Skip to content

Commit 6c95212

Browse files
committed
Update Reader.each and Writer.each to depend on Format, not instantialed subclasses, as these may have not been loaded when called.
1 parent 337c836 commit 6c95212

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/rdf/reader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Reader
5050
# @yieldparam [Class] klass
5151
# @return [Enumerator]
5252
def self.each(&block)
53-
@@subclasses.each(&block)
53+
RDF::Format.map(&:reader).reject(&:nil?).each(&block)
5454
end
5555

5656
##
@@ -195,7 +195,7 @@ def self.open(filename, format: nil, **options, &block)
195195
if reader
196196
reader.new(file, options, &block)
197197
else
198-
raise FormatError, "unknown RDF format: #{format_options.inspect}\nThis may be resolved with a require of the 'linkeddata' gem."
198+
raise FormatError, "unknown RDF format: #{format_options.inspect}" + ("\nThis may be resolved with a require of the 'linkeddata' gem." unless Object.const_defined?(:LinkedData))
199199
end
200200
end
201201
end

lib/rdf/writer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Writer
6161
# @yieldreturn [void] ignored
6262
# @return [Enumerator]
6363
def self.each(&block)
64-
@@subclasses.each(&block)
64+
RDF::Format.map(&:writer).reject(&:nil?).each(&block)
6565
end
6666

6767
##

spec/vocabulary_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
VOCABS = %w(owl rdf rdfs xsd)
55
STRICT_VOCABS = %w(owl rdf rdfs)
66

7-
context "#new" do
7+
context "#initialize" do
88
it "should require one argument" do
99
expect { RDF::Vocabulary.new }.to raise_error(ArgumentError)
1010
expect { RDF::Vocabulary.new("http://example.org/") }.not_to raise_error
@@ -34,7 +34,7 @@
3434
end
3535
end
3636

37-
describe "#each" do
37+
describe ".each" do
3838
it "inumerates pre-defined vocabularies" do
3939
expect {|b| RDF::Vocabulary.each(&b)}.to yield_control.at_least(3).times
4040
expect(RDF::Vocabulary.each.to_a).to include(RDF, RDF::RDFS, RDF::OWL)

0 commit comments

Comments
 (0)