sparql-client 2.2.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- module SPARQL; class Client
1
+ class SPARQL::Client
2
2
  ##
3
3
  # A read-only repository view of a SPARQL endpoint.
4
4
  #
@@ -10,14 +10,13 @@ module SPARQL; class Client
10
10
  ##
11
11
  # @param [URI, #to_s] uri
12
12
  # Endpoint of this repository
13
- # @param [String, #to_s] title (nil)
14
13
  # @param [Hash{Symbol => Object}] options passed to RDF::Repository
15
14
  def initialize(uri: nil, **options, &block)
16
15
  raise ArgumentError, "uri is a required parameter" unless uri
17
16
  @options = options.merge(uri: uri)
18
- @update_client = SPARQL::Client.new(options.delete(:update_endpoint), options) if options[:update_endpoint]
19
- @client = SPARQL::Client.new(uri, options)
20
- super(@options, &block)
17
+ @update_client = SPARQL::Client.new(options.delete(:update_endpoint), **options) if options[:update_endpoint]
18
+ @client = SPARQL::Client.new(uri, **options)
19
+ super(**@options, &block)
21
20
  end
22
21
 
23
22
  ##
@@ -116,7 +115,7 @@ module SPARQL; class Client
116
115
  # @see RDF::Repository#each_subject?
117
116
  def each_subject(&block)
118
117
  if block_given?
119
- client.select(:s, :distinct => true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:s]) }
118
+ client.select(:s, distinct: true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:s]) }
120
119
  end
121
120
  enum_subject
122
121
  end
@@ -130,7 +129,7 @@ module SPARQL; class Client
130
129
  # @see RDF::Repository#each_predicate?
131
130
  def each_predicate(&block)
132
131
  if block_given?
133
- client.select(:p, :distinct => true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:p]) }
132
+ client.select(:p, distinct: true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:p]) }
134
133
  end
135
134
  enum_predicate
136
135
  end
@@ -144,7 +143,7 @@ module SPARQL; class Client
144
143
  # @see RDF::Repository#each_object?
145
144
  def each_object(&block)
146
145
  if block_given?
147
- client.select(:o, :distinct => true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:o]) }
146
+ client.select(:o, distinct: true).where([:s, :p, :o]).each_solution { |solution| block.call(solution[:o]) }
148
147
  end
149
148
  enum_object
150
149
  end
@@ -180,9 +179,7 @@ module SPARQL; class Client
180
179
  binding[:count].value.to_i rescue 0
181
180
  rescue SPARQL::Client::MalformedQuery => e
182
181
  # SPARQL 1.0 does not include support for aggregate functions:
183
- count = 0
184
- each_statement { count += 1 } # TODO: optimize this
185
- count
182
+ each_statement.count
186
183
  end
187
184
  end
188
185
 
@@ -263,10 +260,12 @@ module SPARQL; class Client
263
260
  # @return [void] ignored
264
261
  # @see RDF::Queryable#query
265
262
  # @see RDF::Query#execute
266
- def query_execute(query, options = {}, &block)
263
+ def query_execute(query, **options, &block)
267
264
  return nil unless block_given?
268
- q = SPARQL::Client::Query.select(query.variables).where(*query.patterns)
269
- client.query(q, options).each do |solution|
265
+ q = SPARQL::Client::Query.
266
+ select(query.variables, **{}).
267
+ where(*query.patterns)
268
+ client.query(q, **options).each do |solution|
270
269
  yield solution
271
270
  end
272
271
  end
@@ -276,7 +275,7 @@ module SPARQL; class Client
276
275
  #
277
276
  # @example
278
277
  # repository.query([nil, RDF::DOAP.developer, nil])
279
- # repository.query(:predicate => RDF::DOAP.developer)
278
+ # repository.query({predicate: RDF::DOAP.developer})
280
279
  #
281
280
  # @todo This should use basic SPARQL query mechanism.
282
281
  #
@@ -285,7 +284,7 @@ module SPARQL; class Client
285
284
  # @yield [statement]
286
285
  # @yieldparam [Statement]
287
286
  # @return [Enumerable<Statement>]
