Module: Relaton::Cli

Defined in:
lib/relaton-cli.rb,
lib/relaton/cli.rb,
lib/relaton/cli/command.rb,
lib/relaton/cli/version.rb,
lib/relaton/cli/relaton_file.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

Defined Under Namespace

Classes: BaseConvertor, Command, RelatonDb, RelatonFile, XMLConvertor, XmlToHtmlRenderer, YAMLConvertor

Constant Summary collapse

VERSION =
"1.1.1".freeze

Class Method Summary collapse

Class Method Details

.doctype(doc) ⇒ String

Returns Type prefix.

Parameters:

  • content (Nokogiri::XML::Document)

    Document

Returns:

  • (String)

    Type prefix



46
47
48
49
50
51
# File 'lib/relaton/cli.rb', line 46

def self.doctype(doc)
  docid = doc.at "docidentifier"
  return docid[:type] if docid && docid[:type]

  docid&.text&.match(/^\w+/)&.to_s
end

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

Parameters:

  • content (Nokogiri::XML::Document)

Returns:

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


36
37
38
39
40
41
42
# File 'lib/relaton/cli.rb', line 36

def self.parse_xml(doc)
  if (processor = Relaton::Registry.instance.by_type(Relaton::Cli.doctype(doc)))
    processor.from_xml(doc.to_s)
  else
    RelatonBib::XMLParser.from_xml(doc.to_s)
  end
end

.relatonObject

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.



30
31
32
# File 'lib/relaton/cli.rb', line 30

def self.relaton
  RelatonDb.instance.db
end

.start(arguments) ⇒ Object



19
20
21
# File 'lib/relaton/cli.rb', line 19

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