Class: Quandl::Command::Config

Inherits:
Object
  • Object
show all
Includes:
Support::Attributes
Defined in:
lib/quandl/command/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Config



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

def initialize(opts={})
  self.options = opts.symbolize_keys
  convert_legacy_config
  ensure_directory_is_present
  @attributes = read_config_from_file.stringify_keys
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/quandl/command/config.rb', line 14

def options
  @options
end

Instance Method Details

#auth_tokenObject



40
41
42
43
44
45
46
# File 'lib/quandl/command/config.rb', line 40

def auth_token
  return @auth_token if @auth_token.present?
  @auth_token = options[:token] if options[:token].present?
  @auth_token = ENV['QUANDL_TOKEN'] if @auth_token.blank?
  @auth_token = read_attribute(:token) if @auth_token.blank?
  @auth_token
end

#file_dirObject



56
57
58
# File 'lib/quandl/command/config.rb', line 56

def file_dir
  File.dirname(file_path)
end

#file_pathObject



52
53
54
# File 'lib/quandl/command/config.rb', line 52

def file_path
  options[:file_path]
end

#quandl_urlObject



31
32
33
34
35
36
37
38
# File 'lib/quandl/command/config.rb', line 31

def quandl_url
  return @quandl_url if @quandl_url.present?
  @quandl_url = options[:url] if options[:url].present?
  @quandl_url = ENV['QUANDL_URL'] if @quandl_url.blank?
  @quandl_url = read_attribute(:quandl_url) if @quandl_url.blank?
  @quandl_url = 'http://quandl.com/api/' if @quandl_url.blank?
  @quandl_url
end

#request_platformObject



48
49
50
# File 'lib/quandl/command/config.rb', line 48

def request_platform
  'sandbox' if options[:sandbox].present?
end

#stderrObject



27
28
29
# File 'lib/quandl/command/config.rb', line 27

def stderr
  options[:stderr] || read_attribute(:stderr)
end

#stdoutObject



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

def stdout
  options[:stdout] || read_attribute(:stdout)
end