Class: Glossarist::CLI::ExportCommand
- Inherits:
-
Object
- Object
- Glossarist::CLI::ExportCommand
- Defined in:
- lib/glossarist/cli/export_command.rb
Constant Summary collapse
- EXTENSIONS =
{ "json" => "json", "jsonld" => "jsonld", "turtle" => "ttl", "tbx" => "tbx.xml", "jsonl" => "jsonl", }.freeze
Instance Method Summary collapse
-
#initialize(path, options) ⇒ ExportCommand
constructor
A new instance of ExportCommand.
- #run ⇒ Object
Constructor Details
#initialize(path, options) ⇒ ExportCommand
Returns a new instance of ExportCommand.
14 15 16 17 |
# File 'lib/glossarist/cli/export_command.rb', line 14 def initialize(path, ) @path = path @options = end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/glossarist/cli/export_command.rb', line 19 def run format = @options[:format] output_dir = File.(@options[:output]) FileUtils.mkdir_p(output_dir) concepts = load_concepts name = resolve_shortname(concepts) case format when "json" then export_json(concepts, output_dir) when "jsonld" then export_document(concepts, name, output_dir, :jsonld) when "turtle" then export_document(concepts, name, output_dir, :turtle) when "tbx" then export_tbx(concepts, name, output_dir) when "jsonl" then export_jsonl(concepts, name, output_dir) end rescue ArgumentError => e warn "Error: #{e.}" exit 1 end |