Class: UndriveGoogle::ConfigFile
- Inherits:
-
Object
- Object
- UndriveGoogle::ConfigFile
- Defined in:
- lib/undrive_google/config_file.rb
Overview
Represents the YAML config file for this gem
Constant Summary collapse
- DEFAULT =
{}.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #[](val) ⇒ Object
- #any? ⇒ Boolean
-
#initialize(path) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
- #key?(k) ⇒ Boolean
Constructor Details
#initialize(path) ⇒ ConfigFile
Returns a new instance of ConfigFile.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/undrive_google/config_file.rb', line 10 def initialize(path) @args = config_file(path) validate(@args) return if @args == DEFAULT rename_keys = (@args.keys - [:rename_pattern]).select { |k| k.start_with?("rename") } if rename_keys.any? @args[:rename] = rename_keys.each_with_object({}) do |k, rename| key = k.to_s.sub("rename_", "") rename[key.to_sym] = @args.delete(k.to_sym) end end @args[:extensions] = Helpers::Parse.extensions(@args[:extensions]) if key?(:extensions) rename_pattern = @args.delete(:rename_pattern) @args[:rename_proc] = Helpers::Parse.rename_proc(rename_pattern) if rename_pattern end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
8 9 10 |
# File 'lib/undrive_google/config_file.rb', line 8 def args @args end |
Instance Method Details
#[](val) ⇒ Object
29 30 31 |
# File 'lib/undrive_google/config_file.rb', line 29 def [](val) args[val] end |
#any? ⇒ Boolean
37 38 39 |
# File 'lib/undrive_google/config_file.rb', line 37 def any? args.keys.any? end |
#key?(k) ⇒ Boolean
33 34 35 |
# File 'lib/undrive_google/config_file.rb', line 33 def key?(k) args.key?(k) end |