you_got_listed 0.5.0 → 0.5.1

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/README.rdoc CHANGED
@@ -15,7 +15,7 @@ YouGotListings API documentation can be found here: http://www.yougotlistings.co
15
15
 
16
16
  In a rails 3 app
17
17
 
18
- gem 'you_got_listed', '~> 0.4.0'
18
+ gem 'you_got_listed', '~> 0.5.1'
19
19
 
20
20
  In a rails 2.3.x app (0.2.x only)
21
21
 
@@ -43,6 +43,11 @@ A client object is necessary for each request type. The client is the base clas
43
43
 
44
44
  ** For all operations the "key" required parameter is automatically passed so you never need to worry about this parameter as the client class includes it by default.
45
45
 
46
+ There is also an optional parameter to set the timeout in seconds, passing this will raise a Timeout::Error after that number of seconds
47
+
48
+ @ygl = YouGotListed::Client.new('you_api_key', 5) # raises a Timeout::Error after 5 seconds with no response
49
+
50
+
46
51
  === Searching Accounts
47
52
 
48
53
  To find all of the accounts that your API key can access call #search off the Accounts class:
@@ -5,15 +5,23 @@ module YouGotListed
5
5
  format :xml
6
6
  base_uri "https://www.yougotlistings.com/api"
7
7
 
8
- attr_accessor :api_key
8
+ attr_accessor :api_key, :http_timeout
9
9
 
10
- def initialize(api_key)
10
+ def initialize(api_key, http_timeout = nil)
11
+ self.http_timeout = http_timeout
11
12
  self.class.default_params :key => api_key
12
13
  end
13
14
 
14
15
  def perform_request(http_method, path, params = {})
15
16
  begin
16
- self.class.send(http_method, path, :query => params)
17
+ http_params = {}
18
+ unless params.blank?
19
+ http_params[:query] = params
20
+ end
21
+ unless self.http_timeout.nil?
22
+ http_params[:timeout] = self.http_timeout
23
+ end
24
+ self.class.send(http_method, path, http_params)
17
25
  rescue Timeout::Error
18
26
  {"YGLResponse" => {"responseCode" => "996", "Error" => "Timeout"}}
19
27
  rescue Exception
@@ -1,3 +1,3 @@
1
1
  module YouGotListed
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -4,6 +4,10 @@ def new_ygl
4
4
  YouGotListed::Client.new(YGL_API_KEY)
5
5
  end
6
6
 
7
+ def new_ygl_timeout_5
8
+ YouGotListed::Client.new(YGL_API_KEY, 5)
9
+ end
10
+
7
11
  def mock_get(base_uri, method, response_fixture, params = {})
8
12
  url = base_uri + method
9
13
  unless params.blank?
@@ -2,16 +2,40 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe YouGotListed::Client do
4
4
 
5
- before do
6
- @ygl = new_ygl
7
- end
5
+ context "standard" do
6
+ before do
7
+ @ygl = new_ygl
8
+ end
9
+
10
+ it "should set the api_key" do
11
+ @ygl.class.default_params.should == {:key => YGL_API_KEY}
12
+ end
13
+
14
+ it "should not set the timeout" do
15
+ @ygl.http_timeout.should == nil
16
+ end
8
17
 
9
- it "should set the api_key" do
10
- @ygl.class.default_params.should == {:key => YGL_API_KEY}
18
+ it "should set the base uri" do
19
+ @ygl.class.base_uri.should == "https://www.yougotlistings.com/api"
20
+ end
11
21
  end
12
22
 
13
- it "should set the base uri" do
14
- @ygl.class.base_uri.should == "https://www.yougotlistings.com/api"
23
+ context "timeout" do
24
+ before do
25
+ @ygl = new_ygl_timeout_5
26
+ end
27
+
28
+ it "should set the api_key" do
29
+ @ygl.class.default_params.should == {:key => YGL_API_KEY}
30
+ end
31
+
32
+ it "should set the timeout" do
33
+ @ygl.http_timeout.should == 5
34
+ end
35
+
36
+ it "should set the base uri" do
37
+ @ygl.class.base_uri.should == "https://www.yougotlistings.com/api"
38
+ end
15
39
  end
