Skip to content

Commit 52109c1

Browse files
committed
Finish 3.0.5
2 parents 4a7a92d + 65b7a33 commit 52109c1

File tree

6 files changed

+25
-36
lines changed

6 files changed

+25
-36
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ before_install:
77
env:
88
- CI=true
99
rvm:
10-
- 2.2
10+
- 2.2.2
1111
- 2.3
1212
- 2.4
1313
- 2.5

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.4
1+
3.0.5

lib/rdf/vocabulary.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def from_graph(graph, url: nil, class_name: nil, extra: nil)
534534
term_defs.each do |term, attributes|
535535
# Turn embedded BNodes into either their Term definition or a List
536536
attributes.each do |ak, avs|
537-
attributes[ak] = avs.is_a?(Array) ? avs.map do |av|
537+
attributes[ak] = avs.is_a?(Array) ? (avs.map do |av|
538538
l = RDF::List.new(subject: av, graph: graph)
539539
if l.valid?
540540
RDF::List.new(subject: av) do |nl|
@@ -547,7 +547,7 @@ def from_graph(graph, url: nil, class_name: nil, extra: nil)
547547
else
548548
av
549549
end
550-
end.compact : avs
550+
end).compact : avs
551551
end
552552

553553
if term == :""

lib/rdf/writer.rb

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,29 +158,22 @@ class << self
158158
# the graph or repository to dump
159159
# @param [IO, File, String] io
160160
# the output stream or file to write to
161-
# @param [Encoding, String, Symbol] encoding
162-
# the encoding to use on the output stream.
163-
# Defaults to the format associated with `content_encoding`.
164161
# @param [Hash{Symbol => Object}] options
165162
# passed to {RDF::Writer#initialize} or {RDF::Writer.buffer}
166163
# @return [void]
167-
def self.dump(data, io = nil, encoding: nil, **options)
168-
if io.is_a?(String)
169-
io = File.open(io, 'w')
170-
elsif io.respond_to?(:external_encoding) && io.external_encoding
171-
encoding ||= io.external_encoding
172-
end
173-
io.set_encoding(encoding) if io.respond_to?(:set_encoding) && encoding
164+
def self.dump(data, io = nil, **options)
165+
io = File.open(io, 'w') if io.is_a?(String)
174166
method = data.respond_to?(:each_statement) ? :each_statement : :each
175167
if io
176-
new(io, encoding: encoding, **options) do |writer|
168+
new(io, **options) do |writer|
169+
io.set_encoding(writer.encoding) if io.respond_to?(:set_encoding)
177170
data.send(method) do |statement|
178171
writer << statement
179172
end
180173
writer.flush
181174
end
182175
else
183-
buffer(encoding: encoding, **options) do |writer|
176+
buffer(**options) do |writer|
184177
data.send(method) do |statement|
185178
writer << statement
186179
end
@@ -191,23 +184,21 @@ def self.dump(data, io = nil, encoding: nil, **options)
191184
##
192185
# Buffers output into a string buffer.
193186
#
194-
# @param [Encoding, String, Symbol] encoding
195-
# the encoding to use on the output stream.
196-
# Defaults to the format associated with `content_encoding`.
197187
# @param [Hash{Symbol => Object}] options
198188
# passed to {RDF::Writer#initialize}
199189
# @yield [writer]
200190
# @yieldparam [RDF::Writer] writer
201191
# @yieldreturn [void]
202192
# @return [String]
203193
# @raise [ArgumentError] if no block is provided
204-
def self.buffer(*args, encoding: nil, **options, &block)
205-
encoding ||= Encoding::UTF_8 if RUBY_PLATFORM == "java"
194+
def self.buffer(*args, **options, &block)
206195
raise ArgumentError, "block expected" unless block_given?
207196

208197
StringIO.open do |buffer|
209-
buffer.set_encoding(encoding) if encoding
210-
self.new(buffer, *args, encoding: encoding, **options) { |writer| block.call(writer) }
198+
self.new(buffer, *args, **options) do |writer|
199+
buffer.set_encoding(writer.encoding)
200+
block.call(writer)
201+
end
211202
buffer.string
212203
end
213204
end
@@ -216,19 +207,18 @@ def self.buffer(*args, encoding: nil, **options, &block)
216207
# Writes output to the given `filename`.
217208
#
218209
# @param [String, #to_s] filename
219-
# @param [Encoding, String, Symbol] encoding
220-
# the encoding to use on the output stream.
221-
# Defaults to the format associated with `content_encoding`.
222210
# @param [Symbol] format (nil)
223211
# @param [Hash{Symbol => Object}] options
224212
# any additional options (see {RDF::Writer#initialize} and {RDF::Format.for})
225213
# @return [RDF::Writer]
226-
def self.open(filename, encoding: nil, format: nil, **options, &block)
214+
def self.open(filename, format: nil, **options, &block)
227215
File.open(filename, 'wb') do |file|
228-
file.set_encoding(encoding) if encoding
229216
format_options = options.dup
230217
format_options[:file_name] ||= filename
231-
self.for(format || format_options).new(file, encoding: encoding, **options, &block)
218+
self.for(format || format_options).new(file, **options) do |writer|
219+
file.set_encoding(writer.encoding)
220+
block.call(writer)
221+
end
232222
end
233223
end
234224

spec/ntriples_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,6 @@
662662
s = writer.dump(graph, output, encoding: encoding)
663663
expect(output.external_encoding).to eq encoding
664664
end
665-
666-
it "takes encoding from file external_encoding" do
667-
output = StringIO.new
668-
output.set_encoding encoding
669-
s = writer.dump(graph, output)
670-
expect(output.external_encoding).to eq encoding
671-
end
672665
end
673666
end
674667

spec/vocabulary_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
property :Class
261261
property :prop
262262
property :prop2, label: "Test property label", comment: " Test property comment"
263+
property :snake_case
263264
end
264265
end
265266

@@ -272,6 +273,11 @@
272273
.to eq (test_vocab.to_uri / 'aMissingMethod')
273274
end
274275

276+
it "does not camelize if snake-case term found" do
277+
expect(test_vocab.snake_case).to be_a(RDF::Vocabulary::Term)
278+
expect(test_vocab.snake_case).to eq (test_vocab.to_uri / 'snake_case')
279+
end
280+
275281
it "should respond to [] with properties that have been defined" do
276282
expect(test_vocab[:prop]).to be_a(RDF::URI)
277283
expect(test_vocab["prop2"]).to be_a(RDF::URI)

0 commit comments

Comments
 (0)