Class: GitSafe::Configuration
- Inherits:
-
Object
- Object
- GitSafe::Configuration
- Defined in:
- lib/git-safe/configuration.rb
Constant Summary collapse
- OPTIONS =
{ logger: ::Logger.new(STDOUT), branch: 'master', remote: 'origin', clone_command_repo_dir_replace_text: '<REPO_DIR>', ssh_private_key: nil, # path or string }.freeze
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.
Constructor Details
#initialize ⇒ Configuration
Initializes defaults to be the environment varibales of the same names
17 18 19 20 21 |
# File 'lib/git-safe/configuration.rb', line 17 def initialize OPTIONS.each_pair do |key, value| send("#{key}=", value) end end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
26 27 28 |
# File 'lib/git-safe/configuration.rb', line 26 def [](option) send(option) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
precedence over the defaults
42 43 44 |
# File 'lib/git-safe/configuration.rb', line 42 def merge(hash) to_hash.merge(hash) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
31 32 33 34 35 36 |
# File 'lib/git-safe/configuration.rb', line 31 def to_hash OPTIONS.each_with_object({}) do |option, hash| key = option.first hash[key] = send(key) end end |