Module: MotionSettings
- Defined in:
- lib/motion_settings.rb,
lib/motion_settings/version.rb
Constant Summary collapse
- GLOBAL_CONFIG =
File.("~/.motion-settings.yml")
- APP_CONFIG =
File.(".motion-settings.yml")
- VERSION =
"1.0.0"
Class Method Summary collapse
- .check_files ⇒ Object
- .environmentize(settings) ⇒ Object
- .log_override(key) ⇒ Object
- .parse(file) ⇒ Object
- .start ⇒ Object
Class Method Details
.check_files ⇒ Object
19 20 21 22 |
# File 'lib/motion_settings.rb', line 19 def check_files system("touch #{GLOBAL_CONFIG.shellescape}") unless File.exist?(GLOBAL_CONFIG) system("touch #{APP_CONFIG.shellescape}") unless File.exist?(APP_CONFIG) end |
.environmentize(settings) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/motion_settings.rb', line 24 def environmentize(settings) settings.each do |key, value| log_override(key) unless ENV[key].nil? ENV[key] = value end end |
.log_override(key) ⇒ Object
41 42 43 |
# File 'lib/motion_settings.rb', line 41 def log_override(key) App.log "motion-settings", "#{key} previously set has been overridden" end |
.parse(file) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/motion_settings.rb', line 31 def parse(file) # catch exception for a bug in ruby-1.9.3p194 # https://bugs.ruby-lang.org/issues/6487 begin YAML.load_file(file) rescue TypeError {} end end |
.start ⇒ Object
13 14 15 16 17 |
# File 'lib/motion_settings.rb', line 13 def start check_files environmentize parse(GLOBAL_CONFIG) environmentize parse(APP_CONFIG) end |