Module: Relaton::Cli
- Included in:
- Command, SubcommandCollection, SubcommandDb
- Defined in:
- lib/relaton-cli.rb,
lib/relaton/cli.rb,
lib/relaton/cli/util.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: DataFetcher, Util Classes: BaseConvertor, Command, RelatonDb, RelatonFile, SubcommandCollection, SubcommandDb, XMLConvertor, XmlToHtmlRenderer, YAMLConvertor
Constant Summary collapse
- VERSION =
"2.1.3".freeze
Class Method Summary collapse
- .parse_xml(doc) ⇒ RelatonBib::BibliographicItem, RelatonIsoBib::IsoBibliongraphicItem
- .processor(doc) ⇒ RelatonIso::Processor, ...
-
.registry ⇒ Object
The processor registry moved in relaton v3: the top-level Relaton::Registry became Relaton::Db::Registry.
-
.relaton(dir) ⇒ Relaton::Db
Relaton.
- .start(arguments) ⇒ Object
- .version ⇒ Object
Class Method Details
.parse_xml(doc) ⇒ RelatonBib::BibliographicItem, RelatonIsoBib::IsoBibliongraphicItem
84 85 86 87 88 89 90 91 |
# File 'lib/relaton/cli.rb', line 84 def parse_xml(doc) doc.remove_namespaces! if doc.respond_to?(:remove_namespaces!) if (proc = Cli.processor(doc)) proc.from_xml(doc.to_s) else Relaton::Bib::Item.from_xml(doc.to_s) rescue nil end end |
.processor(doc) ⇒ RelatonIso::Processor, ...
98 99 100 101 102 103 104 |
# File 'lib/relaton/cli.rb', line 98 def processor(doc) docid = doc.at "docidentifier" proc = get_proc docid return proc if proc registry.by_type(docid&.text&.match(/^\w+/)&.to_s) end |
.registry ⇒ Object
The processor registry moved in relaton v3: the top-level Relaton::Registry became Relaton::Db::Registry. The v2 line keeps the old constant, so resolve whichever is present.
46 47 48 49 50 |
# File 'lib/relaton/cli.rb', line 46 def registry Relaton::Db::Registry.instance rescue NameError Relaton::Registry.instance 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.
77 78 79 |
# File 'lib/relaton/cli.rb', line 77 def relaton(dir) RelatonDb.instance.db dir end |
.start(arguments) ⇒ Object
64 65 66 |
# File 'lib/relaton/cli.rb', line 64 def start(arguments) Relaton::Cli::Command.start(arguments) end |
.version ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/relaton/cli.rb', line 52 def version require "relaton/bib" registry = registry() puts "CLI => #{Relaton::Cli::VERSION}" puts "relaton => #{Gem.loaded_specs['relaton'].version}" registry.processors.each_key do |k| name = k.to_s.sub("_", "-") spec = Gem.loaded_specs[name] puts "#{name} => #{spec.version}" if spec end end |