class Slipsquare::Configuration
This is the configuration object. It reads in configuration from a .slipsquare file located in the user's home directory
Constants
- FILE_NAME
Attributes
data[R]
path[R]
Public Class Methods
new()
click to toggle source
# File lib/slipsquare/config.rb, line 14 def initialize @path = ENV["SLIPSTREAM_CONFIG_PATH"] || File.join(File.expand_path("~"), FILE_NAME) @data = self.load_config_file end
Public Instance Methods
app_key()
click to toggle source
# File lib/slipsquare/config.rb, line 28 def app_key @data['authentication']['app_key'] end
app_secret()
click to toggle source
# File lib/slipsquare/config.rb, line 40 def app_secret @data['client']['app_secret'] end
app_token()
click to toggle source
# File lib/slipsquare/config.rb, line 36 def app_token @data['client']['app_token'] end
create_config_file(app_key, secret_key, app_token, app_secret)
click to toggle source
Writes a config file
# File lib/slipsquare/config.rb, line 55 def create_config_file(app_key, secret_key, app_token, app_secret) require 'yaml' File.open(@path, File::RDWR|File::TRUNC|File::CREAT, 0600) do |file| data = { "authentication" => { "app_key" => app_key, "secret_key" => secret_key }, "client" => { "app_token" => app_token, "app_secret" => app_secret } } file.write data.to_yaml end end
load_config_file()
click to toggle source
If we can't load the config file, self.data is nil, which we can check for in CheckConfiguration
# File lib/slipsquare/config.rb, line 21 def load_config_file require 'yaml' YAML.load_file(@path) rescue Errno::ENOENT return end
reload!()
click to toggle source
Re-loads the config
# File lib/slipsquare/config.rb, line 50 def reload! @data = self.load_config_file end
reset!()
click to toggle source
Re-runs initialize
# File lib/slipsquare/config.rb, line 45 def reset! self.send(:initialize) end
secret_key()
click to toggle source
# File lib/slipsquare/config.rb, line 32 def secret_key @data['authentication']['secret_key'] end