class RDF::N3::Format

RDFa format specification.

@example Obtaining an Notation3 format class

RDF::Format.for(:n3)            #=> RDF::N3::Format
RDF::Format.for("etc/foaf.n3")
RDF::Format.for(file_name:      "etc/foaf.n3")
RDF::Format.for(file_extension: "n3")
RDF::Format.for(content_type:   "text/n3")

@example Obtaining serialization format MIME types

RDF::Format.content_types      #=> {"text/n3")" => [RDF::N3::Format]}

@example Obtaining serialization format file extension mappings

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

@see www.w3.org/TR/rdf-testcases/#ntriples

Public Class Methods

cli_commands() click to toggle source

Hash of CLI commands appropriate for this format @return [Hash{Symbol => Hash}]

# File lib/rdf/n3/format.rb, line 37
def self.cli_commands
  {
    reason: {
      description: "Reason over formulae.",
      help: "reason [--think] file\nPerform Notation-3 reasoning.",
      parse: false,
      # Only shows when input and output format set
      filter: {format: :n3},  
      repository: RDF::N3::Repository.new,
      lambda: ->(argv, **options) do
        repository = options[:repository]
        result_repo = RDF::N3::Repository.new
        RDF::CLI.parse(argv, format: :n3, list_terms: true, **options) do |reader|
          reasoner = RDF::N3::Reasoner.new(reader, **options)
          reasoner.reason!(**options)
          if options[:conclusions]
            result_repo << reasoner.conclusions
          elsif options[:data]
            result_repo << reasoner.data
          else
            result_repo << reasoner
          end
        end

        # Replace input repository with results
        repository.clear!
        repository << result_repo
      end,
      options: [
        RDF::CLI::Option.new(
          symbol: :conclusions,
          datatype: TrueClass,
          control: :checkbox,
          use: :optional,
          on: ["--conclusions"],
          description: "Exclude formulae and statements in the original dataset."),
        RDF::CLI::Option.new(
          symbol: :data,
          datatype: TrueClass,
          control: :checkbox,
          use: :optional,
          on: ["--data"],
          description: "Only results from default graph, excluding formulae or variables."),
        RDF::CLI::Option.new(
          symbol: :strings,
          datatype: TrueClass,
          control: :checkbox,
          use: :optional,
          on: ["--strings"],
          description: "Returns the concatenated strings from log:outputString."),
        RDF::CLI::Option.new(
          symbol: :think,
          datatype: TrueClass,
          control: :checkbox,
          use: :optional,
          on: ["--think"],
          description: "Continuously execute until results stop growing."),
      ]
    },
  }
end
symbols() click to toggle source

Symbols which may be used to lookup this format

# File lib/rdf/n3/format.rb, line 30
def self.symbols
  [:n3, :notation3]
end