Module: FileConvert::Configure
- Included in:
- FileConvert
- Defined in:
- lib/file_convert/configure.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'config/file_convert.yml'
Class Method Summary collapse
- .config ⇒ Object
- .config_from_yaml ⇒ Object
- .config_yaml_present? ⇒ Boolean
-
.init_config! ⇒ Object
Loads config/file_convert.yml into Config Or defaults to empty Hash if config file is not present.
Instance Method Summary collapse
Class Method Details
.config ⇒ Object
17 18 19 |
# File 'lib/file_convert/configure.rb', line 17 def self.config @@config end |
.config_from_yaml ⇒ Object
11 12 13 14 15 |
# File 'lib/file_convert/configure.rb', line 11 def self.config_from_yaml ::File.open(DEFAULT_CONFIG_PATH) do |file| YAML.load(file)['file_convert'] end end |
.config_yaml_present? ⇒ Boolean
7 8 9 |
# File 'lib/file_convert/configure.rb', line 7 def self.config_yaml_present? ::File.exist?(DEFAULT_CONFIG_PATH) end |
.init_config! ⇒ Object
Loads config/file_convert.yml into Config Or defaults to empty Hash if config file is not present
24 25 26 |
# File 'lib/file_convert/configure.rb', line 24 def self.init_config! @@config = config_yaml_present? ? config_from_yaml : {} end |
Instance Method Details
#config ⇒ Object
32 33 34 |
# File 'lib/file_convert/configure.rb', line 32 def config Configure.config end |
#config_present? ⇒ Boolean
36 37 38 39 |
# File 'lib/file_convert/configure.rb', line 36 def config_present? provider = 'google_service_account' config.is_a?(Hash) && config.key?(provider) end |
#configure {|config| ... } ⇒ Object
28 29 30 |
# File 'lib/file_convert/configure.rb', line 28 def configure yield config end |