Class: Navy::Configuration
- Inherits:
-
Object
- Object
- Navy::Configuration
- Defined in:
- lib/navy/configuration.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Class Method Summary collapse
Instance Method Summary collapse
- #applications ⇒ Object
- #apps ⇒ Object
- #container_name(app, options = {}) ⇒ Object
- #dependencies ⇒ Object
- #docker_args(app) ⇒ Object
- #find_app(name) ⇒ Object
-
#initialize(definition) ⇒ Configuration
constructor
A new instance of Configuration.
- #post_tasks(app) ⇒ Object
- #pre_tasks(app) ⇒ Object
- #set_env(env) ⇒ Object
Constructor Details
#initialize(definition) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 |
# File 'lib/navy/configuration.rb', line 7 def initialize(definition) @definition = definition @apps = parse_apps end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/navy/configuration.rb', line 5 def definition @definition end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/navy/configuration.rb', line 5 def environment @environment end |
Class Method Details
.from_file(config_file) ⇒ Object
17 18 19 20 |
# File 'lib/navy/configuration.rb', line 17 def self.from_file(config_file) cfg = YAML.load_file(config_file) new(cfg) end |
.from_string(yaml_content) ⇒ Object
12 13 14 15 |
# File 'lib/navy/configuration.rb', line 12 def self.from_string(yaml_content) cfg = YAML.load(yaml_content) new(cfg) end |
Instance Method Details
#applications ⇒ Object
44 45 46 |
# File 'lib/navy/configuration.rb', line 44 def applications @apps.map &:name end |
#apps ⇒ Object
22 23 24 25 26 |
# File 'lib/navy/configuration.rb', line 22 def apps @apps.each do |app| yield app if block_given? end end |
#container_name(app, options = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/navy/configuration.rb', line 37 def container_name(app, ={}) mode = [:mode] convoy = [:convoy] scale = [:scale] [convoy, app, mode, scale].compact.join '_' end |
#dependencies ⇒ Object
52 53 54 55 56 |
# File 'lib/navy/configuration.rb', line 52 def dependencies @deps.each do |app| yield app if block_given? end end |
#docker_args(app) ⇒ Object
66 67 68 |
# File 'lib/navy/configuration.rb', line 66 def docker_args(app) @docker_args[app] end |
#find_app(name) ⇒ Object
48 49 50 |
# File 'lib/navy/configuration.rb', line 48 def find_app(name) @apps.detect {|a| a.name == name } end |
#post_tasks(app) ⇒ Object
62 63 64 |
# File 'lib/navy/configuration.rb', line 62 def post_tasks(app) @post[app] || [] end |
#pre_tasks(app) ⇒ Object
58 59 60 |
# File 'lib/navy/configuration.rb', line 58 def pre_tasks(app) @pre[app] || [] end |
#set_env(env) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/navy/configuration.rb', line 28 def set_env(env) @environment = env @env = environments[environment] || {} @deps = parse_deps @pre = parse_pre_tasks @post = parse_post_tasks @docker_args = parse_docker_args end |