Class: Dockerploy::Configuration
- Inherits:
-
Object
- Object
- Dockerploy::Configuration
- Defined in:
- lib/dockerploy/configuration.rb
Constant Summary collapse
- NoEnvError =
Class.new(StandardError)
- FileNotFound =
Class.new(StandardError)
- DEFAULT_CONFIG_FILE =
'docker/config.yml'.freeze
Instance Attribute Summary collapse
-
#application_name ⇒ Object
readonly
Returns the value of attribute application_name.
-
#docker_host ⇒ Object
readonly
Returns the value of attribute docker_host.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#image_name ⇒ Object
readonly
Returns the value of attribute image_name.
Instance Method Summary collapse
- #after_all_hooks ⇒ Object
- #after_hooks ⇒ Object
- #before_all_hooks ⇒ Object
- #before_hooks ⇒ Object
- #branch ⇒ Object
- #env_file ⇒ Object
- #image_tag ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #servers ⇒ Object
- #tagging? ⇒ Boolean
- #volumes ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dockerploy/configuration.rb', line 9 def initialize( = {}) @config_file = .fetch(:config_file, DEFAULT_CONFIG_FILE) @env = .fetch(:env) @env = @env.to_sym if @env raise FileNotFound unless File.exist?(@config_file) config = YAML.load_file(@config_file).symbolize_keys @application_name = config.fetch(:application_name) @docker_host = config.fetch(:docker_host) @image_name = config.fetch(:image_name) end |
Instance Attribute Details
#application_name ⇒ Object (readonly)
Returns the value of attribute application_name.
7 8 9 |
# File 'lib/dockerploy/configuration.rb', line 7 def application_name @application_name end |
#docker_host ⇒ Object (readonly)
Returns the value of attribute docker_host.
7 8 9 |
# File 'lib/dockerploy/configuration.rb', line 7 def docker_host @docker_host end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/dockerploy/configuration.rb', line 7 def env @env end |
#image_name ⇒ Object (readonly)
Returns the value of attribute image_name.
7 8 9 |
# File 'lib/dockerploy/configuration.rb', line 7 def image_name @image_name end |
Instance Method Details
#after_all_hooks ⇒ Object
63 64 65 66 |
# File 'lib/dockerploy/configuration.rb', line 63 def after_all_hooks return {} if [:hooks].nil? || [:hooks][:after_deploy].nil? [:hooks][:after_deploy] end |
#after_hooks ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/dockerploy/configuration.rb', line 68 def after_hooks raise NoEnvError if @env.nil? return {} if [@env].nil? hooks = [@env][:hooks] return {} if hooks.nil? || hooks[:after_deploy].nil? hooks[:after_deploy] end |
#before_all_hooks ⇒ Object
50 51 52 53 |
# File 'lib/dockerploy/configuration.rb', line 50 def before_all_hooks return {} if [:hooks].nil? || [:hooks][:before_deploy].nil? [:hooks][:before_deploy] end |
#before_hooks ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/dockerploy/configuration.rb', line 55 def before_hooks raise NoEnvError if @env.nil? return {} if [@env].nil? hooks = [@env][:hooks] return {} if hooks.nil? || hooks[:before_deploy].nil? hooks[:before_deploy] end |
#branch ⇒ Object
35 36 37 38 |
# File 'lib/dockerploy/configuration.rb', line 35 def branch raise NoEnvError if @env.nil? [@env][:branch] end |
#env_file ⇒ Object
30 31 32 33 |
# File 'lib/dockerploy/configuration.rb', line 30 def env_file raise NoEnvError if @env.nil? [@env][:env_file] end |
#image_tag ⇒ Object
45 46 47 48 |
# File 'lib/dockerploy/configuration.rb', line 45 def image_tag raise NoEnvError if @env.nil? [@env][:image_tag] end |
#servers ⇒ Object
20 21 22 23 |
# File 'lib/dockerploy/configuration.rb', line 20 def servers raise NoEnvError if @env.nil? [@env][:servers] end |
#tagging? ⇒ Boolean
40 41 42 43 |
# File 'lib/dockerploy/configuration.rb', line 40 def tagging? raise NoEnvError if @env.nil? [@env][:tagging] end |
#volumes ⇒ Object
25 26 27 28 |
# File 'lib/dockerploy/configuration.rb', line 25 def volumes raise NoEnvError if @env.nil? [@env][:volumes] end |