Module: GnListResolver

Defined in:
lib/gn_list_resolver.rb,
lib/gn_list_resolver/stats.rb,
lib/gn_list_resolver/reader.rb,
lib/gn_list_resolver/writer.rb,
lib/gn_list_resolver/graphql.rb,
lib/gn_list_resolver/version.rb,
lib/gn_list_resolver/resolver.rb,
lib/gn_list_resolver/collector.rb,
lib/gn_list_resolver/constants.rb,
lib/gn_list_resolver/column_collector.rb,
lib/gn_list_resolver/result_processor.rb,
lib/gn_list_resolver/sci_name_collector.rb

Overview

Namespace module for resolving lists with GN sources

Defined Under Namespace

Classes: Collector, ColumnCollector, GnGraphQL, Reader, Resolver, ResultProcessor, SciNameCollector, Stats, Writer

Constant Summary collapse

VERSION =
"3.0.1.3"
INPUT_MODE =
"r:utf-8"
OUTPUT_MODE =
"w:utf-8"
MATCH_TYPE_EMPTY =
"EmptyMatch"
RESOLVER_URL =
ENV["GN_RESOLVER_URL"] ||
"http://index-api.globalnames.org/api/graphql"
MATCH_TYPES =
%w[
  EmptyMatch
  ExactNameMatchByUUID
  ExactCanonicalNameMatchByUUID
  FuzzyCanonicalMatch
  ExactPartialMatch
  FuzzyPartialMatch
  ExactMatchPartialByGenus
  ErrorInMatch
].freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

rubocop:enable all



47
48
49
# File 'lib/gn_list_resolver.rb', line 47

def logger
  @logger ||= Logger.new(STDERR)
end

Class Method Details

.find_id(row, name) ⇒ Object



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

def find_id(row, name)
  row.key?(:taxonid) ? row[:taxonid].strip : GnUUID.uuid(name)
end

.log(message) ⇒ Object



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

def log(message)
  logger.info(message)
end

.run(opts) ⇒ Object

rubocop:disable Metrics/AbcSize



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gn_list_resolver.rb', line 33

def run(opts)
  opts = opts_struct(opts)
  input_io, output_io = io(opts.input, opts.output)
  reader = create_reader(input_io, opts)
  data = block_given? ? reader.read(&Proc.new) : reader.read
  writer = create_writer(reader, output_io, opts)
  resolver = create_resolver(writer, opts)
  block_given? ? resolver.resolve(data, &Proc.new) : resolver.resolve(data)
  puts resolver.stats.stats if opts[:debug]
  resolver.stats
end

.versionObject



7
8
9
# File 'lib/gn_list_resolver/version.rb', line 7

def self.version
  VERSION
end