rest 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/rest/client.rb +1 -1
- data/lib/rest/wrappers/rest_client_wrapper.rb +11 -0
- data/rest.gemspec +1 -1
- metadata +5 -5
data/VERSION.yml
CHANGED
data/lib/rest/client.rb
CHANGED
@@ -35,7 +35,7 @@ module Rest
|
|
35
35
|
puts "Could not load typhoeus. #{ex.class.name}: #{ex.message}. Falling back to rest-client. Please install 'typhoeus' gem for best performance."
|
36
36
|
require 'rest_client'
|
37
37
|
Rest.gem = :rest_client
|
38
|
-
require_relative 'wrappers/
|
38
|
+
require_relative 'wrappers/rest_client_wrapper'
|
39
39
|
end
|
40
40
|
|
41
41
|
|
@@ -27,14 +27,25 @@ module Rest
|
|
27
27
|
|
28
28
|
class RestClientWrapper
|
29
29
|
|
30
|
+
def default_headers
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
|
30
34
|
def get(url, req_hash={})
|
31
35
|
response = nil
|
32
36
|
begin
|
33
37
|
req_hash[:method] = :get
|
34
38
|
req_hash[:url] = url
|
39
|
+
req_hash[:headers] ||= default_headers
|
40
|
+
req_hash[:headers][:params] = req_hash[:params] if req_hash[:params]
|
41
|
+
#p req_hash
|
35
42
|
r2 = RestClient::Request.execute(req_hash)
|
36
43
|
response = RestClientResponseWrapper.new(r2)
|
37
44
|
rescue RestClient::Exception => ex
|
45
|
+
#p ex
|
46
|
+
if ex.http_code == 404
|
47
|
+
return RestClientResponseWrapper.new(ex.response)
|
48
|
+
end
|
38
49
|
raise RestClientExceptionWrapper.new(ex)
|
39
50
|
end
|
40
51
|
response
|
data/rest.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &13281860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13281860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rest-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &13281380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13281380
|
36
36
|
description: Rest client wrapper that chooses best installed client.
|
37
37
|
email: travis@iron.io
|
38
38
|
executables: []
|