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 CHANGED
@@ -19,7 +19,7 @@ Documentation
19
19
  Dependencies
20
20
  ------------
21
21
 
22
- * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.1.10)
22
+ * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.2.0)
23
23
  * [JSON](http://rubygems.org/gems/json_pure) (>= 1.4.3)
24
24
 
25
25
  Installation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -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 datatype? # FIXME: use `has_datatype?` in RDF.rb 0.1.0
89
+ when has_datatype?
81
90
  {:type => :literal, :value => value.to_s, :datatype => datatype.to_s}
82
- when language? # FIXME: use `has_language?` in RDF.rb 0.1.0
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
- # FIXME: improve the RDF::Statement constructor in RDF.rb 0.1.0
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.constants.each do |klass|
147
- RDF.const_get(klass).send(:include, Extensions.const_get(klass))
148
- end
153
+ Extensions.install!
149
154
  end # module RDF::JSON
@@ -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
- parse_subject(predicate)
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
- # Iterates the given block for each RDF statement in the input.
109
- #
110
- # @yield [statement]
111
- # @yieldparam [RDF::Statement] statement
112
- # @return [void]
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
- # Iterates the given block for each RDF triple in the input.
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
@@ -1,8 +1,8 @@
1
1
  module RDF; module JSON
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 1
4
+ MINOR = 2
5
+ TINY = 0
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
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-12 00:00:00 +02:00
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
- - 1
30
- - 10
31
- version: 0.1.10
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
- - 5
59
- version: 0.5.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
- - 1
72
- - 10
73
- version: 0.1.10
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: arto.bendiken@gmail.com
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
- - 2
127
- version: 1.8.2
126
+ - 1
127
+ version: 1.8.1
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="