Module: Relaton::Cli

Extended by:
Config
Included in:
Command, SubcommandCollection, SubcommandDb
Defined in:
lib/relaton-cli.rb,
lib/relaton/cli.rb,
lib/relaton/cli/util.rb,
lib/relaton/cli/config.rb,
lib/relaton/cli/command.rb,
lib/relaton/cli/version.rb,
lib/relaton/cli/data_fetcher.rb,
lib/relaton/cli/relaton_file.rb,
lib/relaton/cli/subcommand_db.rb,
lib/relaton/cli/xml_convertor.rb,
lib/relaton/cli/base_convertor.rb,
lib/relaton/cli/yaml_convertor.rb,
lib/relaton/cli/xml_to_html_renderer.rb,
lib/relaton/cli/subcommand_collection.rb

Defined Under Namespace

Modules: Config, DataFetcher, Util Classes: BaseConvertor, Command, Configuration, RelatonDb, RelatonFile, SubcommandCollection, SubcommandDb, XMLConvertor, XmlToHtmlRenderer, YAMLConvertor

Constant Summary collapse

VERSION =
"1.18.0".freeze

Class Method Summary collapse

Class Method Details

.parse_xml(doc) ⇒ RelatonBib::BibliographicItem, RelatonIsoBib::IsoBibliongraphicItem

Parameters:

  • content (Nokogiri::XML::Document)

Returns:

  • (RelatonBib::BibliographicItem, RelatonIsoBib::IsoBibliongraphicItem)


76
77
78
79
80
81
82
# File 'lib/relaton/cli.rb', line 76

def parse_xml(doc)
  if (proc = Cli.processor(doc))
    proc.from_xml(doc.to_s)
  else
    RelatonBib::XMLParser.from_xml(doc.to_s)
  end
end

.processor(doc) ⇒ RelatonIso::Processor, ...

Parameters:

  • doc (Nokogiri::XML::Element)

Returns:

  • (RelatonIso::Processor, RelatonIec::Processor, RelatonNist::Processor, RelatonIetf::Processot, RelatonItu::Processor, RelatonGb::Processor, RelatonOgc::Processor, RelatonCalconnect::Processor)


89
90
91
92
93
94
95
# File 'lib/relaton/cli.rb', line 89

def processor(doc)
  docid = doc.at "docidentifier"
  proc = get_proc docid
  return proc if proc

  Relaton::Registry.instance.by_type(docid&.text&.match(/^\w+/)&.to_s)
end

.relaton(dir) ⇒ Relaton::Db

Relaton

Based on current setup, we need to initiate a Db instance to register all of it’s supported processor backends. To make it easier we have added it as a class method so we can use this whenever necessary.

Parameters:

  • dir (String, nil)

Returns:

  • (Relaton::Db)


69
70
71
# File 'lib/relaton/cli.rb', line 69

def relaton(dir)
  RelatonDb.instance.db dir
end

.start(arguments) ⇒ Object



56
57
58
# File 'lib/relaton/cli.rb', line 56

def start(arguments)
  Relaton::Cli::Command.start(arguments)
end

.versionObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/relaton/cli.rb', line 43

def version
  registry = Relaton::Registry.instance
  puts "CLI => #{Relaton::Cli::VERSION}"
  puts "relaton => #{Relaton::VERSION}"
  puts "relaton-bib => #{RelatonBib::VERSION}"
  puts "relaton-iso-bib => #{RelatonIsoBib::VERSION}"
  registry.processors.each_key do |k|
    klass = "#{k.to_s.split('_').map(&:capitalize).join}::VERSION"
    version = Kernel.const_get(klass)
    puts "#{k.to_s.sub('_', '-')} => #{version}"
  end
end