288
- def query_pattern(pattern, options = {}, &block)
287
+ def query_pattern(pattern, **options, &block)
289
288
  pattern = pattern.dup
290
289
  pattern.subject ||= RDF::Query::Variable.new
291
290
  pattern.predicate ||= RDF::Query::Variable.new
@@ -346,4 +345,4 @@ module SPARQL; class Client
346
345
  end
347
346
 
348
347
  end
349
- end; end
348
+ end
@@ -12,12 +12,12 @@ class SPARQL::Client
12
12
  # insert_data(data)
13
13
  #
14
14
  # @example INSERT DATA \{ GRAPH <http://example.org/> \{\}\}
15
- # insert_data(RDF::Graph.new, :graph => 'http://example.org/')
15
+ # insert_data(RDF::Graph.new, graph: 'http://example.org/')
16
16
  # insert_data(RDF::Graph.new).graph('http://example.org/')
17
17
  #
18
18
  # @param (see InsertData#initialize)
19
- def self.insert_data(*arguments)
20
- InsertData.new(*arguments)
19
+ def self.insert_data(*arguments, **options)
20
+ InsertData.new(*arguments, **options)
21
21
  end
22
22
 
23
23
  ##
@@ -30,12 +30,12 @@ class SPARQL::Client
30
30
  # delete_data(data)
31
31
  #
32
32
  # @example DELETE DATA \{ GRAPH <http://example.org/> \{\}\}
33
- # delete_data(RDF::Graph.new, :graph => 'http://example.org/')
33
+ # delete_data(RDF::Graph.new, graph: 'http://example.org/')
34
34
  # delete_data(RDF::Graph.new).graph('http://example.org/')
35
35
  #
36
36
  # @param (see DeleteData#initialize)
37
- def self.delete_data(*arguments)
38
- DeleteData.new(*arguments)
37
+ def self.delete_data(*arguments, **options)
38
+ DeleteData.new(*arguments, **options)
39
39
  end
40
40
 
41
41
  ##
@@ -53,8 +53,8 @@ class SPARQL::Client
53
53
  # load(RDF::URI(http://example.org/data.rdf), into: RDF::URI(http://example.org/data.rdf))
54
54
  #
55
55
  # @param (see Load#initialize)
56
- def self.load(*arguments)
57
- Load.new(*arguments)
56
+ def self.load(*arguments, **options)
57
+ Load.new(*arguments, **options)
58
58
  end
59
59
 
60
60
  ##
@@ -81,8 +81,8 @@ class SPARQL::Client
81
81
  # clear(:all, silent: true)
82
82
  #
83
83
  # @param (see Clear#initialize)
84
- def self.clear(*arguments)
85
- Clear.new(*arguments)
84
+ def self.clear(*arguments, **options)
85
+ Clear.new(*arguments, **options)
86
86
  end
87
87
 
88
88
  ##
@@ -96,8 +96,8 @@ class SPARQL::Client
96
96
  # create(RDF::URI(http://example.org/data.rdf), silent: true)
97
97
  #
98
98
  # @param (see Create#initialize)
99
- def self.create(*arguments)
100
- Create.new(*arguments)
99
+ def self.create(*arguments, **options)
100
+ Create.new(*arguments, **options)
101
101
  end
102
102
 
103
103
  ##
@@ -124,15 +124,15 @@ class SPARQL::Client
124
124
  # drop(:all, silent: true)
125
125
  #
126
126
  # @param (see Drop#initialize)
127
- def self.drop(*arguments)
128
- Drop.new(*arguments)
127
+ def self.drop(*arguments, **options)
128
+ Drop.new(*arguments, **options)
129
129
  end
130
130
 
131
131
  class Operation
132
132
  attr_reader :options
133
133
 
134
- def initialize(*arguments)
135
- @options = arguments.last.is_a?(Hash) ? arguments.pop.dup : {}
134
+ def initialize(*arguments, **options)
135
+ @options = options.dup
136
136
  unless arguments.empty?
137
137
  send(arguments.shift, *arguments)
138
138
  end
@@ -155,7 +155,7 @@ class SPARQL::Client
155
155
  end
156
156
 
157
157
  ##
