Class: Dockerploy::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/dockerploy/configuration.rb', line 9

def initialize(options = {})
  @config_file = options.fetch(:config_file, DEFAULT_CONFIG_FILE)
  @env = options.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_nameObject (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_hostObject (readonly)

Returns the value of attribute docker_host.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def docker_host
  @docker_host
end

#envObject (readonly)

Returns the value of attribute env.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def env
  @env
end

#image_nameObject (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

#branchObject

Raises:



35
36
37
38
# File 'lib/dockerploy/configuration.rb', line 35

def branch
  raise NoEnvError if @env.nil?
  options[@env][:branch]
end

#env_fileObject

Raises:



30
31
32
33
# File 'lib/dockerploy/configuration.rb', line 30

def env_file
  raise NoEnvError if @env.nil?
  options[@env][:env_file]
end

#serversObject

Raises:



20
21
22
23
# File 'lib/dockerploy/configuration.rb', line 20

def servers
  raise NoEnvError if @env.nil?
  options[@env][:servers]
end

#tagging?Boolean

Returns:

  • (Boolean)

Raises:



40
41
42
43
# File 'lib/dockerploy/configuration.rb', line 40

def tagging?
  raise NoEnvError if @env.nil?
  options[@env][:tagging]
end

#volumesObject

Raises:



25
26
27
28
# File 'lib/dockerploy/configuration.rb', line 25

def volumes
  raise NoEnvError if @env.nil?
  options[@env][:volumes]
end