Module: Relaton::Cli
- Defined in:
- 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_convertor_new.rb,
lib/relaton/cli/yaml_convertor_new.rb,
lib/relaton/cli/xml_to_html_renderer.rb
Defined Under Namespace
Classes: BaseConvertor, Command, RelatonFile, XMLConvertor, XMLConvertorNew, XmlToHtmlRenderer, YAMLConvertor, YAMLConvertorNew
Constant Summary collapse
- VERSION =
"0.3.16".freeze
Class Method Summary collapse
-
.doctype(doc) ⇒ String
Type prefix.
- .parse_xml(doc) ⇒ RelatonBib::BibliographicItem, RelatonIsoBib::IsoBibliongraphicItem
-
.relaton ⇒ Object
Relaton.
- .start(arguments) ⇒ Object
Class Method Details
.doctype(doc) ⇒ String
Returns Type prefix.
35 36 37 38 39 40 |
# File 'lib/relaton/cli.rb', line 35 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
25 26 27 28 29 30 31 |
# File 'lib/relaton/cli.rb', line 25 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 |
.relaton ⇒ Object
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.
19 20 21 |
# File 'lib/relaton/cli.rb', line 19 def self.relaton @relaton ||= Relaton::Db.new("#{Dir.home}/.relaton/cache", nil) end |
.start(arguments) ⇒ Object
8 9 10 |
# File 'lib/relaton/cli.rb', line 8 def self.start(arguments) Relaton::Cli::Command.start(arguments) end |