158
- # @see http://www.w3.org/TR/sparql11-update/#insertData
158
+ # @see https://www.w3.org/TR/sparql11-update/#insertData
159
159
  class InsertData < Operation
160
160
  # @return [RDF::Enumerable]
161
161
  attr_reader :data
@@ -171,9 +171,9 @@ class SPARQL::Client
171
171
  #
172
172
  # @param [Array<RDF::Statement>, RDF::Enumerable] data
173
173
  # @param [Hash{Symbol => Object}] options
174
- def initialize(data, options = {})
174
+ def initialize(data, **options)
175
175
  @data = data
176
- super(options)
176
+ super(**options)
177
177
  end
178
178
 
179
179
  ##
@@ -205,7 +205,7 @@ class SPARQL::Client
205
205
  end
206
206
 
207
207
  ##
208
- # @see http://www.w3.org/TR/sparql11-update/#deleteData
208
+ # @see https://www.w3.org/TR/sparql11-update/#deleteData
209
209
  class DeleteData < Operation
210
210
  # @return [RDF::Enumerable]
211
211
  attr_reader :data
@@ -221,9 +221,9 @@ class SPARQL::Client
221
221
  #
222
222
  # @param [Array<RDF::Statement>, RDF::Enumerable] data
223
223
  # @param [Hash{Symbol => Object}] options
224
- def initialize(data, options = {})
224
+ def initialize(data, **options)
225
225
  @data = data
226
- super(options)
226
+ super(**options)
227
227
  end
228
228
 
229
229
  ##
@@ -247,17 +247,17 @@ class SPARQL::Client
247
247
  end
248
248
 
249
249
  ##
250
- # @see http://www.w3.org/TR/sparql11-update/#deleteInsert
250
+ # @see https://www.w3.org/TR/sparql11-update/#deleteInsert
251
251
  class DeleteInsert < Operation
252
252
  attr_reader :insert_graph
253
253
  attr_reader :delete_graph
254
254
  attr_reader :where_graph
255
255
 
256
- def initialize(_delete_graph, _insert_graph = nil, _where_graph = nil, options = {})
256
+ def initialize(_delete_graph, _insert_graph = nil, _where_graph = nil, **options)
257
257
  @delete_graph = _delete_graph
258
258
  @insert_graph = _insert_graph
259
259
  @where_graph = _where_graph
260
- super(options)
260
+ super(**options)
261
261
  end
262
262
 
263
263
  ##
@@ -301,7 +301,7 @@ class SPARQL::Client
301
301
  end
302
302
 
303
303
  ##
304
- # @see http://www.w3.org/TR/sparql11-update/#load
304
+ # @see https://www.w3.org/TR/sparql11-update/#load
305
305
  class Load < Operation
306
306
  attr_reader :from
307
307
  attr_reader :into
@@ -324,11 +324,10 @@ class SPARQL::Client
324
324
  # @param [Hash{Symbol => Object}] options
325
325
  # @option [RDF::URI] :into
326
326
  # @option [Boolean] :silent
327
- def initialize(from, options = {})
328
- options = options.dup
327
+ def initialize(from, into: nil,**options)
329
328
  @from = RDF::URI(from)
330
- @into = RDF::URI(options.delete(:into)) if options[:into]
331
- super(options)
329
+ @into = RDF::URI(into) if into
330
+ super(**options)
332
331
  end
333
332
 
334
333
  ##
@@ -351,7 +350,7 @@ class SPARQL::Client
351
350
  end
352
351
 
353
352
  ##
354
- # @see http://www.w3.org/TR/sparql11-update/#clear
353
+ # @see https://www.w3.org/TR/sparql11-update/#clear
355
354
  class Clear < Operation
356
355
  attr_reader :uri
357
356
 
@@ -415,14 +414,14 @@ class SPARQL::Client
415
414
  end
416
415
 
417
416
  ##
418
- # @see http://www.w3.org/TR/sparql11-update/#create
417
+ # @see https://www.w3.org/TR/sparql11-update/#create
419
418
  class Create < Operation
420
419
  attr_reader :uri
421
420
 
422
421
  # @param [Hash{Symbol => Object}] options
