require 'fileutils' require 'hws_settings' require 'p4_util' # These are helper methods that should be common to most modular 'Apps' in # Helix Web Services. module HWSHelpers # This will ensure that the environment contains a p4 handle that is # configured using our typical `hws_settings` options. # # It should be rare to actually require using this method. This is typically # generated by authentication middleware. # # The p4 is possibly *not* connected or logged in. def require_p4 unless env.key?('p4') env['p4'] = P4Util.open_from_env(env) end end # This ensures that the `p4` handle has an associated temporary client # workspace. # # The local temporary directory is saved under 'p4_root'. def require_p4_with_temp_client require_p4 name = (0...8).map { (65 + rand(26)).chr }.join env['p4_root'] = init_temp_workspace_dir(name) init_temp_client(name) end private def init_temp_workspace_dir(name) dir = File.join(HWSSettings.system.WORKSPACE_PATH, name) unless Dir.exist?(dir) FileUtils.mkpath(dir) FileUtils.chmod(0700, dir) end dir end # Creates a temporary "wide open" client def init_temp_client(name) p4 = env['p4'] spec = p4.fetch_client spec._root = env['p4_root'] spec._client = name p4.save_client(spec) p4.client = name end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
#3 | 15132 | tjuricek | Provde a basic submit -e mechanism on classic perforce workspaces. | ||
#2 | 15110 | tjuricek | Revise changes methods for new p4 connection handling, add server specs, remove model references in client, and update asciidoc documentation. | ||
#1 | 15032 | tjuricek |
Starting config and doc revisions. System is now broken while revisions underway. Configuration of the p4d connection is now done via a single HWSSettings middleware object injected into the Rack env. The HWSP4Cleanup middleware now cleans up any p4 injected into the Rack env. The Auth::App class now mostly just contains one method to generate a p4 ticket. /auth/v1/login. Added yard documentation for the main project. Yard docs have been reconfigured to dump into build/ directories. This should probably be done with each release. Hm... The top level rake file contains a task, 'all:doc', to update our documentation. This should probably be run for each checkin. Hm... Specs are now using Rack::Test on top of a 'live' p4d. I'd suggest you still use the p4util mechanism, which now dumps to a /tmp folder, so we can safely add P4IGNORE rules back into your local .p4config file. Old 'perforce' application now called 'helix_versioning_engine'. Removing cache data. Helix Sync may be slow. It may also get axed. We'll see. |