Skip to content

Commit a44b432

Browse files
committed
allow --no-validate CLI option.
1 parent 76d6a0f commit a44b432

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

lib/rdf/reader.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def self.options
168168
symbol: :validate,
169169
datatype: TrueClass,
170170
control: :checkbox,
171-
on: ["--validate"],
172-
description: "Validate input file."),
171+
on: ["--[no-]validate"],
172+
description: "Validate on input and output."),
173173
RDF::CLI::Option.new(
174174
symbol: :verifySSL,
175175
datatype: TrueClass,
@@ -181,7 +181,7 @@ def self.options
181181
symbol: :version,
182182
control: :select,
183183
datatype: RDF::Format::VERSIONS, # 1.1, 1.2, or 1.2-basic
184-
on: ["--version"],
184+
on: ["--version VERSION"],
185185
description: "RDF Version."),
186186
]
187187
end
@@ -290,7 +290,7 @@ def to_sym
290290
# any additional options
291291
# @param [Boolean] validate (false)
292292
# whether to validate the parsed statements and values
293-
# @option options [String] :version ("1.2")
293+
# @option options [String] :version
294294
# Parse a specific version of RDF ("1.1', "1.2", or "1.2-basic"")
295295
# @yield [reader] `self`
296296
# @yieldparam [RDF::Reader] reader
@@ -320,6 +320,10 @@ def initialize(input = $stdin,
320320
# The rdfstar option implies version 1.2, but can be overridden
321321
@options[:version] ||= "1.2" if @options[:rdfstar]
322322

323+
unless self.version.nil? || RDF::Format::VERSIONS.include?(self.version)
324+
log_error("Expected version to be one of #{RDF::Format::VERSIONS.join(', ')}, was #{self.version}")
325+
end
326+
323327
@input = case input
324328
when String then StringIO.new(input)
325329
else input
@@ -406,10 +410,10 @@ def prefix(name, uri = nil)
406410
# Returns the RDF version determined by this reader.
407411
#
408412
# @example
409-
# reader.version #=> RDF::URI('http://purl.org/dc/terms/')
413+
# reader.version #=> "1.2"
410414
#
411415
# @return [String]
412-
# @since 3.3.2
416+
# @since 3.3.4
413417
def version
414418
@options[:version]
415419
end

rdf.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Gem::Specification.new do |gem|
3434
gem.add_runtime_dependency 'link_header', '~> 0.0', '>= 0.0.8'
3535
gem.add_runtime_dependency 'logger', '~> 1.5'
3636
gem.add_runtime_dependency 'ostruct', '~> 0.6'
37+
gem.add_runtime_dependency 'readline', '~> 0.0'
3738
gem.add_development_dependency 'base64', '~> 0.2'
3839
gem.add_development_dependency 'rdf-spec', '~> 3.3'
3940
gem.add_development_dependency 'rdf-turtle', '~> 3.3'

0 commit comments

Comments
 (0)