Skip to content

Commit 8b53522

Browse files
committed
Add Reader and Writer options.
1 parent 7b1f952 commit 8b53522

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/json/ld/reader.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ module JSON::LD
77
class Reader < RDF::Reader
88
format Format
99

10+
##
11+
# JSON-LD Reader options
12+
# @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Reader#options-class_method
13+
def self.options
14+
super + [
15+
RDF::CLI::Option.new(
16+
symbol: :compactArrays,
17+
datatype: TrueClass,
18+
on: ["--compact-arrays"],
19+
description: "Replaces arrays with just one element with that element during compaction.") {true},
20+
]
21+
end
22+
1023
##
1124
# Initializes the RDF/JSON reader instance.
1225
#

lib/json/ld/writer.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,39 @@ class Writer < RDF::Writer
6565
# @return [Context] context used to load and administer contexts
6666
attr_reader :context
6767

68+
##
69+
# JSON-LD Writer options
70+
# @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Writer#options-class_method
71+
def self.options
72+
super + [
73+
RDF::CLI::Option.new(
74+
symbol: :compactArrays,
75+
datatype: TrueClass,
76+
on: ["--compact-arrays"],
77+
description: "Replaces arrays with just one element with that element during compaction.") {true},
78+
RDF::CLI::Option.new(
79+
symbol: :context,
80+
datatype: RDF::URI,
81+
on: ["--context CONTEXT"],
82+
description: "Context to use when serializing. Constructed context for native serialization.") {|arg| RDF::URI(arg)},
83+
RDF::CLI::Option.new(
84+
symbol: :frame,
85+
datatype: RDF::URI,
86+
on: ["--frame FRAME"],
87+
description: "Frame to use when serializing.") {|arg| RDF::URI(arg)},
88+
RDF::CLI::Option.new(
89+
symbol: :stream,
90+
datatype: TrueClass,
91+
on: ["--stream"],
92+
description: "Do not attempt to optimize graph presentation, suitable for streaming large graphs.") {true},
93+
RDF::CLI::Option.new(
94+
symbol: :useRdfType,
95+
datatype: TrueClass,
96+
on: ["--use-rdf-type"],
97+
description: "Treat `rdf:type` like a normal property instead of using `@type`.") {true},
98+
]
99+
end
100+
68101
##
69102
# Initializes the RDF-LD writer instance.
70103
#

0 commit comments

Comments
 (0)