Class: AvoDeploy::Config
- Inherits:
-
Object
- Object
- AvoDeploy::Config
- Defined in:
- lib/avodeploy/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#loaded_stage ⇒ Object
readonly
Returns the value of attribute loaded_stage.
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
-
#get(key) ⇒ mixed
Returns a configuration item if set.
-
#initialize ⇒ Config
constructor
Intializes the config object.
-
#merge(other_config) ⇒ Hash
Merges the configuration with another config hash.
-
#set(key, value) ⇒ Object
Sets a configuration item.
-
#setup_stage(name, options = {}, &block) ⇒ Object
Defines a stage.
-
#target(name, options = {}) ⇒ Object
Defines a deployment target.
-
#task(name, options = {}, &block) ⇒ Object
Defines a task.
Constructor Details
#initialize ⇒ Config
Intializes the config object
28 29 30 31 32 33 |
# File 'lib/avodeploy/config.rb', line 28 def initialize @config = setup_config_defaults @stages = {} @targets = {} @loaded_stage = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/avodeploy/config.rb', line 22 def config @config end |
#loaded_stage ⇒ Object (readonly)
Returns the value of attribute loaded_stage.
25 26 27 |
# File 'lib/avodeploy/config.rb', line 25 def loaded_stage @loaded_stage end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
23 24 25 |
# File 'lib/avodeploy/config.rb', line 23 def stages @stages end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
24 25 26 |
# File 'lib/avodeploy/config.rb', line 24 def targets @targets end |
Instance Method Details
#get(key) ⇒ mixed
Returns a configuration item if set
47 48 49 50 51 |
# File 'lib/avodeploy/config.rb', line 47 def get(key) raise ArgumentError, "key #{key} is not set" unless @config.has_key?(key) @config[key] end |
#merge(other_config) ⇒ Hash
Merges the configuration with another config hash
93 94 95 |
# File 'lib/avodeploy/config.rb', line 93 def merge(other_config) @config.merge(other_config) end |
#set(key, value) ⇒ Object
Sets a configuration item
39 40 41 |
# File 'lib/avodeploy/config.rb', line 39 def set(key, value) @config[key] = value end |
#setup_stage(name, options = {}, &block) ⇒ Object
Defines a stage
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/avodeploy/config.rb', line 67 def setup_stage(name, = {}, &block) stages[name] = '' if .has_key?(:desc) stages[name] = [:desc] end if name.to_s == get(:stage).to_s @loaded_stage = name instance_eval(&block) end end |
#target(name, options = {}) ⇒ Object
Defines a deployment target
85 86 87 |
# File 'lib/avodeploy/config.rb', line 85 def target(name, = {}) @targets[name] = AvoDeploy::Target.new(name, ) end |
#task(name, options = {}, &block) ⇒ Object
Defines a task
58 59 60 |
# File 'lib/avodeploy/config.rb', line 58 def task(name, = {}, &block) AvoDeploy::Deployment.instance.task_manager.add_task(name, , &block) end |