Class: EY::Config::EnvironmentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, parent) ⇒ EnvironmentConfig

Returns a new instance of EnvironmentConfig.



103
104
105
106
107
# File 'lib/engineyard/config.rb', line 103

def initialize(config, name, parent)
  @config = config || {}
  @name = name
  @parent = parent
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



101
102
103
# File 'lib/engineyard/config.rb', line 101

def name
  @name
end

Instance Method Details

#branchObject



125
126
127
# File 'lib/engineyard/config.rb', line 125

def branch
  fetch('branch', nil)
end

#ensure_existsObject



113
114
115
116
117
# File 'lib/engineyard/config.rb', line 113

def ensure_exists
  unless path && path.exist?
    raise EY::Error, "Please initialize this application with the following command:\n\tey init"
  end
end

#fetch(key, default = nil, &block) ⇒ Object



119
120
121
122
123
# File 'lib/engineyard/config.rb', line 119

def fetch(key, default = nil, &block)
  @config.fetch(key.to_s) do
    @parent.fetch_from_defaults(key.to_s, default, &block)
  end
end

#migrateObject



129
130
131
132
133
134
# File 'lib/engineyard/config.rb', line 129

def migrate
  ensure_exists
  fetch('migrate') do
    raise EY::Error, "'migrate' not found in #{path}. Reinitialize with:\n\tey init"
  end
end

#migration_commandObject Also known as: migrate_command



136
137
138
139
140
141
# File 'lib/engineyard/config.rb', line 136

def migration_command
  ensure_exists
  fetch('migration_command') do
    raise EY::Error, "'migration_command' not found in #{path}. Reinitialize with:\n\tey init"
  end
end

#pathObject



109
110
111
# File 'lib/engineyard/config.rb', line 109

def path
  @parent.path
end

#verboseObject



145
146
147
# File 'lib/engineyard/config.rb', line 145

def verbose
  fetch('verbose', false)
end