class BigBrother::Settings
Public Class Methods
defaults()
click to toggle source
# File lib/big_brother/settings.rb, line 12 def self.defaults { "history_file" => File.expand_path("~/.bash_history"), "push_url" => "https://ministry-of-truth.herokuapp.com/", "api_key" => nil } end
get(setting)
click to toggle source
# File lib/big_brother/settings.rb, line 26 def self.get(setting) @settings[setting] end
load()
click to toggle source
# File lib/big_brother/settings.rb, line 20 def self.load touch settings_file @settings = defaults.merge(JSON.parse(File.read(settings_file))) save end
save()
click to toggle source
# File lib/big_brother/settings.rb, line 35 def self.save File.write(settings_file, @settings.to_json) end
set(setting, value)
click to toggle source
# File lib/big_brother/settings.rb, line 30 def self.set(setting, value) @settings[setting] = value save end
settings_file()
click to toggle source
# File lib/big_brother/settings.rb, line 4 def self.settings_file @settings_file || File.expand_path("~/.big_brother.json") end
settings_file=(path)
click to toggle source
# File lib/big_brother/settings.rb, line 8 def self.settings_file=(path) @settings_file = path end
touch(file_name)
click to toggle source
# File lib/big_brother/settings.rb, line 39 def self.touch(file_name) File.write(file_name, "{}") unless File.exists? file_name end