rdf-json 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/VERSION +1 -1
- data/lib/rdf/json/extensions.rb +13 -8
- data/lib/rdf/json/reader.rb +16 -16
- data/lib/rdf/json/version.rb +2 -2
- metadata +16 -16
data/README
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/rdf/json/extensions.rb
CHANGED
@@ -31,6 +31,15 @@ module RDF::JSON
|
|
31
31
|
# [RDF::Statement.new(s, p, o)].extend(RDF::Enumerable).to_json
|
32
32
|
#
|
33
33
|
module Extensions
|
34
|
+
##
|
35
|
+
# @private
|
36
|
+
def self.install!
|
37
|
+
self.constants.each do |klass|
|
38
|
+
RDF.const_get(klass).send(:include, self.const_get(:Value)) # needed on Ruby 1.8.x
|
39
|
+
RDF.const_get(klass).send(:include, self.const_get(klass))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
34
43
|
##
|
35
44
|
# RDF/JSON extensions for `RDF::Value`.
|
36
45
|
module Value
|
@@ -77,9 +86,9 @@ module RDF::JSON
|
|
77
86
|
# @return [Hash]
|
78
87
|
def to_rdf_json
|
79
88
|
case
|
80
|
-
when
|
89
|
+
when has_datatype?
|
81
90
|
{:type => :literal, :value => value.to_s, :datatype => datatype.to_s}
|
82
|
-
when
|
91
|
+
when has_language?
|
83
92
|
{:type => :literal, :value => value.to_s, :lang => language.to_s}
|
84
93
|
else
|
85
94
|
{:type => :literal, :value => value.to_s}
|
@@ -95,9 +104,7 @@ module RDF::JSON
|
|
95
104
|
#
|
96
105
|
# @return [Hash]
|
97
106
|
def to_rdf_json
|
98
|
-
|
99
|
-
s, p, o = subject.to_s, predicate.to_s, object.is_a?(RDF::Value) ? object : RDF::Literal.new(object)
|
100
|
-
{s => {p => [o.to_rdf_json]}}
|
107
|
+
{subject.to_s => {predicate.to_s => [object.to_rdf_json]}}
|
101
108
|
end
|
102
109
|
end
|
103
110
|
|
@@ -143,7 +150,5 @@ module RDF::JSON
|
|
143
150
|
end
|
144
151
|
end # module Extensions
|
145
152
|
|
146
|
-
Extensions.
|
147
|
-
RDF.const_get(klass).send(:include, Extensions.const_get(klass))
|
148
|
-
end
|
153
|
+
Extensions.install!
|
149
154
|
end # module RDF::JSON
|
data/lib/rdf/json/reader.rb
CHANGED
@@ -76,8 +76,8 @@ module RDF::JSON
|
|
76
76
|
# @param [String] predicate
|
77
77
|
# @return [RDF::URI]
|
78
78
|
def parse_predicate(predicate)
|
79
|
-
# TODO: support for CURIE predicates (issue #1 on GitHub).
|
80
|
-
|
79
|
+
# TODO: optional support for CURIE predicates (issue #1 on GitHub).
|
80
|
+
RDF::URI.intern(predicate)
|
81
81
|
end
|
82
82
|
|
83
83
|
##
|
@@ -105,25 +105,25 @@ module RDF::JSON
|
|
105
105
|
end
|
106
106
|
|
107
107
|
##
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# @
|
111
|
-
|
112
|
-
|
108
|
+
# @private
|
109
|
+
# @see RDF::Reader#each_graph
|
110
|
+
# @since 0.2.0
|
111
|
+
def each_graph(&block)
|
112
|
+
block_given? ? @block.call(@graph) : enum_for(:each_graph).extend(RDF::Countable)
|
113
|
+
end
|
114
|
+
|
115
|
+
##
|
116
|
+
# @private
|
117
|
+
# @see RDF::Reader#each_statement
|
113
118
|
def each_statement(&block)
|
114
|
-
@graph.each_statement(&block)
|
119
|
+
block_given? ? @graph.each_statement(&block) : enum_for(:each_statement).extend(RDF::Countable)
|
115
120
|
end
|
116
121
|
|
117
122
|
##
|
118
|
-
#
|
119
|
-
#
|
120
|
-
# @yield [subject, predicate, object]
|
121
|
-
# @yieldparam [RDF::Resource] subject
|
122
|
-
# @yieldparam [RDF::URI] predicate
|
123
|
-
# @yieldparam [RDF::Value] object
|
124
|
-
# @return [void]
|
123
|
+
# @private
|
124
|
+
# @see RDF::Reader#each_statement
|
125
125
|
def each_triple(&block)
|
126
|
-
@graph.each_triple(&block)
|
126
|
+
block_given? ? @graph.each_triple(&block) : enum_for(:each_triple).extend(RDF::Countable)
|
127
127
|
end
|
128
128
|
end # class Reader
|
129
129
|
end # module RDF::JSON
|
data/lib/rdf/json/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Arto Bendiken
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-18 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,9 +26,9 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 0
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 0.
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
version: 0.2.0
|
32
32
|
type: :development
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -55,8 +55,8 @@ dependencies:
|
|
55
55
|
segments:
|
56
56
|
- 0
|
57
57
|
- 5
|
58
|
-
-
|
59
|
-
version: 0.5.
|
58
|
+
- 6
|
59
|
+
version: 0.5.6
|
60
60
|
type: :development
|
61
61
|
version_requirements: *id003
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -68,9 +68,9 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
segments:
|
70
70
|
- 0
|
71
|
-
-
|
72
|
-
-
|
73
|
-
version: 0.
|
71
|
+
- 2
|
72
|
+
- 0
|
73
|
+
version: 0.2.0
|
74
74
|
type: :runtime
|
75
75
|
version_requirements: *id004
|
76
76
|
- !ruby/object:Gem::Dependency
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
type: :runtime
|
89
89
|
version_requirements: *id005
|
90
90
|
description: RDF.rb plugin for parsing/serializing RDF/JSON data.
|
91
|
-
email:
|
91
|
+
email: public-rdf-ruby@w3.org
|
92
92
|
executables: []
|
93
93
|
|
94
94
|
extensions: []
|
@@ -108,7 +108,7 @@ files:
|
|
108
108
|
- lib/rdf/json/writer.rb
|
109
109
|
- lib/rdf/json.rb
|
110
110
|
has_rdoc: false
|
111
|
-
homepage: http://rdf.rubyforge.org/
|
111
|
+
homepage: http://rdf.rubyforge.org/json/
|
112
112
|
licenses:
|
113
113
|
- Public Domain
|
114
114
|
post_install_message:
|
@@ -123,8 +123,8 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
segments:
|
124
124
|
- 1
|
125
125
|
- 8
|
126
|
-
-
|
127
|
-
version: 1.8.
|
126
|
+
- 1
|
127
|
+
version: 1.8.1
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ">="
|