rdf-trig 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +15 -0
  2. data/VERSION +1 -1
  3. data/lib/rdf/trig/meta.rb +459 -549
  4. data/lib/rdf/trig/reader.rb +18 -37
  5. metadata +11 -36
@@ -67,26 +67,26 @@ module RDF::TriG
67
67
  end
68
68
 
69
69
  # String terminals
70
- terminal(nil, %r([\{\}\(\),.;\[\]a]|\^\^|@base|@prefix|true|false)) do |prod, token, input|
70
+ terminal(nil, %r([\{\}\(\),.;\[\]a]|\^\^|true|false)) do |prod, token, input|
71
71
  case token.value
72
- when 'a' then input[:resource] = RDF.type
72
+ when 'A', 'a' then input[:resource] = RDF.type
73
73
  when 'true', 'false' then input[:resource] = RDF::Literal::Boolean.new(token.value)
74
74
  when '@base', '@prefix' then input[:lang] = token.value[1..-1]
75
75
  else input[:string] = token.value
76
76
  end
77
77
  end
78
78
 
79
- terminal(:LANGTAG, LANGTAG) do |prod, token, input|
80
- input[:lang] = token.value[1..-1]
81
- end
82
-
83
- terminal(:SPARQL_PREFIX, SPARQL_PREFIX) do |prod, token, input|
79
+ terminal(:PREFIX, PREFIX) do |prod, token, input|
84
80
  input[:string_value] = token.value.downcase
85
81
  end
86
- terminal(:SPARQL_BASE, SPARQL_BASE) do |prod, token, input|
82
+ terminal(:BASE, BASE) do |prod, token, input|
87
83
  input[:string_value] = token.value.downcase
88
84
  end
89
85
 
86
+ terminal(:LANGTAG, LANGTAG) do |prod, token, input|
87
+ input[:lang] = token.value[1..-1]
88
+ end
89
+
90
90
  # Productions
91
91
  # [3g] graph defines the basic creation of context
92
92
  start_production(:graph) do |input, current, callback|
@@ -96,13 +96,13 @@ module RDF::TriG
96
96
  callback.call(:context, "graph", nil)
97
97
  end
98
98
 
99
- # [4g] graphIri
100
- # Normally, just returns the IRIref, but if called from [3g], also
99
+ # [4g] graphName
100
+ # Normally, just returns the resource, but if called from [3g], also
101
101
  # sets the context for triples defined within that graph
102
- production(:graphIri) do |input, current, callback|
102
+ production(:graphName) do |input, current, callback|
103
103
  # If input contains set_graph_iri, use the returned value to set @context
104
- debug("graphIri") {"Set graph context to #{current[:resource]}"}
105
- callback.call(:context, "graphIri", current[:resource])
104
+ debug("graphName") {"Set graph context to #{current[:resource]}"}
105
+ callback.call(:context, "graphName", current[:resource])
106
106
  end
107
107
 
108
108
 
@@ -122,21 +122,6 @@ module RDF::TriG
122
122
  options[:base_uri] = iri
123
123
  end
124
124
 
125
- # [28s] sparqlPrefix ::= [Pp][Rr][Ee][Ff][Ii][Xx] PNAME_NS IRIREF
126
- production(:sparqlPrefix) do |input, current, callback|
127
- prefix = current[:prefix]
128
- iri = current[:resource]
129
- debug("sparqlPrefix") {"Defined prefix #{prefix.inspect} mapping to #{iri.inspect}"}
130
- prefix(prefix, iri)
131
- end
132
-
133
- # [29s] sparqlBase ::= [Bb][Aa][Ss][Ee] IRIREF
134
- production(:sparqlBase) do |input, current, callback|
135
- iri = current[:resource]
136
- debug("base") {"Defined base as #{iri}"}
137
- options[:base_uri] = iri
138
- end
139
-
140
125
  # [6] triples
141
126
  start_production(:triples) do |input, current, callback|
142
127
  # Note production as triples for blankNodePropertyList
@@ -195,20 +180,15 @@ module RDF::TriG
195
180
 
196
181
  production(:collection) do |input, current, callback|
