lucid_works 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/lucid_works/base.rb +32 -10
- data/lib/lucid_works/patch_restclient.rb +16 -0
- data/lib/lucid_works/version.rb +1 -1
- metadata +2 -2
data/lib/lucid_works/base.rb
CHANGED
|
@@ -132,9 +132,15 @@ module LucidWorks
|
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
raw_response = ActiveSupport::Notifications.instrument("lucid_works.request") do |payload|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
begin
|
|
136
|
+
payload[:method] = :get
|
|
137
|
+
payload[:uri] = url
|
|
138
|
+
payload[:response] = RestClient.get(url)
|
|
139
|
+
rescue RestClient::Exception => exception
|
|
140
|
+
# Tack on what we were doing when we got the exception, then send it on up
|
|
141
|
+
exception.message = "#{exception.message} while performing #{payload[:method]} #{payload[:uri]}"
|
|
142
|
+
raise exception
|
|
143
|
+
end
|
|
138
144
|
end
|
|
139
145
|
|
|
140
146
|
data = JSON.parse(raw_response)
|
|
@@ -173,9 +179,15 @@ module LucidWorks
|
|
|
173
179
|
if kind_of_find == :all && association_info[:supports_all]
|
|
174
180
|
all_targets_path = "#{collection_url(parent)}/all/#{target_name}"
|
|
175
181
|
raw_response = ActiveSupport::Notifications.instrument("lucid_works.request") do |payload|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
182
|
+
begin
|
|
183
|
+
payload[:method] = :get
|
|
184
|
+
payload[:uri] = all_targets_path
|
|
185
|
+
payload[:response] = RestClient.get(all_targets_path)
|
|
186
|
+
rescue RestClient::Exception => exception
|
|
187
|
+
# Tack on what we were doing when we got the exception, then send it on up
|
|
188
|
+
exception.message = "#{exception.message} while performing #{payload[:method]} #{payload[:uri]}"
|
|
189
|
+
raise exception
|
|
190
|
+
end
|
|
179
191
|
end
|
|
180
192
|
if association_info[:type] == :has_one
|
|
181
193
|
all_targets_attributes = JSON.parse raw_response
|
|
@@ -321,6 +333,10 @@ module LucidWorks
|
|
|
321
333
|
payload[:exception] = e
|
|
322
334
|
attach_errors_to_model(e.response)
|
|
323
335
|
false
|
|
336
|
+
rescue RestClient::Exception => exception
|
|
337
|
+
# Tack on what we were doing when we got the exception, then send it on up
|
|
338
|
+
exception.message = "#{exception.message} while performing #{payload[:method]} #{payload[:uri]}"
|
|
339
|
+
raise exception
|
|
324
340
|
end
|
|
325
341
|
end
|
|
326
342
|
end
|
|
@@ -336,10 +352,16 @@ module LucidWorks
|
|
|
336
352
|
|
|
337
353
|
def destroy(options={})
|
|
338
354
|
ActiveSupport::Notifications.instrument("lucid_works.request") do |payload|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
355
|
+
begin
|
|
356
|
+
payload[:method] = :delete
|
|
357
|
+
payload[:uri] = member_url
|
|
358
|
+
payload[:options] = options
|
|
359
|
+
payload[:repsonse] = RestClient.delete(member_url, options)
|
|
360
|
+
rescue RestClient::Exception => exception
|
|
361
|
+
# Tack on what we were doing when we got the exception, then send it on up
|
|
362
|
+
exception.message = "#{exception.message} while performing #{payload[:method]} #{payload[:uri]}"
|
|
363
|
+
raise exception
|
|
364
|
+
end
|
|
343
365
|
end
|
|
344
366
|
end
|
|
345
367
|
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
module RestClient #:nodoc:
|
|
2
|
+
|
|
3
|
+
STATUSES.each_pair do |code, message|
|
|
4
|
+
|
|
5
|
+
# Compatibility
|
|
6
|
+
superclass = ([304, 401, 404].include? code) ? ExceptionWithResponse : RequestFailed
|
|
7
|
+
klass = Class.new(superclass) do
|
|
8
|
+
# LucidWorks: RestClient is kinda obnoxious and replaces the exception getter :message
|
|
9
|
+
# with a method returning a static string. Make it return @message if it is set.
|
|
10
|
+
send(:define_method, :message) {@message || "#{http_code ? "#{http_code} " : ''}#{message}"}
|
|
11
|
+
# send(:define_method, :message) {"#{http_code ? "#{http_code} " : ''}#{message}"}
|
|
12
|
+
end
|
|
13
|
+
remove_const message.delete(' \-\'') # LucidWorks
|
|
14
|
+
klass_constant = const_set message.delete(' \-\''), klass
|
|
15
|
+
Exceptions::EXCEPTIONS_MAP[code] = klass_constant
|
|
16
|
+
end
|
|
17
|
+
|
|
2
18
|
class Request #:nodoc:
|
|
3
19
|
|
|
4
20
|
# Extract the query parameters for get request and append them to the url
|
data/lib/lucid_works/version.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: lucid_works
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.6.
|
|
5
|
+
version: 0.6.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Sam Pierson
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-05-05 00:00:00 -07:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|