Class: Gigawatt::Settings
- Inherits:
-
Object
- Object
- Gigawatt::Settings
- Defined in:
- lib/gigawatt/settings.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#companies ⇒ Object
Returns the value of attribute companies.
-
#projects ⇒ Object
Returns the value of attribute projects.
-
#staff ⇒ Object
Returns the value of attribute staff.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Settings
constructor
A new instance of Settings.
- #path ⇒ Object
- #read ⇒ Object
- #setup? ⇒ Boolean
- #write(type) ⇒ Object
Constructor Details
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
3 4 5 |
# File 'lib/gigawatt/settings.rb', line 3 def access_key @access_key end |
#companies ⇒ Object
Returns the value of attribute companies.
3 4 5 |
# File 'lib/gigawatt/settings.rb', line 3 def companies @companies end |
#projects ⇒ Object
Returns the value of attribute projects.
3 4 5 |
# File 'lib/gigawatt/settings.rb', line 3 def projects @projects end |
#staff ⇒ Object
Returns the value of attribute staff.
3 4 5 |
# File 'lib/gigawatt/settings.rb', line 3 def staff @staff end |
Class Method Details
.defaults ⇒ Object
10 11 12 13 14 |
# File 'lib/gigawatt/settings.rb', line 10 def self.defaults { :path => File.join(Dir.home, '.88miles') } end |
Instance Method Details
#path ⇒ Object
20 21 22 |
# File 'lib/gigawatt/settings.rb', line 20 def path @options[:path] end |
#read ⇒ Object
24 25 26 27 28 29 |
# File 'lib/gigawatt/settings.rb', line 24 def read self.access_key = YAML.load_file(File.join(path, 'accesskey')) if File.exists?(File.join(path, 'accesskey')) self.companies = YAML.load_file(File.join(path, 'companies')) if File.exists?(File.join(path, 'companies')) self.projects = YAML.load_file(File.join(path, 'projects')) if File.exists?(File.join(path, 'projects')) self.staff = YAML.load_file(File.join(path, 'staff')) if File.exists?(File.join(path, 'staff')) end |
#setup? ⇒ Boolean
16 17 18 |
# File 'lib/gigawatt/settings.rb', line 16 def setup? File.exists?(path) && File.directory?(path) end |
#write(type) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/gigawatt/settings.rb', line 31 def write(type) # Make the directory if it doesn't exist FileUtils.mkdir_p(path) unless File.exists?(path) File.write(File.join(path, 'accesskey'), self.access_key.to_yaml) if type == :accesskey File.write(File.join(path, 'companies'), self.companies.to_yaml) if type == :companies File.write(File.join(path, 'projects'), self.projects.to_yaml) if type == :projects File.write(File.join(path, 'staff'), self.staff.to_yaml) if type == :staff FileUtils.chmod 0700, path end |