16
40
 
17
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: you_got_listed
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Cocca
@@ -19,7 +19,7 @@ date: 2011-04-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
@@ -28,12 +28,12 @@ dependencies:
28
28
  segments:
29
29
  - 3
30
30
  version: "3"
31
- version_requirements: *id001
32
- name: activesupport
31
+ requirement: *id001
33
32
  type: :runtime
33
+ name: activesupport
34
34
  prerelease: false
35
35
  - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
38
38
  requirements:
39
39
  - - ~>
@@ -44,12 +44,12 @@ dependencies:
44
44
  - 8
45
45
  - 3
46
46
  version: 0.8.3
47
- version_requirements: *id002
48
- name: httparty
47
+ requirement: *id002
49
48
  type: :runtime
49
+ name: httparty
50
50
  prerelease: false
51
51
  - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ">="
@@ -60,12 +60,12 @@ dependencies:
60
60
  - 3
61
61
  - 2
62
62
  version: 0.3.2
63
- version_requirements: *id003
64
- name: rash
63
+ requirement: *id003
65
64
  type: :runtime
65
+ name: rash
66
66
  prerelease: false
67
67
  - !ruby/object:Gem::Dependency
68
- requirement: &id004 !ruby/object:Gem::Requirement
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
71
71
  - - ">="
@@ -74,12 +74,12 @@ dependencies:
74
74
  segments:
75
75
  - 3
76
76
  version: "3"
77
- version_requirements: *id004
78
- name: will_paginate
77
+ requirement: *id004
79
78
  type: :runtime
79
+ name: will_paginate
80
80
  prerelease: false
81
81
  - !ruby/object:Gem::Dependency
82
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -90,12 +90,12 @@ dependencies:
90
90
  - 9
91
91
  - 2
92
92
  version: 0.9.2
93
- version_requirements: *id005
94
- name: rake
93
+ requirement: *id005
95
94
  type: :development
95
+ name: rake
96
96
  prerelease: false
97
97
  - !ruby/object:Gem::Dependency
98
- requirement: &id006 !ruby/object:Gem::Requirement
98
+ version_requirements: &id006 !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements:
101
101
  - - ">="
@@ -106,12 +106,12 @@ dependencies:
106
106
  - 5
107
107
  - 0
108
108
  version: 2.5.0
109
- version_requirements: *id006
110
- name: rspec
109
+ requirement: *id006
111
110
  type: :development
111
+ name: rspec
112
112
  prerelease: false
113
113
  - !ruby/object:Gem::Dependency
114
- requirement: &id007 !ruby/object:Gem::Requirement
114
+ version_requirements: &id007 !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
117
117
  - - ">="
@@ -122,12 +122,12 @@ dependencies:
122
122
  - 6
123
123
  - 2
124
124
  version: 1.6.2
125
- version_requirements: *id007
126
- name: webmock
125
+ requirement: *id007
127
126
  type: :development
127
+ name: webmock
128
128
  prerelease: false
129
129
  - !ruby/object:Gem::Dependency
130
- requirement: &id008 !ruby/object:Gem::Requirement
130
+ version_requirements: &id008 !ruby/object:Gem::Requirement
131
131
  none: false
132
132
  requirements:
133
133
  - - ">="
@@ -138,9 +138,9 @@ dependencies:
138
138
  - 8
139
139
  - 0
140
140
  version: 1.8.0
141
- version_requirements: *id008
142
- name: vcr
141
+ requirement: *id008
143
142
  type: :development
143
+ name: vcr
144
144
  prerelease: false
145
145
  description: Ruby API wrapper for yougotlistings.com built with httparty
146
146
  email: tom.cocca@gmail.com