rdf-trig 1.99.0.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 945b965084b17121e6a5a70b0cb66b58440715e1
4
- data.tar.gz: dd4aaa9580923f30b8ddcd89d4061a42aafdc9eb
3
+ metadata.gz: 35b96ac52b82bb2ed1cf499ce6f45cd1500c38d9
4
+ data.tar.gz: 1bd3f0b3567026b4ebd885e90ab2518d535ba9be
5
5
  SHA512:
6
- metadata.gz: 6745f82933f2b6500a42b5ac3c23817abc330e43b083ffa27d6fe20164fb0cc65f1d7b26dd80748dfc752b9410e7b5afe68eb8d0cbee92080f97523714f49644
7
- data.tar.gz: bd853537f25715b9ee00d9240da7d91236b49eabb05df1de0ce467601881d796576747368a6dca780b2238b734b5aa533cdb6cecfe62e45a41398060e5ee4a56
6
+ metadata.gz: ec377131d0565b53ebc0c7aba15854e9e71d345419a6769351e32b100a1e617216260301afdab3e7c55b71f9279e80a3a5ee23419532ecd40980550e250fad28
7
+ data.tar.gz: a576989832f2438a1705680902f22adff5eb3350fbeb64d89621b1bd3893f020da58ace14eab0ce464f0ab3863f46cc0acdccc9c34e0c5532bb042799f91a76a
data/README.md CHANGED
@@ -17,7 +17,7 @@ Install with `gem install rdf-trig`
17
17
 
