Class: RDF::N3::Format

Inherits:
Format
  • Object
show all
Defined in:
lib/rdf/n3/format.rb

Overview

RDFa format specification.

Examples:

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")

Obtaining serialization format MIME types

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

Obtaining serialization format file extension mappings

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

See Also:

Class Method Summary collapse

Class Method Details

.cli_commandsHash{Symbol => Hash}

Hash of CLI commands appropriate for this format

Returns:

  • (Hash{Symbol => Hash})


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# 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

.symbolsObject

Symbols which may be used to lookup this format



30
31
32
# File 'lib/rdf/n3/format.rb', line 30

def self.symbols
  [:n3, :notation3]
end