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 28 29 30 |
# 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[:dir] = @args[:dir].strip if key?(:dir) @args[:lang] = @args[:lang].strip if key?(:lang) @args[:title] = @args[:title].strip if key?(:title) @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
32 33 34 |
# File 'lib/undrive_google/config_file.rb', line 32 def [](val) args[val] end |
#any? ⇒ Boolean
40 41 42 |
# File 'lib/undrive_google/config_file.rb', line 40 def any? args.keys.any? end |
#key?(k) ⇒ Boolean
36 37 38 |
# File 'lib/undrive_google/config_file.rb', line 36 def key?(k) args.key?(k) end |