grel 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/grel/base.rb +23 -23
  2. metadata +1 -1
data/lib/grel/base.rb CHANGED
@@ -4,31 +4,31 @@ module GRel
4
4
 
5
5
  include Stardog
6
6
 
7
- attr_accessor :stardog, :last_query_context
7
+ attr_accessor :connection, :last_query_context
8
8
  attr_reader :db_name, :schema_graph
9
9
 
10
10
  def initialize(endpoint, options)
11
11
  @options = options
12
12
  @endpoint = endpoint
13
- @stardog = Stardog::stardog(endpoint,options)
13
+ @connection = stardog(endpoint,options)
14
14
  @validations = options[:validate] || false
15
- @dbs = @stardog.list_dbs.body["databases"]
15
+ @dbs = @connection.list_dbs.body["databases"]
16
16
  @reasoning = false
17
17
  self
18
18
  end
19
19
 
20
20
  def with_reasoning(reasoning="QL")
21
21
  @reasoning = true
22
- @stardog = Stardog::stardog(@endpoint,@options.merge(:reasoning => reasoning))
23
- @stardog.offline_db(@db_name)
24
- @stardog.set_db_options(@db_name, "icv.reasoning.type" => reasoning)
25
- @stardog.online_db(@db_name, 'WAIT')
22
+ @connection = stardog(@endpoint,@options.merge(:reasoning => reasoning))
23
+ @connection.offline_db(@db_name)
24
+ @connection.set_db_options(@db_name, "icv.reasoning.type" => reasoning)
25
+ @connection.online_db(@db_name, 'WAIT')
26
26
  self
27
27
  end
28
28
 
29
29
  def without_reasoning
30
30
  @reasoning = false
31
- @stardog = Stardog::stardog(@endpoint,@options)
31
+ @connection = stardog(@endpoint,@options)
32
32
  self
33
33
  end
34
34
 
@@ -56,7 +56,7 @@ module GRel
56
56
  GRel::Debugger.debug QL.to_turtle(data)
57
57
  GRel::Debugger.debug "IN"
58
58
  GRel::Debugger.debug @db_name
59
- @stardog.add(@db_name, QL.to_turtle(data), nil, "text/turtle")
59
+ @connection.add(@db_name, QL.to_turtle(data), nil, "text/turtle")
60
60
  end
61
61
  self
62
62
  rescue Stardog::ICVException => ex
@@ -111,7 +111,7 @@ module GRel
111
111
  GRel::Debugger.debug triples
112
112
  GRel::Debugger.debug "IN"
113
113
  GRel::Debugger.debug @db_name
114
- @stardog.add(@db_name, triples, @schema_graph, "text/turtle")
114
+ @connection.add(@db_name, triples, @schema_graph, "text/turtle")
115
115
  self
116
116
  end
117
117
 
@@ -126,7 +126,7 @@ module GRel
126
126
  GRel::Debugger.debug triples
127
127
  GRel::Debugger.debug "IN"
128
128
  GRel::Debugger.debug @db_name
129
- @stardog.remove(@db_name, triples, @schema_graph, "text/turtle")
129
+ @connection.remove(@db_name, triples, @schema_graph, "text/turtle")
130
130
  self
131
131
  end
132
132
 
@@ -148,7 +148,7 @@ module GRel
148
148
  GRel::Debugger.debug triples
149
149
  GRel::Debugger.debug "IN"
150
150
  GRel::Debugger.debug @db_name
151
- @stardog.add_icv(@db_name, triples, "text/turtle")
151
+ @connection.add_icv(@db_name, triples, "text/turtle")
152
152
  self
153
153
  end
154
154
 
@@ -161,7 +161,7 @@ module GRel
161
161
  GRel::Debugger.debug triples
162
162
  GRel::Debugger.debug "IN"
163
163
  GRel::Debugger.debug @db_name
164
- @stardog.remove_icv(@db_name, triples, "text/turtle")
164
+ @connection.remove_icv(@db_name, triples, "text/turtle")
165
165
  self
166
166
  end
167
167
 
@@ -171,15 +171,15 @@ module GRel
171
171
  GRel::Debugger.debug QL.to_turtle(data)
172
172
  GRel::Debugger.debug "IN"
173
173
  GRel::Debugger.debug @db_name
174
- @stardog.remove(@db_name, QL.to_turtle(data), nil, "text/turtle")
174
+ @connection.remove(@db_name, QL.to_turtle(data), nil, "text/turtle")
175
175
  else
176
176
  args = {:describe => true}
177
177
  args = {:accept => "application/rdf+xml"}
178
178
 
179
179
  sparql = @last_query_context.to_sparql_describe
180
- triples = @stardog.query(@db_name,sparql, args).body
180
+ triples = @connection.query(@db_name,sparql, args).body
181
181
 
182
- @stardog.remove(@db_name, triples, nil, "application/rdf+xml")
182
+ @connection.remove(@db_name, triples, nil, "application/rdf+xml")
183
183
  end
184
184
  self
185
185
  end
@@ -244,7 +244,7 @@ module GRel
244
244
  args[:accept] = options[:accept] if options[:accept]
245
245
  args[:offset] = @last_query_context.offset if @last_query_context.offset
246
246
  args[:limit] = @last_query_context.limit if @last_query_context.limit
247
- @stardog.query(@db_name,query, args).body
247
+ @connection.query(@db_name,query, args).body
248
248
  end
249
249
 
250
250
  def run_tuples(query, options = {})
@@ -257,14 +257,14 @@ module GRel
257
257
  args[:accept] = options[:accept] if options[:accept]
258
258
  args[:offset] = @last_query_context.offset if @last_query_context.offset
259
259
  args[:limit] = @last_query_context.limit if @last_query_context.limit
260
- @stardog.query(@db_name,query, args).body
260
+ @connection.query(@db_name,query, args).body
261
261
  end
262
262
 
263
263
  def with_validations(state = true)
264
264
  @validations = state
265
- @stardog.offline_db(@db_name)
266
- @stardog.set_db_options(@db_name, "icv.enabled" => @validations)
267
- @stardog.online_db(@db_name, 'WAIT')
265
+ @connection.offline_db(@db_name)
266
+ @connection.set_db_options(@db_name, "icv.enabled" => @validations)
267
+ @connection.online_db(@db_name, 'WAIT')
268
268
 
269
269
  self
270
270
  end
@@ -277,8 +277,8 @@ module GRel
277
277
 
278
278
  def ensure_db(db_name)
279
279
  unless(@dbs.include?(db_name))
280
- @stardog.create_db(db_name, :options => { "reasoning.schema.graphs" => "#{db_name}:schema" })
281
- @stardog.with_validations(@validations) if @validations == true
280
+ @connection.create_db(db_name, :options => { "reasoning.schema.graphs" => "#{db_name}:schema" })
281
+ @connection.with_validations(@validations) if @validations == true
282
282
  @dbs << db_name
283
283
  end
284
284
  yield if block_given?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: