Class: Docman::Application
- Includes:
- Context, Singleton
- Defined in:
- lib/application.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#deploy_target ⇒ Object
Returns the value of attribute deploy_target.
-
#docroot_config ⇒ Object
readonly
Returns the value of attribute docroot_config.
-
#force ⇒ Object
Returns the value of attribute force.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #build(deploy_target_name, state, options = false) ⇒ Object
- #deploy(deploy_target_name, name, type, version, options = false) ⇒ Object
- #execute(action, state, name = nil) ⇒ Object
- #force? ⇒ Boolean
- #init(name, repo) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
Methods included from Context
Methods included from Logging
#log, logger, #logger, #prefix, #properties_info, #with_logging
Methods inherited from Command
#add_action, #add_actions, create, #describe, #perform, #prefix, register_command, #replace_placeholder, #run_actions, #run_with_hooks
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
38 39 40 41 42 43 |
# File 'lib/application.rb', line 38 def initialize # TODO: Define workspace properly @workspace_dir = Dir.pwd @config = Docman::Config.new(File.join(Pathname(__FILE__).dirname.parent, 'config', 'config.yaml')) @force = false end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
32 33 34 |
# File 'lib/application.rb', line 32 def config @config end |
#deploy_target ⇒ Object
Returns the value of attribute deploy_target.
33 34 35 |
# File 'lib/application.rb', line 33 def deploy_target @deploy_target end |
#docroot_config ⇒ Object (readonly)
Returns the value of attribute docroot_config.
32 33 34 |
# File 'lib/application.rb', line 32 def docroot_config @docroot_config end |
#force ⇒ Object
Returns the value of attribute force.
33 34 35 |
# File 'lib/application.rb', line 33 def force @force end |
#options ⇒ Object
Returns the value of attribute options.
33 34 35 |
# File 'lib/application.rb', line 33 def @options end |
Class Method Details
.bin ⇒ Object
84 85 86 |
# File 'lib/application.rb', line 84 def self.bin File.join root, 'bin' end |
.lib ⇒ Object
88 89 90 |
# File 'lib/application.rb', line 88 def self.lib File.join root, 'lib' end |
.root ⇒ Object
80 81 82 |
# File 'lib/application.rb', line 80 def self.root Pathname(__FILE__).dirname.parent end |
Instance Method Details
#build(deploy_target_name, state, options = false) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/application.rb', line 49 def build(deploy_target_name, state, = false) @options = @deploy_target = @config['deploy_targets'][deploy_target_name] @deploy_target['name'] = deploy_target_name @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target) execute('build', state) end |
#deploy(deploy_target_name, name, type, version, options = false) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/application.rb', line 57 def deploy(deploy_target_name, name, type, version, = false) @options = @deploy_target = @config['deploy_targets'][deploy_target_name] @deploy_target['name'] = deploy_target_name @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target) @docroot_config.states_dependin_on(name, version).keys.each do |state| execute('deploy', state, name) end end |
#execute(action, state, name = nil) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/application.rb', line 67 def execute(action, state, name = nil) params = @deploy_target.clone params['state'] = state params['action'] = action params['name'] = name params['environment'] = @deploy_target['environments'][state] Docman::Deployers::Deployer.create(params, nil, self).perform end |
#force? ⇒ Boolean
76 77 78 |
# File 'lib/application.rb', line 76 def force? @force or @options[:force] end |
#init(name, repo) ⇒ Object
45 46 47 |
# File 'lib/application.rb', line 45 def init(name, repo) `mkdir #{name} && cd #{name} && git clone #{repo} config` end |