423
- def initialize(uri, options = {})
422
+ def initialize(uri, **options)
424
423
  @uri = RDF::URI(uri)
425
- super(options)
424
+ super(**options)
426
425
  end
427
426
 
428
427
  def to_s
@@ -434,7 +433,7 @@ class SPARQL::Client
434
433
  end
435
434
 
436
435
  ##
437
- # @see http://www.w3.org/TR/sparql11-update/#drop
436
+ # @see https://www.w3.org/TR/sparql11-update/#drop
438
437
  class Drop < Clear
439
438
  def to_s
440
439
  query_text = 'DROP '
@@ -451,7 +450,7 @@ class SPARQL::Client
451
450
  end
452
451
 
453
452
  ##
454
- # @see http://www.w3.org/TR/sparql11-update/#copy
453
+ # @see https://www.w3.org/TR/sparql11-update/#copy
455
454
  class Copy < Operation
456
455
  def to_s
457
456
  # TODO
@@ -459,7 +458,7 @@ class SPARQL::Client
459
458
  end
460
459
 
461
460
  ##
462
- # @see http://www.w3.org/TR/sparql11-update/#move
461
+ # @see https://www.w3.org/TR/sparql11-update/#move
463
462
  class Move < Operation
464
463
  def to_s
465
464
  # TODO
@@ -467,7 +466,7 @@ class SPARQL::Client
467
466
  end
468
467
 
469
468
  ##
470
- # @see http://www.w3.org/TR/sparql11-update/#add
469
+ # @see https://www.w3.org/TR/sparql11-update/#add
471
470
  class Add < Operation
472
471
  def to_s
473
472
  # TODO
@@ -1,4 +1,4 @@
1
- module SPARQL; class Client
1
+ class SPARQL::Client
2
2
  module VERSION
3
3
  FILE = File.expand_path('../../../../VERSION', __FILE__)
4
4
  MAJOR, MINOR, TINY, EXTRA = File.read(FILE).chomp.split('.')
@@ -16,4 +16,4 @@ module SPARQL; class Client
16
16
  # @return [Array(Integer, Integer, Integer)]
17
17
  def self.to_a() [MAJOR, MINOR, TINY] end
18
18
  end
19
- end; end
19
+ end
metadata CHANGED
@@ -1,139 +1,121 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparql-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
8
  - Ben Lavender
9
9
  - Gregg Kellogg
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-12-13 00:00:00.000000000 Z
13
+ date: 2021-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdf
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '2.2'
22
- - - "<"
19
+ - - "~>"
23
20
  - !ruby/object:Gem::Version
24
- version: '4.0'
21
+ version: '3.1'
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: '2.2'
32
- - - "<"
26
+ - - "~>"
33
27
  - !ruby/object:Gem::Version
34
- version: '4.0'
28
+ version: '3.1'
35
29
  - !ruby/object:Gem::Dependency
36
30
  name: net-http-persistent
37
31
  requirement: !ruby/object:Gem::Requirement
38
32
  requirements:
39
- - - ">="
33
+ - - "~>"
40
34
  - !ruby/object:Gem::Version
41
- version: '2.9'
42
- - - "<"
35
+ version: '4.0'
36
+ - - ">="
43
37
  - !ruby/object:Gem::Version
44
- version: '4'
38
+ version: 4.0.1
45
39
  type: :runtime
46
40
  prerelease: false
47
41
  version_requirements: !ruby/object:Gem::Requirement
48
42
  requirements:
49
- - - ">="
43
+ - - "~>"
50
44
  - !ruby/object:Gem::Version
51
- version: '2.9'
52
- - - "<"
45
+ version: '4.0'
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
- version: '4'
48
+ version: 4.0.1
55
49
  - !ruby/object:Gem::Dependency
56
- name: sparql
50
+ name: rdf-spec
57
51
  requirement: !ruby/object:Gem::Requirement
58
52
  requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '2.2'
62
- - - "<"
53
+ - - "~>"
63
54
  - !ruby/object:Gem::Version
64
- version: '4.0'
55
+ version: '3.1'
65
56
  type: :development
66
57
  prerelease: false