18
18
  * 100% free and unencumbered [public domain](http://unlicense.org/) software.
19
19
  * Implements a complete parser and serializer for [TriG][].
20
- * Compatible with Ruby 1.8.7+, Ruby 1.9.x, and JRuby 1.7+.
20
+ * Compatible with Ruby 2.x, and JRuby 1.7+.
21
21
  * Optional streaming writer, to serialize large graphs
22
22
 
23
23
  ## Usage
@@ -58,9 +58,9 @@ There is a new `:stream` option to {RDF::TriG::Writer} which is more efficient f
58
58
 
59
59
  ## Dependencies
60
60
 
61
- * [Ruby](http://ruby-lang.org/) (>= 1.9.3)
62
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 1.1)
63
- * [rdf-turtle](http://rubygems.org/gems/rdf-turtle) (~> 1.1, >= 1.1.8)
61
+ * [Ruby](http://ruby-lang.org/) (>= 2.0)
62
+ * [RDF.rb](http://rubygems.org/gems/rdf) (~> 2.0)
63
+ * [rdf-turtle](http://rubygems.org/gems/rdf-turtle) (~> 2.0)
64
64
 
65
65
  ## Installation
66
66
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.99.0.1
1
+ 2.0.0.beta1
@@ -25,8 +25,5 @@ module RDF
25
25
  autoload :Reader, 'rdf/trig/reader'
26
26
  autoload :VERSION, 'rdf/trig/version'
27
27
  autoload :Writer, 'rdf/trig/writer'
28
-
29
- def self.debug?; @debug; end
30
- def self.debug=(value); RDF::Turtle.debug = @debug = value; end
31
28
  end
32
29
  end
@@ -49,14 +49,8 @@ module RDF::TriG
49
49
  # Terminate loop if EOF found while recovering
50
50
  end
51
51
 
52
- if validate?
53
- if !warnings.empty? && !@options[:warnings]
54
- $stderr.puts "Warnings: #{warnings.join("\n")}"
55
- end
56
- if !errors.empty?
57
- $stderr.puts "Errors: #{errors.join("\n")}" unless @options[:errors]
58
- raise RDF::ReaderError, "Errors found during processing"
59
- end
52
+ if validate? && log_statistics[:error]
53
+ raise RDF::ReaderError, "Errors found during processing"
60
54
  end
61
55
  end
62
56
  enum_for(:each_statement)
@@ -123,7 +117,7 @@ module RDF::TriG
123
117
  when nil
124
118
  # End of input
125
119
  else
126
- error("Unexpected token", production: :block, token: @lexer.first)
120
+ error("Unexpected token: #{@lexer.first.inspect}", production: :block, token: @lexer.first)
127
121
  end
128
122
  end
129
123
  end
@@ -217,8 +211,10 @@ module RDF::TriG
217
211
  def read_triplesBlock
218
212
  prod(:triplesBlock, %w(.)) do
219
213
  while (token = @lexer.first) && token.value != '}' && read_triples
220
- break unless @lexer.first === '.'
221
- @lexer.shift
214
+ unless log_recovering?
215
+ break unless @lexer.first === '.'
216
+ @lexer.shift
217
+ end
222
218
  end
223
219
  end
224
220
  end
@@ -59,40 +59,6 @@ module RDF::TriG
59
59
  include StreamingWriter
60
60
  format RDF::TriG::Format
61
61
 
62
- class GraphFilteredRepo
63
- include RDF::Queryable
64
-
65
- def initialize(repo, graph_name)
66
- @repo = repo
67
- @graph_name = graph_name
68
- end
69
-
70
- # Filter statements in repository to those having the specified graph_name
71
- # Returns each statement having the specified graph_name, `false` for default graph
72
- # @yield statement
73
- # @yieldparam [RDF::Statement] statement
74
- # @return [void]
75
- # @see [RDF::Queryable]
76
- def each
77
- @repo.each_statement do |st|
78
- case @graph_name
79
- when false
80
- yield st if !st.graph_name
81
- else
82
- yield st if st.graph_name == @graph_name
83
- end
84
- end
85
- end
86
-
87
- ##
88
- # Proxy Repository#query_pattern
89
- # @see RDF::Repository#query_pattern
90
- def query_pattern(pattern, &block)
91
- pattern.graph_name = @graph_name || false
92
- @repo.send(:query_pattern, pattern, &block)
93
- end
94
- end
95
-
96
62
  ##
97
63
  # Initializes the TriG writer instance.
98
64
  #
@@ -122,11 +88,8 @@ module RDF::TriG
122
88
  # @yield [writer]
123
89
  # @yieldparam [RDF::Writer] writer
124
90
  def initialize(output = $stdout, options = {}, &block)
125
- reset
126
91
  super do
127
92
  # Set both @repo and @graph to a new repository.
128
- # When serializing a named graph, @graph is changed
129
- # to a GraphFilteredRepo
130
93
  @repo = @graph = RDF::Repository.new
131
94
  if block_given?
132
95
  case block.arity
@@ -139,15 +102,18 @@ module RDF::TriG
139
102
 
140
103
 
141
104
  ##
142
- # Adds a statement to be serialized
143
- # @param [RDF::Statement] statement
105
+ # Adds a triple to be serialized
106
+ # @param [RDF::Resource] subject
107
+ # @param [RDF::URI] predicate
108
+ # @param [RDF::Value] object
109
+ # @param [RDF::Resource] graph_name
144
110
  # @return [void]
145
- def write_statement(statement)
146
- case
147
- when @options[:stream]
111
+ def write_quad(subject, predicate, object, graph_name)
112
+ statement = RDF::Statement.new(subject, predicate, object, graph_name: graph_name)
113
+ if @options[:stream]
148
114
  stream_statement(statement)
149
115
  else
150
- super
116
+ @graph.insert(statement)
151
117
  end
152
118
  end
153
119
 
@@ -178,34 +144,37 @@ module RDF::TriG
178
144
 
179
145
  reset
180
146
 
181
- debug {"\nserialize: repo: #{@repo.size}"}
147
+ log_debug {"serialize: repo: #{@repo.size}"}
182
148
 
183
149
  preprocess
184
150
  start_document
185
151
 
186
- order_graphs.each do |ctx|
187
- debug {"graph_name: #{ctx.inspect}"}
188
- reset
189
- @depth = ctx ? 2 : 0
152
+ order_graphs.each do |graph_name|
153
+ log_depth do
154
+ log_debug {"graph_name: #{graph_name.inspect}"}
155
+ reset
156
+ @options[:log_depth] = graph_name ? 1 : 0
190
157
 
191
- if ctx
192
- @output.write("\n#{format_term(ctx)} {")
193
- end
158
+ if graph_name
159
+ @output.write("\n#{format_term(graph_name)} {")
160
+ end
194
161
 
195
- # Restrict view to the particular graph
196
- @graph = GraphFilteredRepo.new(@repo, ctx)
162
+ # Restrict view to the particular graph
163
+ @graph = @repo.project_graph(graph_name)
197
164
 
198
- # Pre-process statements again, but in the specified graph
199
- @graph.each {|st| preprocess_statement(st)}
200
- order_subjects.each do |subject|
201
- unless is_done?(subject)
202
- statement(subject)
165
+ # Pre-process statements again, but in the specified graph
166
+ @graph.each {|st| preprocess_statement(st)}
167
+ order_subjects.each do |subject|
168
+ unless is_done?(subject)
169
+ statement(subject)
170
+ end
203
171
  end
204
- end
205
172
 
206
- @output.puts("}") if ctx
173
+ @output.puts("}") if graph_name
174
+ end
207
175
  end
208
176
  end
177
+ raise RDF::WriterError, "Errors found during processing" if log_statistics[:error]
209
178
  end
210
179
 
211
180
  protected
@@ -228,7 +197,7 @@ module RDF::TriG
228
197
 
229
198
  # Order graphs for output
230
199
  def order_graphs
231
- debug("order_graphs") {@repo.graph_names.to_a.inspect}
200
+ log_debug("order_graphs") {@repo.graph_names.to_a.inspect}
232
201
  graph_names = @repo.graph_names.to_a.sort
233
202
 
234
203
  # include default graph, if necessary
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-trig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.0.1
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0.beta
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '1.99'
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '1.99'
29
+ version: 2.0.0.beta
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: ebnf
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '1.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.1.beta
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,34 +47,49 @@ dependencies:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
49
  version: '1.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.1.beta
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rdf-turtle
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - "~>"
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.0.0.beta
60
+ - - "<"
46
61
  - !ruby/object:Gem::Version
47
- version: '1.99'
62
+ version: '3'
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - "~>"
67
+ - - ">="
53
68
  - !ruby/object:Gem::Version
54
- version: '1.99'
69
+ version: 2.0.0.beta
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '3'
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: json-ld
57
75
  requirement: !ruby/object:Gem::Requirement
58
76
  requirements:
59
- - - "~>"
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.0.0.beta
80
+ - - "<"
60
81
  - !ruby/object:Gem::Version
61
- version: '1.99'
82
+ version: '3'
62
83
  type: :development
63
84
  prerelease: false
64
85
  version_requirements: !ruby/object:Gem::Requirement
65
86
  requirements:
66
- - - "~>"
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.0.beta
90
+ - - "<"
67
91
  - !ruby/object:Gem::Version
68
- version: '1.99'
92
+ version: '3'
69
93
  - !ruby/object:Gem::Dependency
70
94
  name: rspec
71
95
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +122,22 @@ dependencies:
98
122
  name: rdf-isomorphic
99
123
  requirement: !ruby/object:Gem::Requirement
100
124
  requirements:
101
- - - "~>"
125
+ - - ">="
102
126
  - !ruby/object:Gem::Version
103
- version: '1.99'
127
+ version: 2.0.0.beta
128
+ - - "<"
129
+ - !ruby/object:Gem::Version
130
+ version: '3'
104
131
  type: :development
105
132
  prerelease: false
106
133
  version_requirements: !ruby/object:Gem::Requirement
107
134
  requirements:
108
- - - "~>"
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 2.0.0.beta
138
+ - - "<"
109
139
  - !ruby/object:Gem::Version
110
- version: '1.99'
140
+ version: '3'
111
141
  - !ruby/object:Gem::Dependency
112
142
  name: yard
113
143
  requirement: !ruby/object:Gem::Requirement
@@ -126,16 +156,22 @@ dependencies:
126
156
  name: rdf-spec
127
157
  requirement: !ruby/object:Gem::Requirement
128
158
  requirements:
129
- - - "~>"
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: 2.0.0.beta
162
+ - - "<"
130
163
  - !ruby/object:Gem::Version
131
- version: '1.99'
164
+ version: '3'
132
165
  type: :development
133
166
  prerelease: false
134
167
  version_requirements: !ruby/object:Gem::Requirement
135
168
  requirements:
136
- - - "~>"
169
+ - - ">="
137
170
  - !ruby/object:Gem::Version
138
- version: '1.99'
171
+ version: 2.0.0.beta
172
+ - - "<"
173
+ - !ruby/object:Gem::Version
174
+ version: '3'
139
175
  - !ruby/object:Gem::Dependency
140
176
  name: rake
141
177
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +205,7 @@ files:
169
205
  - lib/rdf/trig/writer.rb
170
206
  homepage: http://ruby-rdf.github.com/rdf-trig
171
207
  licenses:
172
- - Public Domain
208
+ - Unlicense
173
209
  metadata: {}
174
210
  post_install_message:
175
211
  rdoc_options: []
@@ -179,15 +215,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
215
  requirements:
180
216
  - - ">="
181
217
  - !ruby/object:Gem::Version
182
- version: 1.9.3
218
+ version: '2.0'
183
219
  required_rubygems_version: !ruby/object:Gem::Requirement
184
220
  requirements:
185
- - - ">="
221
+ - - ">"
186
222
  - !ruby/object:Gem::Version
187
- version: '0'
223
+ version: 1.3.1
188
224
  requirements: []
189
225
  rubyforge_project: rdf-trig
190
- rubygems_version: 2.4.5.1
226
+ rubygems_version: 2.5.1
191
227
  signing_key:
192
228
  specification_version: 4
193
229
  summary: TriG reader/writer for Ruby.