stardog-rb 0.0.2 → 0.0.3

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/stardog.rb +14 -8
  2. metadata +4 -1
data/lib/stardog.rb CHANGED
@@ -79,6 +79,10 @@ module Stardog
79
79
  def to_s
80
80
  @attributes.to_json
81
81
  end
82
+
83
+ def method_missing(meth, *args, &block)
84
+ @attributes.send(meth, *args, &block) if @attributes.respond_to?(meth)
85
+ end
82
86
  end
83
87
 
84
88
 
@@ -137,13 +141,16 @@ module Stardog
137
141
 
138
142
  def add(database, body, graph_uri=nil, content_type="text/plain")
139
143
  with_transaction(database) do |txId|
140
- add_in_transaction(database, txId, body, graph_uri, content_type)
144
+ result = add_in_transaction(database, txId, body, graph_uri, content_type)
145
+ raise Exception.new("Error adding data to database #{database} -> #{result.body}") unless(result.success?)
146
+ result
141
147
  end
142
148
  end
143
149
 
144
150
  def remove(database, body, graph_uri=nil, content_type="text/plain")
145
151
  with_transaction(database) do |txId|
146
- remove_in_transaction(database, txId, body, graph_uri, content_type)
152
+ result = remove_in_transaction(database, txId, body, graph_uri, content_type)
153
+ raise Exception.new("Error removing data to database #{database} -> #{result.body}") unless(result.success?)
147
154
  end
148
155
  end
149
156
 
@@ -215,7 +222,7 @@ module Stardog
215
222
  debug ex.message
216
223
  debug ex.backtrace.join("\n")
217
224
  rollback(db_name, txID)
218
- false
225
+ raise ex
219
226
  end
220
227
  end
221
228
 
@@ -225,8 +232,10 @@ module Stardog
225
232
  offset = options[:offset]
226
233
  accept = options[:accept]
227
234
  ask_request = options.delete(:ask)
235
+ describe_request = options.delete(:describe)
228
236
 
229
237
  accept = 'text/boolean' if(ask_request)
238
+ accept = 'application/ld+json' if(describe_request)
230
239
  accept_header = accept ? accept : 'application/sparql-results+json'
231
240
 
232
241
  options = {
@@ -429,10 +438,7 @@ module Stardog
429
438
  arguments[:headers]["SD-Connection-String"] = "reasoning=#{@reasoning}"
430
439
  end
431
440
 
432
- #arguments.merge!(credentials) if credentials
433
- if credentials
434
- arguments[:url].gsub!("http://","http://#{credentials[:user]}:#{credentials[:password]}@")
435
- end
441
+ arguments.merge!(credentials) if credentials
436
442
 
437
443
  arguments[:payload] = msg_body if msg_body
438
444
 
@@ -491,7 +497,7 @@ module Stardog
491
497
  end
492
498
 
493
499
  rescue => exception
494
- if(exception.respond_to?(:response))
500
+ if(exception.respond_to?(:response) && exception.response)
495
501
  debug "RESPONSE:"
496
502
  debug exception.response.code
497
503
  debug "---"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stardog-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -63,6 +63,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
+ segments:
67
+ - 0
68
+ hash: -4293871523762893836
66
69
  required_rubygems_version: !ruby/object:Gem::Requirement
67
70
  none: false
68
71
  requirements: