Class: YARSPG::Format

Inherits:
RDF::Format
  • Object
show all
Defined in:
lib/yarspg/format.rb

Overview

YARS-PG format specification.

Examples:

Obtaining an ## format class

RDF::Format.for("etc/foaf.yarspg")
RDF::Format.for(file_name:      "etc/foaf.yarspg")
RDF::Format.for(file_extension: "yarspg")
RDF::Format.for(content_type:   "text/yarspg")

Obtaining serialization format MIME types

RDF::Format.content_types      #=> {"text/yarspg" => [YARSPG::Format]}

Obtaining serialization format file extension mappings

RDF::Format.file_extensions    #=> {yarspg: "text/yarspg"}

See Also:

Class Method Summary collapse

Class Method Details

.detect(sample) ⇒ Boolean

Sample detection to see if it matches YARS-PG

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.

Parameters:

  • sample (String)

    Beginning several bytes (~ 1K) of input.

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
# File 'lib/yarspg/format.rb', line 33

def self.detect(sample)
  !!sample.match(%r(
    (?:%(METADATA|NODE SCHEMAS|EDGE SCHEMAS|NODES|EDGES)) | # Section Names
    (?:[S\{.*\}]-)                                        | # Node Schema
    (?:[S\(.*\)]-)                                        | # Edge Schema
    (?:\(.*\)-)                                             # Edge
  )mx)
end