rest 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 0
4
- :patch: 2
3
+ :minor: 1
4
+ :patch: 0
5
5
  :build:
@@ -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/typhoeus_wrapper'
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rest"
8
- s.version = "0.0.2"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis Reeder"]
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.2
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: &17129060 !ruby/object:Gem::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: *17129060
24
+ version_requirements: *13281860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &17128580 !ruby/object:Gem::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: *17128580
35
+ version_requirements: *13281380
36
36
  description: Rest client wrapper that chooses best installed client.
37
37
  email: travis@iron.io
38
38
  executables: []