Class: Quandl::Command::QConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/quandl/command/qconfig.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ QConfig

Returns a new instance of QConfig.



61
62
63
# File 'lib/quandl/command/qconfig.rb', line 61

def initialize(*args)
  self.options = OpenStruct.new(args.extract_options!)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



57
58
59
# File 'lib/quandl/command/qconfig.rb', line 57

def options
  @options
end

Class Method Details

.config_fileObject



15
16
17
18
19
20
21
# File 'lib/quandl/command/qconfig.rb', line 15

def config_file
  return @config_file if defined?(@config_file)
  @config_file = File.join(root_path, 'config')
  convert_legacy_config
  ensure_directory_is_present
  @config_file
end

.configurationObject



11
12
13
# File 'lib/quandl/command/qconfig.rb', line 11

def configuration
  @configuration ||= self.new( config_file: config_file )
end

.root_pathObject



23
24
25
# File 'lib/quandl/command/qconfig.rb', line 23

def root_path
  @root_path ||= File.join(ENV['HOME'], '.quandl')
end

Instance Method Details

#configObject



65
66
67
# File 'lib/quandl/command/qconfig.rb', line 65

def config
  @config ||= OpenStruct.new(YAML.load(File.read(options.config_file)))
end