Class: TuneupConfig

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultsObject



7
8
9
# File 'lib/tuneup_config.rb', line 7

def self.defaults
  { 'api_key' => nil }
end

Instance Method Details

#config_fileObject



21
22
23
# File 'lib/tuneup_config.rb', line 21

def config_file
  File.join(RAILS_ROOT, 'config', 'fiveruns_tuneup.yml')
end

#dataObject



15
16
17
18
19
# File 'lib/tuneup_config.rb', line 15

def data
  @data ||= begin
    YAML.load(File.read(config_file)) rescue self.class.defaults
  end
end

#save!Object



11
12
13
# File 'lib/tuneup_config.rb', line 11

def save!
  File.open(config_file, 'w') { |f| f.puts data.to_yaml }
end

#stateObject



25
26
27
# File 'lib/tuneup_config.rb', line 25

def state
  data['api_key'] ? :registered : :unregistered
end