rdf 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/VERSION +1 -1
- data/lib/rdf/mixin/enumerable.rb +7 -7
- data/lib/rdf/model/literal/boolean.rb +1 -1
- data/lib/rdf/model/literal/double.rb +3 -3
- data/lib/rdf/reader.rb +25 -6
- data/lib/rdf/util/file.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5b0c02b8e9058e426f16a534e9a9f67b0ddab07
|
4
|
+
data.tar.gz: a68b6870879a0eec41e12047561334f7c1173d39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac36cd538bb75de037dc179f6125e424c701e50667936ee62ef75426f316f53de83b0a56fe464648450445dbaf31ab52b7e91ce8ad7aeb75e7d71840de206fba
|
7
|
+
data.tar.gz: 35ab589fcf5f331c29518f7928fd1bde329c4ba65b67c31e05ef219f2c4ff998e79610a883bfb6d9409b7190fd196807f82527aa5d9f9652391386249a60fba5
|
data/README.md
CHANGED
@@ -84,7 +84,10 @@ operations on RDF files using available readers and writers.
|
|
84
84
|
* `serialize`: Parse an RDF input and re-serializing to [N-Triples][] or another available format using `--output-format` option.
|
85
85
|
* `subjects`: Returns unique subjects from parsed input.
|
86
86
|
|
87
|
-
The `serialize` command can also be used to serialize as a vocabulary
|
87
|
+
The `serialize` command can also be used to serialize as a vocabulary.
|
88
|
+
|
89
|
+
Different RDF gems will augment the `rdf` script with more capabilities, which may require specifying the appropriate `--input-format` option to revel.
|
90
|
+
|
88
91
|
## Examples
|
89
92
|
|
90
93
|
require 'rdf'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.4
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
@@ -122,7 +122,7 @@ module RDF
|
|
122
122
|
# @see #each_statement
|
123
123
|
# @see #enum_statement
|
124
124
|
def statements(**options)
|
125
|
-
|
125
|
+
enum_statement.to_a
|
126
126
|
end
|
127
127
|
|
128
128
|
##
|
@@ -311,7 +311,7 @@ module RDF
|
|
311
311
|
unless unique
|
312
312
|
enum_statement.map(&:subject) # TODO: optimize
|
313
313
|
else
|
314
|
-
|
314
|
+
enum_subject.to_a
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
@@ -376,7 +376,7 @@ module RDF
|
|
376
376
|
unless unique
|
377
377
|
enum_statement.map(&:predicate) # TODO: optimize
|
378
378
|
else
|
379
|
-
|
379
|
+
enum_predicate.to_a
|
380
380
|
end
|
381
381
|
end
|
382
382
|
|
@@ -441,7 +441,7 @@ module RDF
|
|
441
441
|
unless unique
|
442
442
|
enum_statement.map(&:object) # TODO: optimize
|
443
443
|
else
|
444
|
-
|
444
|
+
enum_object.to_a
|
445
445
|
end
|
446
446
|
end
|
447
447
|
|
@@ -514,7 +514,7 @@ module RDF
|
|
514
514
|
flatten.
|
515
515
|
compact
|
516
516
|
else
|
517
|
-
|
517
|
+
enum_term.to_a
|
518
518
|
end
|
519
519
|
end
|
520
520
|
|
@@ -759,7 +759,7 @@ module RDF
|
|
759
759
|
# @overload #to_writer
|
760
760
|
# Implements #to_writer for each available instance of {RDF::Writer},
|
761
761
|
# based on the writer symbol.
|
762
|
-
#
|
762
|
+
#
|
763
763
|
# @return [String]
|
764
764
|
# @see {RDF::Writer.sym}
|
765
765
|
def method_missing(meth, *args)
|
@@ -780,7 +780,7 @@ module RDF
|
|
780
780
|
end
|
781
781
|
|
782
782
|
##
|
783
|
-
# @note this instantiates an writer; it could probably be done more
|
783
|
+
# @note this instantiates an writer; it could probably be done more
|
784
784
|
# efficiently by refactoring `RDF::Reader` and/or `RDF::Format` to expose
|
785
785
|
# a list of valid format symbols.
|
786
786
|
def respond_to_missing?(name, include_private = false)
|
@@ -12,7 +12,7 @@ module RDF; class Literal
|
|
12
12
|
# @since 0.2.1
|
13
13
|
class Double < Numeric
|
14
14
|
DATATYPE = RDF::XSD.double
|
15
|
-
GRAMMAR = /^(?:NaN|
|
15
|
+
GRAMMAR = /^(?:NaN|\-?INF|[+\-]?(?:\d+(:?\.\d*)?|\.\d+)(?:[eE][\+\-]?\d+)?)$/.freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# @param [String, Float, #to_f] value
|
@@ -21,11 +21,11 @@ module RDF; class Literal
|
|
21
21
|
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
|
22
22
|
@string = lexical || (value if value.is_a?(String))
|
23
23
|
@object = case
|
24
|
-
when value.is_a?(::String) then case value
|
24
|
+
when value.is_a?(::String) then case value.upcase
|
25
25
|
when '+INF' then 1/0.0
|
26
26
|
when 'INF' then 1/0.0
|
27
27
|
when '-INF' then -1/0.0
|
28
|
-
when '
|
28
|
+
when 'NAN' then 0/0.0
|
29
29
|
else Float(value.sub(/\.[eE]/, '.0E')) rescue nil
|
30
30
|
end
|
31
31
|
when value.is_a?(::Float) then value
|
data/lib/rdf/reader.rb
CHANGED
@@ -180,18 +180,37 @@ module RDF
|
|
180
180
|
# @yieldreturn [void] ignored
|
181
181
|
# @raise [RDF::FormatError] if no reader found for the specified format
|
182
182
|
def self.open(filename, format: nil, **options, &block)
|
183
|
+
# If we're the abstract reader, and we can figure out a concrete reader from format and options, use that.
|
184
|
+
if self == RDF::Reader && reader = self.for(format || {file_name: filename}.merge(options))
|
185
|
+
return reader.open(filename, format: format, **options, &block)
|
186
|
+
end
|
187
|
+
|
188
|
+
# If we are a concrete reader class or format is not nil, set accept header from our content_types.
|
189
|
+
unless self == RDF::Reader
|
190
|
+
headers = (options[:headers] ||= {})
|
191
|
+
headers['Accept'] ||= (self.format.accept_type + %w(*/*;q=0.1)).join(", ")
|
192
|
+
end
|
193
|
+
|
183
194
|
Util::File.open_file(filename, options) do |file|
|
184
195
|
format_options = options.dup
|
185
196
|
format_options[:content_type] ||= file.content_type if file.respond_to?(:content_type)
|
186
197
|
format_options[:file_name] ||= filename
|
198
|
+
reader = if self == RDF::Reader
|
199
|
+
# We are the abstract reader class, find an appropriate reader
|
200
|
+
self.for(format || format_options) do
|
201
|
+
# Return a sample from the input file
|
202
|
+
sample = file.read(1000)
|
203
|
+
file.rewind
|
204
|
+
sample
|
205
|
+
end
|
206
|
+
else
|
207
|
+
# We are a concrete reader class
|
208
|
+
self
|
209
|
+
end
|
210
|
+
|
187
211
|
options[:encoding] ||= file.encoding if file.respond_to?(:encoding)
|
188
212
|
options[:filename] ||= filename
|
189
|
-
|
190
|
-
# Return a sample from the input file
|
191
|
-
sample = file.read(1000)
|
192
|
-
file.rewind
|
193
|
-
sample
|
194
|
-
end
|
213
|
+
|
195
214
|
if reader
|
196
215
|
reader.new(file, options, &block)
|
197
216
|
else
|
data/lib/rdf/util/file.rb
CHANGED
@@ -305,7 +305,7 @@ module RDF; module Util
|
|
305
305
|
content_type = format ? format.content_type.first : 'text/plain'
|
306
306
|
# Open as a file, passing any options
|
307
307
|
begin
|
308
|
-
url_no_frag_or_query = RDF::URI(filename_or_url)
|
308
|
+
url_no_frag_or_query = RDF::URI(filename_or_url).dup
|
309
309
|
url_no_frag_or_query.query = nil
|
310
310
|
url_no_frag_or_query.fragment = nil
|
311
311
|
options[:encoding] ||= Encoding::UTF_8
|
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: 2.2.
|
4
|
+
version: 2.2.4
|
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: 2017-
|
13
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|