rdf 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/vocabulary.rb +2 -2
- data/lib/rdf/writer.rb +15 -25
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bea45795551315414671bb114872e5cac5162e1ec2a27e05a9d4879120ab134
|
4
|
+
data.tar.gz: a992b86dca4f494960654e4fc9435d7ed2ebaae59a4dd51c73c98213c36f8468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 827ef18bb7e6f5f299ce5ba7e570012e03a391b1b025a915b2ea0d3faa9bb42446393dddb41d015dade8889395c11b7413c9134af14d88c28c8caa15eca0c3c7
|
7
|
+
data.tar.gz: 9c2109b329d2ea4e5417c4c86f026c49a039055a2151ba24963f920b70a6dfbf64417088fda6477aa5ce849bb692de1962f1dd9cdf6287c913623d966bffc26f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.5
|
data/lib/rdf/vocabulary.rb
CHANGED
@@ -534,7 +534,7 @@ module RDF
|
|
534
534
|
term_defs.each do |term, attributes|
|
535
535
|
# Turn embedded BNodes into either their Term definition or a List
|
536
536
|
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|
|
538
538
|
l = RDF::List.new(subject: av, graph: graph)
|
539
539
|
if l.valid?
|
540
540
|
RDF::List.new(subject: av) do |nl|
|
@@ -547,7 +547,7 @@ module RDF
|
|
547
547
|
else
|
548
548
|
av
|
549
549
|
end
|
550
|
-
end.compact : avs
|
550
|
+
end).compact : avs
|
551
551
|
end
|
552
552
|
|
553
553
|
if term == :""
|
data/lib/rdf/writer.rb
CHANGED
@@ -158,29 +158,22 @@ module RDF
|
|
158
158
|
# the graph or repository to dump
|
159
159
|
# @param [IO, File, String] io
|
160
160
|
# 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`.
|
164
161
|
# @param [Hash{Symbol => Object}] options
|
165
162
|
# passed to {RDF::Writer#initialize} or {RDF::Writer.buffer}
|
166
163
|
# @return [void]
|
167
|
-
def self.dump(data, io = nil,
|
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)
|
174
166
|
method = data.respond_to?(:each_statement) ? :each_statement : :each
|
175
167
|
if io
|
176
|
-
new(io,
|
168
|
+
new(io, **options) do |writer|
|
169
|
+
io.set_encoding(writer.encoding) if io.respond_to?(:set_encoding)
|
177
170
|
data.send(method) do |statement|
|
178
171
|
writer << statement
|
179
172
|
end
|
180
173
|
writer.flush
|
181
174
|
end
|
182
175
|
else
|
183
|
-
buffer(
|
176
|
+
buffer(**options) do |writer|
|
184
177
|
data.send(method) do |statement|
|
185
178
|
writer << statement
|
186
179
|
end
|
@@ -191,9 +184,6 @@ module RDF
|
|
191
184
|
##
|
192
185
|
# Buffers output into a string buffer.
|
193
186
|
#
|
194
|
-
# @param [Encoding, String, Symbol] encoding
|
195
|
-
# the encoding to use on the output stream.
|
196
|
-
# Defaults to the format associated with `content_encoding`.
|
197
187
|
# @param [Hash{Symbol => Object}] options
|
198
188
|
# passed to {RDF::Writer#initialize}
|
199
189
|
# @yield [writer]
|
@@ -201,13 +191,14 @@ module RDF
|
|
201
191
|
# @yieldreturn [void]
|
202
192
|
# @return [String]
|
203
193
|
# @raise [ArgumentError] if no block is provided
|
204
|
-
def self.buffer(*args,
|
205
|
-
encoding ||= Encoding::UTF_8 if RUBY_PLATFORM == "java"
|
194
|
+
def self.buffer(*args, **options, &block)
|
206
195
|
raise ArgumentError, "block expected" unless block_given?
|
207
196
|
|
208
197
|
StringIO.open do |buffer|
|
209
|
-
|
210
|
-
|
198
|
+
self.new(buffer, *args, **options) do |writer|
|
199
|
+
buffer.set_encoding(writer.encoding)
|
200
|
+
block.call(writer)
|
201
|
+
end
|
211
202
|
buffer.string
|
212
203
|
end
|
213
204
|
end
|
@@ -216,19 +207,18 @@ module RDF
|
|
216
207
|
# Writes output to the given `filename`.
|
217
208
|
#
|
218
209
|
# @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`.
|
222
210
|
# @param [Symbol] format (nil)
|
223
211
|
# @param [Hash{Symbol => Object}] options
|
224
212
|
# any additional options (see {RDF::Writer#initialize} and {RDF::Format.for})
|
225
213
|
# @return [RDF::Writer]
|
226
|
-
def self.open(filename,
|
214
|
+
def self.open(filename, format: nil, **options, &block)
|
227
215
|
File.open(filename, 'wb') do |file|
|
228
|
-
file.set_encoding(encoding) if encoding
|
229
216
|
format_options = options.dup
|
230
217
|
format_options[:file_name] ||= filename
|
231
|
-
self.for(format || format_options).new(file,
|
218
|
+
self.for(format || format_options).new(file, **options) do |writer|
|
219
|
+
file.set_encoding(writer.encoding)
|
220
|
+
block.call(writer)
|
221
|
+
end
|
232
222
|
end
|
233
223
|
end
|
234
224
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
298
|
version: '0'
|
299
299
|
requirements: []
|
300
300
|
rubyforge_project:
|
301
|
-
rubygems_version: 2.7.
|
301
|
+
rubygems_version: 2.7.7
|
302
302
|
signing_key:
|
303
303
|
specification_version: 4
|
304
304
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|