Class: Quandl::Command::QConfig
- Inherits:
-
Object
- Object
- Quandl::Command::QConfig
- Defined in:
- lib/quandl/command/qconfig.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(*args) ⇒ QConfig
constructor
A new instance of QConfig.
Constructor Details
#initialize(*args) ⇒ QConfig
Returns a new instance of QConfig.
51 52 53 |
# File 'lib/quandl/command/qconfig.rb', line 51 def initialize(*args) self. = OpenStruct.new(args.) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
47 48 49 |
# File 'lib/quandl/command/qconfig.rb', line 47 def @options end |
Class Method Details
.config_file ⇒ Object
23 24 25 26 |
# File 'lib/quandl/command/qconfig.rb', line 23 def config_file convert_legacy_config @config_file ||= File.join(root_path, 'config') end |
.configuration ⇒ Object
10 11 12 |
# File 'lib/quandl/command/qconfig.rb', line 10 def configuration @configuration ||= self.new( config_file: config_file ) end |
.convert_legacy_config ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/quandl/command/qconfig.rb', line 14 def convert_legacy_config return if File.directory?(root_path) # otherwise move the old .quandl into .quandl/config FileUtils.mv(root_path, "#{root_path}.old") FileUtils.mkdir(root_path) token = File.read("#{root_path}.old") File.write(config_file, "token: #{token}") end |
.root_path ⇒ Object
28 29 30 |
# File 'lib/quandl/command/qconfig.rb', line 28 def root_path @root_path ||= File.join(ENV['HOME'], '.quandl') end |
Instance Method Details
#config ⇒ Object
55 56 57 |
# File 'lib/quandl/command/qconfig.rb', line 55 def config @config ||= OpenStruct.new(YAML.load(File.read(.config_file))) end |