Class: Insup::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/insup/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#settingsObject (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_patternsObject



28
29
30
# File 'lib/insup/settings.rb', line 28

def ignore_patterns
  return @settings['ignore'] || []
end

#insalesObject



32
33
34
# File 'lib/insup/settings.rb', line 32

def insales
  return @settings['insales']
end

#logObject



40
41
42
# File 'lib/insup/settings.rb', line 40

def log
  @settings['log'] || {}
end

#log_fileObject



58
59
60
# File 'lib/insup/settings.rb', line 58

def log_file
  log['file']
end

#log_levelObject



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_patternObject



54
55
56
# File 'lib/insup/settings.rb', line 54

def log_pattern
  log['pattern'] || "%{message}\n"
end

#optionsObject



50
51
52
# File 'lib/insup/settings.rb', line 50

def options
  @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_locationsObject



16
17
18
# File 'lib/insup/settings.rb', line 16

def tracked_locations
  return settings['track'] || []
end

#trackerObject



24
25
26
# File 'lib/insup/settings.rb', line 24

def tracker
  return @settings['tracker']
end

#uploaderObject



20
21
22
# File 'lib/insup/settings.rb', line 20

def uploader
  return @settings['uploader']
end