Class: Insup::Settings
- Inherits:
-
Object
- Object
- Insup::Settings
- Defined in:
- lib/insup/settings.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #ignore_patterns ⇒ Object
-
#initialize(filename = '.insup') ⇒ Settings
constructor
A new instance of Settings.
- #insales ⇒ Object
- #log ⇒ Object
- #log_file ⇒ Object
- #log_level ⇒ Object
- #log_pattern ⇒ Object
- #options ⇒ Object
- #save(filename) ⇒ Object
- #tracked_locations ⇒ Object
- #tracker ⇒ Object
- #uploader ⇒ Object
Constructor Details
#initialize(filename = '.insup') ⇒ Settings
Returns a new instance of Settings.
7 8 9 10 11 12 13 14 |
# File 'lib/insup/settings.rb', line 7 def initialize(filename = '.insup') if File.exist?(filename) insupfile = IO.read(filename) @settings = YAML.load(insupfile) else @settings = {} end end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
5 6 7 |
# File 'lib/insup/settings.rb', line 5 def settings @settings end |
Instance Method Details
#ignore_patterns ⇒ Object
28 29 30 |
# File 'lib/insup/settings.rb', line 28 def ignore_patterns return @settings['ignore'] || [] end |
#insales ⇒ Object
32 33 34 |
# File 'lib/insup/settings.rb', line 32 def insales return @settings['insales'] end |
#log ⇒ Object
40 41 42 |
# File 'lib/insup/settings.rb', line 40 def log @settings['log'] || {} end |
#log_file ⇒ Object
58 59 60 |
# File 'lib/insup/settings.rb', line 58 def log_file log['file'] end |
#log_level ⇒ Object
44 45 46 47 48 |
# File 'lib/insup/settings.rb', line 44 def log_level level = log['level'] || 'info' level = "Logger::#{level.upcase}" Kernel.const_get(level) end |
#log_pattern ⇒ Object
54 55 56 |
# File 'lib/insup/settings.rb', line 54 def log_pattern log['pattern'] || "%{message}\n" end |
#options ⇒ Object
50 51 52 |
# File 'lib/insup/settings.rb', line 50 def @settings['options'] || {} end |
#save(filename) ⇒ Object
36 37 38 |
# File 'lib/insup/settings.rb', line 36 def save(filename) File.write(filename, @settings.to_yaml) end |
#tracked_locations ⇒ Object
16 17 18 |
# File 'lib/insup/settings.rb', line 16 def tracked_locations return settings['track'] || [] end |
#tracker ⇒ Object
24 25 26 |
# File 'lib/insup/settings.rb', line 24 def tracker return @settings['tracker'] end |
#uploader ⇒ Object
20 21 22 |
# File 'lib/insup/settings.rb', line 20 def uploader return @settings['uploader'] end |