Class: GithubHerokuDeployer::Configuration
- Inherits:
-
Object
- Object
- GithubHerokuDeployer::Configuration
- Defined in:
- lib/github_heroku_deployer/configuration.rb
Constant Summary collapse
- OPTIONS =
{ github_repo: ENV["GITHUB_REPO"], heroku_api_key: ENV["HEROKU_API_KEY"], heroku_app_name: ENV["HEROKU_APP_NAME"], heroku_repo: ENV["HEROKU_REPO"], heroku_username: ENV["HEROKU_USERNAME"], id_rsa: ENV["ID_RSA"], logger: ::Logger.new(STDOUT), repo_dir: ENV["REPO_DIR"] }
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
-
#initialize ⇒ Configuration
constructor
Initializes defaults to be the environment varibales of the same names.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. -
#to_hash ⇒ Object
Returns a hash of all configurable options.
- #validate_presence(options) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Initializes defaults to be the environment varibales of the same names
20 21 22 23 24 |
# File 'lib/github_heroku_deployer/configuration.rb', line 20 def initialize OPTIONS.each_pair do |key, value| self.send("#{key}=", value) end end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
29 30 31 |
# File 'lib/github_heroku_deployer/configuration.rb', line 29 def [](option) send(option) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
precedence over the defaults
46 47 48 |
# File 'lib/github_heroku_deployer/configuration.rb', line 46 def merge(hash) to_hash.merge(hash) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
34 35 36 37 38 39 40 |
# File 'lib/github_heroku_deployer/configuration.rb', line 34 def to_hash OPTIONS.inject({}) do |hash, option| key = option.first hash[key] = self.send(key) hash end end |
#validate_presence(options) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/github_heroku_deployer/configuration.rb', line 50 def validate_presence() OPTIONS.each_pair do |key, value| if [key].nil? raise GithubHerokuDeployer::ConfigurationException, "#{key} is missing" end end end |