67
58
  version_requirements: !ruby/object:Gem::Requirement
68
59
  requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '2.2'
72
- - - "<"
60
+ - - "~>"
73
61
  - !ruby/object:Gem::Version
74
- version: '4.0'
62
+ version: '3.1'
75
63
  - !ruby/object:Gem::Dependency
76
- name: rdf-spec
64
+ name: sparql
77
65
  requirement: !ruby/object:Gem::Requirement
78
66
  requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '2.2'
82
- - - "<"
67
+ - - "~>"
83
68
  - !ruby/object:Gem::Version
84
- version: '4.0'
69
+ version: '3.1'
85
70
  type: :development
86
71
  prerelease: false
87
72
  version_requirements: !ruby/object:Gem::Requirement
88
73
  requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '2.2'
92
- - - "<"
74
+ - - "~>"
93
75
  - !ruby/object:Gem::Version
94
- version: '4.0'
76
+ version: '3.1'
95
77
  - !ruby/object:Gem::Dependency
96
78
  name: rspec
97
79
  requirement: !ruby/object:Gem::Requirement
98
80
  requirements:
99
81
  - - "~>"
100
82
  - !ruby/object:Gem::Version
101
- version: '3.7'
83
+ version: '3.10'
102
84
  type: :development
103
85
  prerelease: false
104
86
  version_requirements: !ruby/object:Gem::Requirement
105
87
  requirements:
106
88
  - - "~>"
107
89
  - !ruby/object:Gem::Version
108
- version: '3.7'
90
+ version: '3.10'
109
91
  - !ruby/object:Gem::Dependency
110
92
  name: rspec-its
111
93
  requirement: !ruby/object:Gem::Requirement
112
94
  requirements:
113
95
  - - "~>"
114
96
  - !ruby/object:Gem::Version
115
- version: '1.2'
97
+ version: '1.3'
116
98
  type: :development
117
99
  prerelease: false
118
100
  version_requirements: !ruby/object:Gem::Requirement
119
101
  requirements:
120
102
  - - "~>"
121
103
  - !ruby/object:Gem::Version
122
- version: '1.2'
104
+ version: '1.3'
123
105
  - !ruby/object:Gem::Dependency
124
106
  name: webmock
125
107
  requirement: !ruby/object:Gem::Requirement
126
108
  requirements:
127
109
  - - "~>"
128
110
  - !ruby/object:Gem::Version
129
- version: '3.0'
111
+ version: '3.11'
130
112
  type: :development
131
113
  prerelease: false
132
114
  version_requirements: !ruby/object:Gem::Requirement
133
115
  requirements:
134
116
  - - "~>"
135
117
  - !ruby/object:Gem::Version
136
- version: '3.0'
118
+ version: '3.11'
137
119
  - !ruby/object:Gem::Dependency
138
120
  name: yard
139
121
  requirement: !ruby/object:Gem::Requirement
@@ -168,11 +150,11 @@ files:
168
150
  - lib/sparql/client/repository.rb
169
151
  - lib/sparql/client/update.rb
170
152
  - lib/sparql/client/version.rb
171
- homepage: http://ruby-rdf.github.com/sparql-client/
153
+ homepage: https://github.com/ruby-rdf/sparql-client/
172
154
  licenses:
173
155
  - Unlicense
174
156
  metadata: {}
175
- post_install_message:
157
+ post_install_message:
176
158
  rdoc_options: []
177
159
  require_paths:
178
160
  - lib
@@ -180,16 +162,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
162
  requirements:
181
163
  - - ">="
182
164
  - !ruby/object:Gem::Version
183
- version: 2.2.2
165
+ version: '2.4'
184
166
  required_rubygems_version: !ruby/object:Gem::Requirement
185
167
  requirements:
186
168
  - - ">="
187
169
  - !ruby/object:Gem::Version
188
170
  version: '0'
189
171
  requirements: []
190
- rubyforge_project:
191
- rubygems_version: 2.6.14
192
- signing_key:
172
+ rubygems_version: 3.2.3
173
+ signing_key:
193
174
  specification_version: 4
194
175
  summary: SPARQL client for RDF.rb.
195
176
  test_files: []