class Dockerploy::Configuration

Constants

DEFAULT_CONFIG_FILE
FileNotFound
NoEnvError

Attributes

application_name[R]
docker_host[R]
env[R]
image_name[R]

Public Class Methods

new(options = {}) click to toggle source
# 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

Public Instance Methods

after_all_hooks() click to toggle source
# File lib/dockerploy/configuration.rb, line 63
def after_all_hooks
  return {} if options[:hooks].nil? || options[:hooks][:after_deploy].nil?
  options[:hooks][:after_deploy]
end
after_hooks() click to toggle source
# File lib/dockerploy/configuration.rb, line 68
def after_hooks
  raise NoEnvError if @env.nil?
  return {} if options[@env].nil?
  hooks = options[@env][:hooks]
  return {} if hooks.nil? || hooks[:after_deploy].nil?
  hooks[:after_deploy]
end
before_all_hooks() click to toggle source
# File lib/dockerploy/configuration.rb, line 50
def before_all_hooks
  return {} if options[:hooks].nil? || options[:hooks][:before_deploy].nil?
  options[:hooks][:before_deploy]
end
before_hooks() click to toggle source
# File lib/dockerploy/configuration.rb, line 55
def before_hooks
  raise NoEnvError if @env.nil?
  return {} if options[@env].nil?
  hooks = options[@env][:hooks]
  return {} if hooks.nil? || hooks[:before_deploy].nil?
  hooks[:before_deploy]
end
branch() click to toggle source
# File lib/dockerploy/configuration.rb, line 35
def branch
  raise NoEnvError if @env.nil?
  options[@env][:branch]
end
env_file() click to toggle source
# File lib/dockerploy/configuration.rb, line 30
def env_file
  raise NoEnvError if @env.nil?
  options[@env][:env_file]
end
image_tag() click to toggle source
# File lib/dockerploy/configuration.rb, line 45
def image_tag
  raise NoEnvError if @env.nil?
  options[@env][:image_tag]
end
servers() click to toggle source
# File lib/dockerploy/configuration.rb, line 20
def servers
  raise NoEnvError if @env.nil?
  options[@env][:servers]
end
tagging?() click to toggle source
# File lib/dockerploy/configuration.rb, line 40
def tagging?
  raise NoEnvError if @env.nil?
  options[@env][:tagging]
end
volumes() click to toggle source
# File lib/dockerploy/configuration.rb, line 25
def volumes
  raise NoEnvError if @env.nil?
  options[@env][:volumes]
end

Private Instance Methods

options() click to toggle source
# File lib/dockerploy/configuration.rb, line 78
def options
  @options ||= begin
    raise FileNotFound unless File.exist?(@config_file)
    YAML.load_file(@config_file).symbolize_keys
  end
end