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/section.rb,
lib/iev/version.rb,
lib/iev/exporter.rb,
lib/iev/iev_code.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/subject_area.rb,
lib/iev/term_builder.rb,
lib/iev/source_parser.rb,
lib/iev/subject_areas.rb,
lib/iev/scraper/browser.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/subject_area_concepts.rb,
lib/iev/converter/mathml_to_asciimath.rb

Overview

© Copyright 2020 Ribose Inc.

Defined Under Namespace

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

Constant Summary collapse

IEV_SOURCE =

IEV dataset URN — single source of truth for all concept references.

"urn:iec:std:iec:60050"
VERSION =
"0.4.6"

Class Method Summary collapse

Class Method Details

.area_for_section(section_code) ⇒ SubjectArea?

Return the parent subject area for a given section code.

Parameters:

  • section_code (String)

    e.g. “102-01”

Returns:



141
142
143
# File 'lib/iev.rb', line 141

def self.area_for_section(section_code)
  SubjectAreas.area_for_section(section_code)
end

.configConfig

Returns:



49
50
51
# File 'lib/iev.rb', line 49

def self.config
  @config ||= Config.new
end

.configure {|Config| ... } ⇒ Object

Yield the config object for initialization.

Yields:



55
56
57
# File 'lib/iev.rb', line 55

def self.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)

    concept data hash with all languages

Raises:



84
85
86
# File 'lib/iev.rb', line 84

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 or nil if not found

Raises:



94
95
96
# File 'lib/iev.rb', line 94

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

.find_section(section_code) ⇒ Section?

Find a section by its section code.

Parameters:

  • section_code (String)

    e.g. “102-01”

Returns:



127
128
129
# File 'lib/iev.rb', line 127

def self.find_section(section_code)
  SubjectAreas.find_section(section_code)
end

.find_subject_area(code) ⇒ SubjectArea?

Find a subject area by code.

Parameters:

  • code (String, Integer)

    e.g. “102”

Returns:



120
121
122
# File 'lib/iev.rb', line 120

def self.find_subject_area(code)
  SubjectAreas.find_area(code)
end

.get(code, lang) ⇒ String?

Fetch term designation from IEV data.

Parameters:

  • code (String)

    for example “103-01-02”

  • lang (String)

    language code, for example “en”

Returns:

  • (String, nil)

    if found then term, if code or language not found then nil.



73
74
75
76
77
# File 'lib/iev.rb', line 73

def self.get(code, lang)
  DataSource.fetch_term_designation(code, lang)
rescue DataSource::NotFoundError
  nil
end

.parse_code(code) ⇒ IevCode?

Parse an IEV code into its structural components.

Parameters:

  • code (String)

    e.g. “103-01-02”

Returns:

  • (IevCode, nil)

    nil if the code is blank



148
149
150
# File 'lib/iev.rb', line 148

def self.parse_code(code)
  IevCode.parse(code)
end

.reset_config!Object

Reset config (useful in tests).



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

def self.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



105
106
107
# File 'lib/iev.rb', line 105

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

.sections_for(code) ⇒ Array<Section>

Return sections for a given area code.

Parameters:

  • code (String, Integer)

    e.g. “102”

Returns:



134
135
136
# File 'lib/iev.rb', line 134

def self.sections_for(code)
  SubjectAreas.sections_for(code)
end

.subject_areasArray<SubjectArea>

Return all IEV subject areas with their sections (from bundled data).

Returns:



113
114
115
# File 'lib/iev.rb', line 113

def self.subject_areas
  SubjectAreas.all
end