Class: GithubBitbucketDeployer::Configuration
- Inherits:
-
Object
- Object
- GithubBitbucketDeployer::Configuration
- Defined in:
- lib/github_bitbucket_deployer/configuration.rb
Constant Summary collapse
- OPTIONS =
{ 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
15 16 17 18 19 |
# File 'lib/github_bitbucket_deployer/configuration.rb', line 15 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
24 25 26 |
# File 'lib/github_bitbucket_deployer/configuration.rb', line 24 def [](option) send(option) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
precedence over the defaults
41 42 43 |
# File 'lib/github_bitbucket_deployer/configuration.rb', line 41 def merge(hash) to_hash.merge(hash) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
29 30 31 32 33 34 35 |
# File 'lib/github_bitbucket_deployer/configuration.rb', line 29 def to_hash OPTIONS.inject({}) do |hash, option| key = option.first hash[key] = self.send(key) hash end end |
#validate_presence(options) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/github_bitbucket_deployer/configuration.rb', line 45 def validate_presence() OPTIONS.each_pair do |key, value| if [key].nil? raise GithubBitbucketDeployer::ConfigurationException, "#{key} is missing" end end end |