Module: Iev

Defined in:
lib/iev/cli.rb,
lib/iev.rb,
lib/iev/cli/ui.rb,
lib/iev/config.rb,
lib/iev/scraper.rb,
lib/iev/version.rb,
lib/iev/exporter.rb,
lib/iev/profiler.rb,
lib/iev/converter.rb,
lib/iev/db_writer.rb,
lib/iev/utilities.rb,
lib/iev/relaton_db.rb,
lib/iev/cli/command.rb,
lib/iev/data_source.rb,
lib/iev/iso_639_code.rb,
lib/iev/term_builder.rb,
lib/iev/source_parser.rb,
lib/iev/data_conversions.rb,
lib/iev/term_attrs_parser.rb,
lib/iev/cli/command_helper.rb,
lib/iev/scraper/page_parser.rb,
lib/iev/supersession_parser.rb,
lib/iev/converter/mathml_to_asciimath.rb

Overview

© Copyright 2020 Ribose Inc.

Defined Under Namespace

Modules: Cli, Converter, DataConversions, DataSource, Utilities Classes: Config, DbWriter, Exporter, Iso639Code, Profiler, RelatonDb, Scraper, SourceParser, SupersessionParser, TermAttrsParser, TermBuilder

Constant Summary collapse

VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details

.configObject



19
20
21
# File 'lib/iev/config.rb', line 19

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



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

def configure
  yield(config) if block_given?
end

.fetch_concept(code) ⇒ Hash?

Fetch full concept data (all languages) for a given IEV code.

Parameters:

  • code (String)

    IEV code, e.g. “103-01-02”

Returns:

  • (Hash, nil)

    concept data hash with all languages



59
60
61
# File 'lib/iev.rb', line 59

def self.fetch_concept(code)
  DataSource.fetch_concept(code)
end

.fetch_term(code, lang) ⇒ Hash?

Fetch localized term data for a given IEV code and language.

Parameters:

  • code (String)

    IEV code, e.g. “103-01-02”

  • lang (String)

    language code, e.g. “en” or “eng”

Returns:

  • (Hash, nil)

    localized concept data



68
69
70
# File 'lib/iev.rb', line 68

def self.fetch_term(code, lang)
  DataSource.fetch_term(code, lang)
end

.get(code, lang) ⇒ String?

Fetch term designation from IEV data.

if code not found then nil,

if language not found then nil.

Parameters:

  • code (String)

    for example “103-01-02”

  • lang (String)

    language code, for example “en”

Returns:

  • (String, nil)

    if found then term,



51
52
53
# File 'lib/iev.rb', line 51

def self.get(code, lang)
  DataSource.fetch_term_designation(code, lang)
end

.reset_config!Object



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

def reset_config!
  @config = nil
end

.scrape_concept(code) ⇒ Hash?

Scrape concept data from Electropedia for a given IEV code. Uses Ferrum (headless Chrome) to handle AWS WAF challenge.

Parameters:

  • code (String)

    IEV code, e.g. “103-01-02”

Returns:

  • (Hash, nil)

    concept data hash or nil if not found



77
78
79
# File 'lib/iev.rb', line 77

def self.scrape_concept(code)
  Scraper.new.fetch_concept(code)
end