Class: RDF::Turtle::Format
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-turtle-6506e92ccd8e/lib/rdf/turtle/format.rb
Overview
Turtle format specification.
Class Method Summary collapse
-
.detect(sample) ⇒ Boolean
Sample detection to see if it matches Turtle (or N-Triples).
-
.symbols ⇒ Object
List of symbols used to lookup this format.
Methods inherited from Format
accept_type, accept_types, cli_commands, content_encoding, content_type, content_types, each, file_extension, file_extensions, for, name, reader, reader_symbols, reader_types, require, to_sym, uri, uris, writer, writer_symbols, writer_types
Class Method Details
.detect(sample) ⇒ Boolean
Sample detection to see if it matches Turtle (or N-Triples)
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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-turtle-6506e92ccd8e/lib/rdf/turtle/format.rb', line 41 def self.detect(sample) !!sample.match(%r( (?:@(base|prefix)) | # Turtle keywords ["']{3} | # STRING_LITERAL_LONG_SINGLE_QUOTE/2 "[^"]*"^^ | "[^"]*"@ | # Typed/Language literals (?: (?:\s*(?:(?:<[^>]*>) | (?:\w*:\w+) | (?:"[^"]*"))\s*[,;]) || (?:\s*(?:(?:<[^>]*>) | (?:\w*:\w+) | (?:"[^"]*"))){3} ) )mx) && !( sample.match(%r([{}])) || # TriG sample.match(%r(@keywords|=>|\{)) || # N3 sample.match(%r(<(?:\/|html|rdf))i) || # HTML, RDF/XML sample.match(%r(^(?:\s*<[^>]*>){4}.*\.\s*$)) || # N-Quads sample.match(%r("@(context|subject|iri)")) # JSON-LD ) end |
.symbols ⇒ Object
List of symbols used to lookup this format
60 61 62 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-turtle-6506e92ccd8e/lib/rdf/turtle/format.rb', line 60 def self.symbols [:turtle, :ttl] end |