rdf 2.1.1 → 2.2.0.pre.rc1
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.rb +2 -2
- data/lib/rdf/changeset.rb +2 -2
- data/lib/rdf/cli.rb +18 -12
- data/lib/rdf/format.rb +1 -1
- data/lib/rdf/mixin/enumerable.rb +22 -7
- data/lib/rdf/mixin/enumerator.rb +40 -4
- data/lib/rdf/mixin/queryable.rb +3 -3
- data/lib/rdf/model/dataset.rb +1 -1
- data/lib/rdf/model/graph.rb +4 -4
- data/lib/rdf/model/literal.rb +42 -20
- data/lib/rdf/model/literal/boolean.rb +5 -6
- data/lib/rdf/model/literal/date.rb +5 -6
- data/lib/rdf/model/literal/datetime.rb +3 -4
- data/lib/rdf/model/literal/decimal.rb +12 -8
- data/lib/rdf/model/literal/double.rb +5 -6
- data/lib/rdf/model/literal/integer.rb +6 -7
- data/lib/rdf/model/literal/time.rb +5 -6
- data/lib/rdf/model/literal/token.rb +6 -7
- data/lib/rdf/model/node.rb +1 -1
- data/lib/rdf/model/statement.rb +43 -15
- data/lib/rdf/model/uri.rb +23 -5
- data/lib/rdf/nquads.rb +2 -2
- data/lib/rdf/ntriples/reader.rb +13 -10
- data/lib/rdf/ntriples/writer.rb +18 -19
- data/lib/rdf/query.rb +33 -30
- data/lib/rdf/query/hash_pattern_normalizer.rb +2 -2
- data/lib/rdf/query/pattern.rb +5 -4
- data/lib/rdf/query/solution.rb +25 -13
- data/lib/rdf/query/variable.rb +20 -2
- data/lib/rdf/reader.rb +33 -22
- data/lib/rdf/repository.rb +2 -2
- data/lib/rdf/transaction.rb +1 -1
- data/lib/rdf/util/file.rb +34 -41
- data/lib/rdf/util/logger.rb +36 -36
- data/lib/rdf/util/uuid.rb +3 -2
- data/lib/rdf/vocab/writer.rb +4 -4
- data/lib/rdf/vocabulary.rb +10 -12
- data/lib/rdf/writer.rb +32 -22
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 021b280777d430a6b79691be567737b25ca3dbb1
|
4
|
+
data.tar.gz: aaa41238c2b7fa38dcc80b760bb14dbed315c906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80781fd13019493a907988216a762d910568965b8aa352fc3a1674e752b0d30cf67ebfd428d7d3c9cec3212d44dd269e83e54783e3724ef20bb4bf5231677155
|
7
|
+
data.tar.gz: 915f78c9eb8d23b796bc6c7ba2f60b03c3fd09efc8544bff972bdb0c61de29913df3010f995218396459433299824f3737d96d879f8640e4db5cdb1e2a4ec183
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0-rc1
|
data/lib/rdf.rb
CHANGED
@@ -156,7 +156,7 @@ module RDF
|
|
156
156
|
# @overload Statement()
|
157
157
|
# @return [RDF::URI] returns the IRI for `rdf:Statement`
|
158
158
|
#
|
159
|
-
# @overload Statement(options
|
159
|
+
# @overload Statement(**options)
|
160
160
|
# @param [Hash{Symbol => Object}] options
|
161
161
|
# @option options [RDF::Resource] :subject (nil)
|
162
162
|
# @option options [RDF::URI] :predicate (nil)
|
@@ -165,7 +165,7 @@ module RDF
|
|
165
165
|
# Note, a graph_name MUST be an IRI or BNode.
|
166
166
|
# @return [RDF::Statement]
|
167
167
|
#
|
168
|
-
# @overload Statement(subject, predicate, object, options
|
168
|
+
# @overload Statement(subject, predicate, object, **options)
|
169
169
|
# @param [RDF::Resource] subject
|
170
170
|
# @param [RDF::URI] predicate
|
171
171
|
# @param [RDF::Term] object
|
data/lib/rdf/changeset.rb
CHANGED
@@ -41,7 +41,7 @@ module RDF
|
|
41
41
|
# @yield [changes]
|
42
42
|
# @yieldparam [RDF::Changeset] changes
|
43
43
|
# @return [void]
|
44
|
-
def self.apply(mutable, options
|
44
|
+
def self.apply(mutable, **options, &block)
|
45
45
|
self.new(&block).apply(mutable, options)
|
46
46
|
end
|
47
47
|
|
@@ -106,7 +106,7 @@ module RDF
|
|
106
106
|
# @param [RDF::Mutable] mutable
|
107
107
|
# @param [Hash{Symbol => Object}] options
|
108
108
|
# @return [void]
|
109
|
-
def apply(mutable, options
|
109
|
+
def apply(mutable, **options)
|
110
110
|
mutable.apply_changeset(self)
|
111
111
|
end
|
112
112
|
|
data/lib/rdf/cli.rb
CHANGED
@@ -338,23 +338,24 @@ module RDF
|
|
338
338
|
# Execute one or more commands, parsing input as necessary
|
339
339
|
#
|
340
340
|
# @param [Array<String>] args
|
341
|
+
# @param [IO] output
|
342
|
+
# @param [Hash{Symbol => Object}] options
|
341
343
|
# @return [Boolean]
|
342
|
-
def self.exec(args, options
|
343
|
-
|
344
|
-
out.set_encoding(Encoding::UTF_8) if out.respond_to?(:set_encoding) && RUBY_PLATFORM == "java"
|
344
|
+
def self.exec(args, output: $stdout, option_parser: self.options, **options)
|
345
|
+
output.set_encoding(Encoding::UTF_8) if output.respond_to?(:set_encoding) && RUBY_PLATFORM == "java"
|
345
346
|
cmds, args = args.partition {|e| commands.include?(e.to_s)}
|
346
347
|
|
347
348
|
if cmds.empty?
|
348
|
-
usage(
|
349
|
+
usage(option_parser)
|
349
350
|
abort "No command given"
|
350
351
|
end
|
351
352
|
|
352
353
|
if cmds.first == 'help'
|
353
354
|
on_cmd = cmds[1]
|
354
355
|
if on_cmd && COMMANDS.fetch(on_cmd.to_sym, {})[:help]
|
355
|
-
usage(
|
356
|
+
usage(option_parser, banner: "Usage: #{self.basename.split('/').last} #{COMMANDS[on_cmd.to_sym][:help]}")
|
356
357
|
else
|
357
|
-
usage(
|
358
|
+
usage(option_parser)
|
358
359
|
end
|
359
360
|
return
|
360
361
|
end
|
@@ -374,7 +375,7 @@ module RDF
|
|
374
375
|
|
375
376
|
# Run each command in sequence
|
376
377
|
cmds.each do |command|
|
377
|
-
COMMANDS[command.to_sym][:lambda].call(args, options)
|
378
|
+
COMMANDS[command.to_sym][:lambda].call(args, output: output, **options)
|
378
379
|
end
|
379
380
|
rescue ArgumentError => e
|
380
381
|
abort e.message
|
@@ -409,7 +410,7 @@ module RDF
|
|
409
410
|
# @yieldparam [Array<String>] argv
|
410
411
|
# @yieldparam [Hash] opts
|
411
412
|
# @yieldreturn [void]
|
412
|
-
def self.add_command(command, options
|
413
|
+
def self.add_command(command, **options, &block)
|
413
414
|
options[:lambda] = block if block_given?
|
414
415
|
COMMANDS[command.to_sym] ||= options
|
415
416
|
end
|
@@ -431,20 +432,25 @@ module RDF
|
|
431
432
|
# yielding a reader
|
432
433
|
#
|
433
434
|
# @param [Array<String>] files
|
435
|
+
# @param [String] evaluate from command-line, rather than referenced file
|
436
|
+
# @param [Symbol] format (:ntriples) Reader symbol for finding reader
|
437
|
+
# @param [Encoding] encoding set on the input
|
438
|
+
# @param [Hash{Symbol => Object}] options sent to reader
|
434
439
|
# @yield [reader]
|
435
440
|
# @yieldparam [RDF::Reader]
|
436
441
|
# @return [nil]
|
437
|
-
def self.parse(files,
|
442
|
+
def self.parse(files, evaluate: nil, format: :ntriples, encoding: Encoding::UTF_8, **options, &block)
|
438
443
|
if files.empty?
|
439
444
|
# If files are empty, either use options[:execute]
|
440
|
-
input =
|
441
|
-
input.set_encoding(
|
442
|
-
r = RDF::Reader.for(
|
445
|
+
input = evaluate ? StringIO.new(evaluate) : $stdin
|
446
|
+
input.set_encoding(encoding)
|
447
|
+
r = RDF::Reader.for(format)
|
443
448
|
(@readers ||= []) << r
|
444
449
|
r.new(input, options) do |reader|
|
445
450
|
yield(reader)
|
446
451
|
end
|
447
452
|
else
|
453
|
+
options[:format] = format if format
|
448
454
|
files.each do |file|
|
449
455
|
RDF::Reader.open(file, options) do |reader|
|
450
456
|
(@readers ||= []) << reader.class.to_s
|
data/lib/rdf/format.rb
CHANGED
@@ -70,7 +70,7 @@ module RDF
|
|
70
70
|
# @param [String, RDF::URI] filename
|
71
71
|
# @return [Class]
|
72
72
|
#
|
73
|
-
# @overload for(options
|
73
|
+
# @overload for(**options)
|
74
74
|
# Finds an RDF serialization format class based on various options.
|
75
75
|
#
|
76
76
|
# @param [Hash{Symbol => Object}] options
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
@@ -121,7 +121,7 @@ module RDF
|
|
121
121
|
# @return [Array<RDF::Statement>]
|
122
122
|
# @see #each_statement
|
123
123
|
# @see #enum_statement
|
124
|
-
def statements(options
|
124
|
+
def statements(**options)
|
125
125
|
Array(enum_statement)
|
126
126
|
end
|
127
127
|
|
@@ -184,7 +184,7 @@ module RDF
|
|
184
184
|
# @return [Array<Array(RDF::Resource, RDF::URI, RDF::Term)>]
|
185
185
|
# @see #each_triple
|
186
186
|
# @see #enum_triple
|
187
|
-
def triples(options
|
187
|
+
def triples(**options)
|
188
188
|
enum_statement.map(&:to_triple) # TODO: optimize
|
189
189
|
end
|
190
190
|
|
@@ -245,7 +245,7 @@ module RDF
|
|
245
245
|
# @return [Array<Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)>]
|
246
246
|
# @see #each_quad
|
247
247
|
# @see #enum_quad
|
248
|
-
def quads(options
|
248
|
+
def quads(**options)
|
249
249
|
enum_statement.map(&:to_quad) # TODO: optimize
|
250
250
|
end
|
251
251
|
|
@@ -711,7 +711,7 @@ module RDF
|
|
711
711
|
# `{subject => {predicate => [*objects]}}`.
|
712
712
|
#
|
713
713
|
# @return [Hash]
|
714
|
-
def
|
714
|
+
def to_h
|
715
715
|
result = {}
|
716
716
|
each_statement do |statement|
|
717
717
|
result[statement.subject] ||= {}
|
@@ -738,14 +738,24 @@ module RDF
|
|
738
738
|
# @see RDF::Writer.dump
|
739
739
|
# @raise [RDF::WriterError] if no writer found
|
740
740
|
# @since 0.2.0
|
741
|
-
def dump(*args)
|
742
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
741
|
+
def dump(*args, **options)
|
743
742
|
writer = RDF::Writer.for(*args)
|
744
743
|
raise RDF::WriterError, "No writer found using #{args.inspect}" unless writer
|
745
|
-
writer.dump(self, nil, options)
|
744
|
+
writer.dump(self, nil, **options)
|
746
745
|
end
|
747
746
|
|
747
|
+
protected
|
748
|
+
|
748
749
|
##
|
750
|
+
# @overload #to_hash
|
751
|
+
# Returns all RDF object terms indexed by their subject and predicate
|
752
|
+
# terms.
|
753
|
+
#
|
754
|
+
# The return value is a `Hash` instance that has the structure:
|
755
|
+
# `{subject => {predicate => [*objects]}}`.
|
756
|
+
#
|
757
|
+
# @return [Hash]
|
758
|
+
# @deprecated Use {#to_h} instead.
|
749
759
|
# @overload #to_writer
|
750
760
|
# Implements #to_writer for each available instance of {RDF::Writer},
|
751
761
|
# based on the writer symbol.
|
@@ -753,6 +763,11 @@ module RDF
|
|
753
763
|
# @return [String]
|
754
764
|
# @see {RDF::Writer.sym}
|
755
765
|
def method_missing(meth, *args)
|
766
|
+
case meth
|
767
|
+
when :to_hash
|
768
|
+
warn "[DEPRECATION] Enumerable#to_hash is deprecated, use Enumerable#to_h instead. Called from #{Gem.location_of_caller.join(':')}"
|
769
|
+
return self.to_h
|
770
|
+
end
|
756
771
|
writer = RDF::Writer.for(meth.to_s[3..-1].to_sym) if meth.to_s[0,3] == "to_"
|
757
772
|
if writer
|
758
773
|
writer.buffer(standard_prefixes: true) {|w| w << self}
|
data/lib/rdf/mixin/enumerator.rb
CHANGED
@@ -7,11 +7,29 @@ module RDF
|
|
7
7
|
include Queryable
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
-
|
10
|
+
##
|
11
|
+
# @return [Array]
|
12
|
+
# @note Make sure returned arrays are also queryable
|
11
13
|
def to_a
|
12
14
|
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
|
13
15
|
end
|
14
|
-
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
##
|
20
|
+
# @overload #to_ary
|
21
|
+
# @see #to_a
|
22
|
+
# @deprecated use {#to_a} instead
|
23
|
+
def method_missing(name, *args)
|
24
|
+
if name == :to_ary
|
25
|
+
warn "[DEPRECATION] #{self.class}#to_ary is deprecated, use " \
|
26
|
+
"#{self.class}#to_a instead. Called from " \
|
27
|
+
"#{Gem.location_of_caller.join(':')}"
|
28
|
+
to_a
|
29
|
+
else
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
17
35
|
|
@@ -28,11 +46,29 @@ module RDF
|
|
28
46
|
include Queryable
|
29
47
|
include Enumerable
|
30
48
|
|
31
|
-
|
49
|
+
##
|
50
|
+
# @return [Array]
|
51
|
+
# @note Make sure returned arrays are also queryable
|
32
52
|
def to_a
|
33
53
|
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
|
34
54
|
end
|
35
|
-
|
55
|
+
|
56
|
+
protected
|
57
|
+
|
58
|
+
##
|
59
|
+
# @overload #to_ary
|
60
|
+
# @see #to_a
|
61
|
+
# @deprecated use {#to_a} instead
|
62
|
+
def method_missing(name, *args)
|
63
|
+
if name == :to_ary
|
64
|
+
warn "[DEPRECATION] #{self.class}#to_ary is deprecated, use " \
|
65
|
+
"#{self.class}#to_a instead. Called from " \
|
66
|
+
"#{Gem.location_of_caller.join(':')}"
|
67
|
+
self.to_a
|
68
|
+
else
|
69
|
+
super
|
70
|
+
end
|
71
|
+
end
|
36
72
|
end
|
37
73
|
end
|
38
74
|
end
|
data/lib/rdf/mixin/queryable.rb
CHANGED
@@ -41,7 +41,7 @@ module RDF
|
|
41
41
|
# Returns an enumerable of statements (may be an enumerator) or query solutions, if passed an {RDF::Query}
|
42
42
|
# @see RDF::Queryable#query_pattern
|
43
43
|
# @note Since 2.0, this may return an Enumerable or an Enumerator in addition to Solutions
|
44
|
-
def query(pattern, options
|
44
|
+
def query(pattern, **options, &block)
|
45
45
|
raise TypeError, "#{self} is not readable" if respond_to?(:readable?) && !readable?
|
46
46
|
|
47
47
|
case pattern
|
@@ -111,7 +111,7 @@ module RDF
|
|
111
111
|
# @see RDF::Queryable#query
|
112
112
|
# @see RDF::Query#execute
|
113
113
|
# @since 0.3.0
|
114
|
-
def query_execute(query, options
|
114
|
+
def query_execute(query, **options, &block)
|
115
115
|
# By default, we let RDF.rb's built-in `RDF::Query#execute` handle BGP
|
116
116
|
# query execution by breaking down the query into its constituent
|
117
117
|
# triple patterns and invoking `RDF::Query::Pattern#execute` on each
|
@@ -139,7 +139,7 @@ module RDF
|
|
139
139
|
# @see RDF::Queryable#query
|
140
140
|
# @see RDF::Query::Pattern#execute
|
141
141
|
# @since 0.2.0
|
142
|
-
def query_pattern(pattern, options
|
142
|
+
def query_pattern(pattern, **options, &block)
|
143
143
|
# By default, we let Ruby's built-in `Enumerable#grep` handle the
|
144
144
|
# matching of statements by iterating over all statements and calling
|
145
145
|
# `RDF::Query::Pattern#===` on each statement.
|
data/lib/rdf/model/dataset.rb
CHANGED
@@ -119,7 +119,7 @@ module RDF
|
|
119
119
|
##
|
120
120
|
# Implements basic query pattern matching over the Dataset, with handling
|
121
121
|
# for a default graph.
|
122
|
-
def query_pattern(pattern, options
|
122
|
+
def query_pattern(pattern, **options, &block)
|
123
123
|
return super unless pattern.graph_name == DEFAULT_GRAPH
|
124
124
|
|
125
125
|
if block_given?
|
data/lib/rdf/model/graph.rb
CHANGED
@@ -87,12 +87,12 @@ module RDF
|
|
87
87
|
end
|
88
88
|
|
89
89
|
##
|
90
|
-
# @param [RDF::Resource]
|
90
|
+
# @param [RDF::Resource] graph_name
|
91
91
|
# The graph_name from the associated {RDF::Queryable} associated
|
92
92
|
# with this graph as provided with the `:data` option
|
93
93
|
# (only for {RDF::Queryable} instances supporting
|
94
94
|
# named graphs).
|
95
|
-
# @param [RDF::Queryable]
|
95
|
+
# @param [RDF::Queryable] data (RDF::Repository.new)
|
96
96
|
# Storage behind this graph.
|
97
97
|
#
|
98
98
|
# @raise [ArgumentError] if a `data` does not support named graphs.
|
@@ -273,7 +273,7 @@ module RDF
|
|
273
273
|
##
|
274
274
|
# @private
|
275
275
|
# @see RDF::Queryable#query_pattern
|
276
|
-
def query_pattern(pattern, options
|
276
|
+
def query_pattern(pattern, **options, &block)
|
277
277
|
pattern = pattern.dup
|
278
278
|
pattern.graph_name = graph_name || false
|
279
279
|
@data.query(pattern, &block)
|
@@ -294,7 +294,7 @@ module RDF
|
|
294
294
|
def insert_statements(statements)
|
295
295
|
enum = Enumerable::Enumerator.new do |yielder|
|
296
296
|
|
297
|
-
statements.send(
|
297
|
+
statements.send(statements.respond_to?(:each_statement) ? :each_statement : :each) do |s|
|
298
298
|
s = s.dup
|
299
299
|
s.graph_name = graph_name
|
300
300
|
yielder << s
|
data/lib/rdf/model/literal.rb
CHANGED
@@ -104,13 +104,13 @@ module RDF
|
|
104
104
|
|
105
105
|
##
|
106
106
|
# @private
|
107
|
-
def self.new(value,
|
108
|
-
raise ArgumentError, "datatype with language must be rdf:langString" if
|
107
|
+
def self.new(value, language: nil, datatype: nil, lexical: nil, validate: false, canonicalize: false, **options)
|
108
|
+
raise ArgumentError, "datatype with language must be rdf:langString" if language && (datatype || RDF.langString).to_s != RDF.langString.to_s
|
109
109
|
|
110
110
|
klass = case
|
111
111
|
when !self.equal?(RDF::Literal)
|
112
112
|
self # subclasses can be directly constructed without type dispatch
|
113
|
-
when typed_literal = datatyped_class(
|
113
|
+
when typed_literal = datatyped_class(datatype.to_s)
|
114
114
|
typed_literal
|
115
115
|
else case value
|
116
116
|
when ::TrueClass then RDF::Literal::Boolean
|
@@ -126,9 +126,9 @@ module RDF
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
literal = klass.allocate
|
129
|
-
literal.send(:initialize, value, options)
|
130
|
-
literal.validate! if
|
131
|
-
literal.canonicalize! if
|
129
|
+
literal.send(:initialize, value, language: language, datatype: datatype, **options)
|
130
|
+
literal.validate! if validate
|
131
|
+
literal.canonicalize! if canonicalize
|
132
132
|
literal
|
133
133
|
end
|
134
134
|
|
@@ -147,28 +147,28 @@ module RDF
|
|
147
147
|
# depending on if there is language
|
148
148
|
#
|
149
149
|
# @param [Object] value
|
150
|
-
# @
|
150
|
+
# @param [Symbol] language (nil)
|
151
151
|
# Language is downcased to ensure proper matching
|
152
|
-
# @
|
152
|
+
# @param [String] lexical (nil)
|
153
153
|
# Supplied lexical representation of this literal,
|
154
|
-
# otherwise it comes from transforming `value` to a string form
|
155
|
-
#
|
156
|
-
# @
|
157
|
-
# @
|
158
|
-
# @option options [Boolean] :canonicalize (false)
|
154
|
+
# otherwise it comes from transforming `value` to a string form..
|
155
|
+
# @param [URI] datatype (nil)
|
156
|
+
# @param [Boolean] validate (false)
|
157
|
+
# @param [Boolean] canonicalize (false)
|
159
158
|
# @raise [ArgumentError]
|
160
159
|
# if there is a language and datatype is no rdf:langString
|
161
160
|
# or datatype is rdf:langString and there is no language
|
162
161
|
# @see http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal
|
163
162
|
# @see http://www.w3.org/TR/rdf11-concepts/#section-Datatypes
|
164
|
-
|
163
|
+
# @see #to_s
|
164
|
+
def initialize(value, language: nil, datatype: nil, lexical: nil, validate: false, canonicalize: false, **options)
|
165
165
|
@object = value.freeze
|
166
|
-
@string =
|
166
|
+
@string = lexical if lexical
|
167
167
|
@string = value if !defined?(@string) && value.is_a?(String)
|
168
168
|
@string = @string.encode(Encoding::UTF_8).freeze if @string
|
169
169
|
@object = @string if @string && @object.is_a?(String)
|
170
|
-
@language =
|
171
|
-
@datatype = RDF::URI(
|
170
|
+
@language = language.to_s.downcase.to_sym if language
|
171
|
+
@datatype = RDF::URI(datatype).freeze if datatype
|
172
172
|
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
|
173
173
|
@datatype ||= @language ? RDF.langString : RDF::XSD.string
|
174
174
|
raise ArgumentError, "datatype of rdf:langString requires a language" if !@language && @datatype == RDF::langString
|
@@ -233,7 +233,7 @@ module RDF
|
|
233
233
|
##
|
234
234
|
# Returns a hash code for this literal.
|
235
235
|
#
|
236
|
-
# @return [
|
236
|
+
# @return [Integer]
|
237
237
|
def hash
|
238
238
|
@hash ||= [to_s, datatype, language].hash
|
239
239
|
end
|
@@ -242,7 +242,7 @@ module RDF
|
|
242
242
|
##
|
243
243
|
# Returns a hash code for the value.
|
244
244
|
#
|
245
|
-
# @return [
|
245
|
+
# @return [Integer]
|
246
246
|
def value_hash
|
247
247
|
@value_hash ||= value.hash
|
248
248
|
end
|
@@ -441,7 +441,7 @@ module RDF
|
|
441
441
|
#
|
442
442
|
# @param [String] string
|
443
443
|
# @return [String]
|
444
|
-
# @see
|
444
|
+
# @see RDF::Term#escape
|
445
445
|
def escape(string)
|
446
446
|
string.gsub('\\', '\\\\').
|
447
447
|
gsub("\t", '\\t').
|
@@ -477,5 +477,27 @@ module RDF
|
|
477
477
|
def inspect
|
478
478
|
sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, RDF::NTriples.serialize(self))
|
479
479
|
end
|
480
|
+
|
481
|
+
protected
|
482
|
+
|
483
|
+
##
|
484
|
+
# @overload #to_str
|
485
|
+
# This method is implemented when the datatype is `xsd:string` or `rdf:langString`
|
486
|
+
# @return [String]
|
487
|
+
def method_missing(name, *args)
|
488
|
+
case name
|
489
|
+
when :to_str
|
490
|
+
return to_s if @datatype == RDF.langString || @datatype == RDF::XSD.string
|
491
|
+
end
|
492
|
+
super
|
493
|
+
end
|
494
|
+
|
495
|
+
def respond_to_missing?(name, include_private = false)
|
496
|
+
case name
|
497
|
+
when :to_str
|
498
|
+
return true if @datatype == RDF.langString || @datatype == RDF::XSD.string
|
499
|
+
end
|
500
|
+
super
|
501
|
+
end
|
480
502
|
end # Literal
|
481
503
|
end # RDF
|