Module: Uktt

Defined in:
lib/uktt.rb,
lib/uktt/cli.rb,
lib/uktt/pdf.rb,
lib/uktt/http.rb,
lib/uktt/quota.rb,
lib/uktt/chapter.rb,
lib/uktt/heading.rb,
lib/uktt/section.rb,
lib/uktt/version.rb,
lib/uktt/commodity.rb,
lib/uktt/monetary_exchange_rate.rb

Defined Under Namespace

Classes: CLI, Chapter, Commodity, Error, Heading, Http, MonetaryExchangeRate, Pdf, Quota, Section

Constant Summary collapse

API_HOST_PROD =
'https://www.trade-tariff.service.gov.uk/api'.freeze
API_HOST_LOCAL =
'http://localhost:3002/api'.freeze
API_VERSION =
'v1'.freeze
SECTION =
'sections'.freeze
CHAPTER =
'chapters'.freeze
HEADING =
'headings'.freeze
COMMODITY =
'commodities'.freeze
M_X_RATE =
'monetary_exchange_rates'.freeze
GOODS_NOMENCLATURE =
'goods_nomenclatures'.freeze
QUOTA =
'quotas'.freeze
PARENT_CURRENCY =
'EUR'.freeze
VERSION =
'0.2.15'.freeze

Class Method Summary collapse

Class Method Details

.configObject



58
59
60
# File 'lib/uktt.rb', line 58

def self.config
  @config
end

.configure(opts = {}) ⇒ Object

Configure through hash



41
42
43
# File 'lib/uktt.rb', line 41

def self.configure(opts = {})
  opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
end

.configure_with(path_to_yaml_file) ⇒ Object

Configure through yaml file



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/uktt.rb', line 46

def self.configure_with(path_to_yaml_file)
  begin
    config = YAML::load(IO.read(path_to_yaml_file))
  rescue Errno::ENOENT
    log(:warning, "YAML configuration file couldn't be found. Using defaults."); return
  rescue Psych::SyntaxError
    log(:warning, "YAML configuration file contains invalid syntax. Using defaults."); return
  end

  configure(config)
end