Class: RDF::Tabular::Format
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/format.rb
Overview
Tabular Data/CSV format specification.
Class Method Summary collapse
-
.cli_commands ⇒ Hash{Symbol => Lambda(Array, Hash)}
Hash of CLI commands appropriate for this format.
-
.detect(sample) ⇒ Boolean
Sample detection to see if it matches JSON-LD.
Methods inherited from Format
accept_type, accept_types, content_encoding, content_type, content_types, each, file_extension, file_extensions, for, name, reader, reader_symbols, reader_types, require, symbols, to_sym, uri, uris, writer, writer_symbols, writer_types
Class Method Details
.cli_commands ⇒ Hash{Symbol => Lambda(Array, Hash)}
Hash of CLI commands appropriate for this format
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/format.rb', line 53 def self.cli_commands { "tabular-json": { description: "Serialize using tabular JSON", parse: false, filter: {format: :tabular}, # Only shows output format set option_use: {output_format: :disabled}, help: "tabular-json --input-format tabular files ...\nGenerate tabular JSON output, rather than RDF for Tabular data", lambda: ->(argv, opts) do raise ArgumentError, "Outputting Tabular JSON only allowed when input format is tabular." unless opts[:format] == :tabular out = opts[:output] || $stdout out.set_encoding(Encoding::UTF_8) if RUBY_PLATFORM == "java" RDF::CLI.parse(argv, **opts) do |reader| out.puts reader.to_json end end } } end |
.detect(sample) ⇒ Boolean
Sample detection to see if it matches JSON-LD
Use a text sample to detect the format of an input file. Sub-classes implement a matcher sufficient to detect probably format matches, including disambiguating between other similar formats.
46 47 48 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/format.rb', line 46 def self.detect(sample) !!sample.match(/^(?:(?:\w )+,(?:\w ))$/) end |