adility 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency('fakeweb')
21
21
  s.add_development_dependency('yard', '~> 0.6')
22
22
  s.add_development_dependency('maruku', '~> 0.6')
23
+ s.add_development_dependency('awesome_print', '~> 0.3.2')
23
24
  s.add_runtime_dependency("faraday", '~> 0.5.7')
24
25
  s.add_runtime_dependency("faraday_middleware", '~> 0.3.2')
25
26
  s.add_runtime_dependency("typhoeus", '~> 0.2.4')
@@ -15,7 +15,7 @@ module Adility
15
15
  @api_key = args[0]
16
16
  @conn = Faraday.new(:url => "https://testapi.offersdb.com") do |builder|
17
17
  builder.adapter Faraday.default_adapter
18
- builder.adapter :logger #if options[:debug] == true
18
+ builder.adapter :logger # if options[:debug] == true
19
19
  builder.use Faraday::Response::ParseJson
20
20
  builder.use Faraday::Response::Mashify
21
21
  end
@@ -31,12 +31,18 @@ module Adility
31
31
  req.headers['X-OFFERSDB-API-KEY'] = api_key
32
32
  req.params = options
33
33
  end
34
+ require 'pp'
35
+ pp response.body
36
+ total_pages = response.body.send :total_pages
37
+ total_items = response.body.send :total_items
38
+ page = response.body.send :page
34
39
  if args[0].nil?
35
40
  ret = response.body.send sym
41
+ return ret, page, total_pages
36
42
  else
37
43
  ret = response.body.send sym.to_s.chop
44
+ return ret
38
45
  end
39
- ret
40
46
  end
41
47
  end
42
48
  end
@@ -1,3 +1,3 @@
1
1
  module Adility
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+ require 'ap'
3
+
4
+ describe Adility::Client do
5
+ context "api" do
6
+ before(:all) do
7
+ api_key="47877649661a15f4cb70f0b88c7b1068"
8
+ @client = Adility::Client.new(api_key)
9
+ end
10
+ context "categories" do
11
+ context "list" do
12
+ use_vcr_cassette
13
+ before(:all) do
14
+ @categories = @client.categories
15
+ end
16
+ subject { @categories }
17
+ it { should_not be_nil }
18
+ it { should be_an(Array) }
19
+ it { should have_at_least(1).items }
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -1,9 +1,10 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
+ require 'ap'
2
3
 
3
4
  describe Adility::Client do
4
5
  context "api" do
5
6
  before(:all) do
6
- api_key=""
7
+ api_key="47877649661a15f4cb70f0b88c7b1068"
7
8
  @client = Adility::Client.new(api_key)
8
9
  end
9
10
  context "offers" do
@@ -11,12 +12,16 @@ describe Adility::Client do
11
12
  context "with zip" do
12
13
  use_vcr_cassette
13
14
  before(:all) do
14
- @offers = @client.offers(:zip => "94117", :distance => "100", :sort_by => :title)
15
+ @offers, @page, @total_pages = @client.offers(:zip => "94117", :distance => "10", :sort_by => :title, :types => 'deal')
16
+ require 'pp'
17
+ pp @offers
15
18
  end
16
19
  subject { @offers }
17
20
  it { should_not be_nil }
18
21
  it { should be_an(Array) }
19
22
  it { should have_at_least(1).items }
23
+ specify { @total_pages.should be >= 1 }
24
+ specify { @page.should be >= 1 }
20
25
  end
21
26
  end
22
27
  context "load individial" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: adility
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Deeden
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-22 00:00:00 -04:00
13
+ date: 2011-03-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -91,71 +91,82 @@ dependencies:
91
91
  type: :development
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
94
- name: faraday
94
+ name: awesome_print
95
95
  prerelease: false
96
96
  requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.3.2
102
+ type: :development
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: faraday
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
97
108
  none: false
98
109
  requirements:
99
110
  - - ~>
100
111
  - !ruby/object:Gem::Version
101
112
  version: 0.5.7
102
113
  type: :runtime
103
- version_requirements: *id008
114
+ version_requirements: *id009
104
115
  - !ruby/object:Gem::Dependency
105
116
  name: faraday_middleware
106
117
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
118
+ requirement: &id010 !ruby/object:Gem::Requirement
108
119
  none: false
109
120
  requirements:
110
121
  - - ~>
111
122
  - !ruby/object:Gem::Version
112
123
  version: 0.3.2
113
124
  type: :runtime
114
- version_requirements: *id009
125
+ version_requirements: *id010
115
126
  - !ruby/object:Gem::Dependency
116
127
  name: typhoeus
117
128
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
129
+ requirement: &id011 !ruby/object:Gem::Requirement
119
130
  none: false
120
131
  requirements:
121
132
  - - ~>
122
133
  - !ruby/object:Gem::Version
123
134
  version: 0.2.4
124
135
  type: :runtime
125
- version_requirements: *id010
136
+ version_requirements: *id011
126
137
  - !ruby/object:Gem::Dependency
127
138
  name: hashie
128
139
  prerelease: false
129
- requirement: &id011 !ruby/object:Gem::Requirement
140
+ requirement: &id012 !ruby/object:Gem::Requirement
130
141
  none: false
131
142
  requirements:
132
143
  - - ~>
133
144
  - !ruby/object:Gem::Version
134
145
  version: 1.0.0
135
146
  type: :runtime
136
- version_requirements: *id011
147
+ version_requirements: *id012
137
148
  - !ruby/object:Gem::Dependency
138
149
  name: yajl-ruby
139
150
  prerelease: false
140
- requirement: &id012 !ruby/object:Gem::Requirement
151
+ requirement: &id013 !ruby/object:Gem::Requirement
141
152
  none: false
142
153
  requirements:
143
154
  - - ~>
144
155
  - !ruby/object:Gem::Version
145
156
  version: 0.8.1
146
157
  type: :runtime
147
- version_requirements: *id012
158
+ version_requirements: *id013
148
159
  - !ruby/object:Gem::Dependency
149
160
  name: multi_json
150
161
  prerelease: false
151
- requirement: &id013 !ruby/object:Gem::Requirement
162
+ requirement: &id014 !ruby/object:Gem::Requirement
152
163
  none: false
153
164
  requirements:
154
165
  - - ~>
155
166
  - !ruby/object:Gem::Version
156
167
  version: 0.0.5
157
168
  type: :runtime
158
- version_requirements: *id013
169
+ version_requirements: *id014
159
170
  description: A wrapper for the Adility API
160
171
  email:
161
172
  - jdeeden@gmail.com
@@ -175,6 +186,7 @@ files:
175
186
  - lib/adility/version.rb
176
187
  - lib/core_ext/array.rb
177
188
  - lib/faraday/patch.rb
189
+ - spec/categories/categories_spec.rb
178
190
  - spec/offers/offers_spec.rb
179
191
  - spec/spec_helper.rb
180
192
  has_rdoc: true
@@ -206,5 +218,6 @@ signing_key:
206
218
  specification_version: 3
207
219
  summary: A wrapper for the Adility API
208
220
  test_files:
221
+ - spec/categories/categories_spec.rb
209
222
  - spec/offers/offers_spec.rb
210
223
  - spec/spec_helper.rb