197
182
  # Create an RDF list
198
- bnode = self.bnode
199
183
  objects = current[:object_list]
200
- list = RDF::List.new(bnode, nil, objects)
184
+ list = RDF::List[*objects]
201
185
  list.each_statement do |statement|
202
- # Spec Confusion, referenced section "Collection" is missing from the spec.
203
- # Anicdodal evidence indicates that some expect each node to be of type rdf:list,
204
- # but existing Notation3 and Turtle tests (http://www.w3.org/2001/sw/DataAccess/df1/tests/manifest.ttl) do not.
205
186
  next if statement.predicate == RDF.type && statement.object == RDF.List
206
187
  callback.call(:statement, "collection", statement.subject, statement.predicate, statement.object)
207
188
  end
208
- bnode = RDF.nil if list.empty?
209
189
 
210
190
  # Return bnode as resource
211
- input[:resource] = bnode
191
+ input[:resource] = list.subject
212
192
  end
213
193
 
214
194
  # [16] RDFLiteral ::= String ( LanguageTag | ( "^^" IRIref ) )?
@@ -240,7 +220,8 @@ module RDF::TriG
240
220
  data << @context if @context
241
221
  debug("each_statement") {"data: #{data.inspect}, context: #{@context.inspect}"}
242
222
  loc = data.shift
243
- add_statement(loc, RDF::Statement.from(data))
223
+ s = RDF::Statement.from(data, :lineno => lineno)
224
+ add_statement(loc, s) unless !s.valid? && validate?
244
225
  when :trace
245
226
  level, lineno, depth, *args = data
246
227
  message = "#{args.join(': ')}"
@@ -257,7 +238,7 @@ module RDF::TriG
257
238
  end
258
239
  end
259
240
  rescue EBNF::LL1::Parser::Error => e
260
- debug("Parsing completed with errors:\n\t#{e.message}")
241
+ progress("Parsing completed with errors:\n\t#{e.message}")
261
242
  raise RDF::ReaderError, e.message if validate?
262
243
  end
263
244
 
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-trig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gregg Kellogg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
11
+ date: 2013-05-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rdf
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '1.0'
19
+ version: 1.0.7
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
29
- version: '1.0'
26
+ version: 1.0.7
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: ebnf
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
37
- version: 0.2.0
33
+ version: 0.3.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
- version: 0.2.0
40
+ version: 0.3.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rdf-turtle
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
53
- version: 1.0.4
47
+ version: 1.0.7
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
- version: 1.0.4
54
+ version: 1.0.7
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: open-uri-cached
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: json-ld
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rdf-isomorphic
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: yard
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ! '>='
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rdf-spec
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ! '>='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ! '>='
156
137
  - !ruby/object:Gem::Version
@@ -158,7 +139,6 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rake
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - ! '>='
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - ! '>='
172
151
  - !ruby/object:Gem::Version
@@ -191,30 +170,26 @@ files:
191
170
  homepage: http://ruby-rdf.github.com/rdf-trig
192
171
  licenses:
193
172
  - Public Domain
173
+ metadata: {}
194
174
  post_install_message:
195
175
  rdoc_options: []
196
176
  require_paths:
197
177
  - lib
198
178
  required_ruby_version: !ruby/object:Gem::Requirement
199
- none: false
200
179
  requirements:
201
180
  - - ! '>='
202
181
  - !ruby/object:Gem::Version
203
182
  version: 1.8.1
204
183
  required_rubygems_version: !ruby/object:Gem::Requirement
205
- none: false
206
184
  requirements:
207
185
  - - ! '>='
208
186
  - !ruby/object:Gem::Version
209
187
  version: '0'
210
- segments:
211
- - 0
212
- hash: 3391794697366494735
213
188
  requirements: []
214
189
  rubyforge_project: rdf-trig
215
- rubygems_version: 1.8.25
190
+ rubygems_version: 2.0.3
216
191
  signing_key:
217
- specification_version: 3
192
+ specification_version: 4
218
193
  summary: TriG reader/writer for Ruby.
219
194
  test_files: []
220
195
  has_rdoc: false