itunes 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/README.md +11 -9
- data/itunes.gemspec +7 -9
- data/lib/itunes.rb +11 -6
- data/lib/itunes/client/lookup.rb +40 -3
- data/lib/itunes/client/search.rb +28 -14
- data/lib/itunes/request.rb +3 -3
- data/lib/itunes/version.rb +1 -1
- data/spec/fixtures/ITunes_Client.yml +1113 -512
- data/spec/itunes/client_spec.rb +75 -47
- data/spec/itunes_spec.rb +17 -2
- metadata +17 -117
- data/lib/faraday/rashify.rb +0 -30
- data/spec/faraday/rashify_spec.rb +0 -17
- data/spec/fixtures/Faraday_Response_Rashify.yml +0 -46
data/spec/itunes/client_spec.rb
CHANGED
@@ -1,77 +1,87 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ITunes::Client do
|
4
|
+
before(:each) do
|
5
|
+
@client = ITunes::Client.new
|
6
|
+
end
|
4
7
|
|
5
8
|
use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method]
|
6
9
|
|
7
10
|
describe ".lookup" do
|
8
|
-
before(:each) do
|
9
|
-
@client = ITunes::Client.new
|
10
|
-
end
|
11
|
-
|
12
11
|
it "should return results for valid ids" do
|
13
12
|
item = @client.lookup('396405320')
|
14
13
|
item.results.first.collection_name.should == 'Hold it Down - Single'
|
15
14
|
item.results.first.primary_genre_name == 'Dance'
|
16
15
|
end
|
17
16
|
|
18
|
-
describe "when
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
describe "when passing an id_type other than amg or upc" do
|
18
|
+
it "should raise an error" do
|
19
|
+
lambda {
|
20
|
+
@client.lookup('1235', :id_type => :lastfm)
|
21
|
+
}.should raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
describe '.amg_artist' do
|
27
|
+
it "should return a valid item when passed a single id" do
|
28
|
+
items = @client.amg_artist('792844')
|
29
|
+
items.result_count.should == 1
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
32
|
+
it "should return results when passed a comma separated string of ids" do
|
33
|
+
items = @client.amg_artist('468749,5723')
|
34
|
+
items.result_count.should == 2
|
35
|
+
end
|
35
36
|
|
37
|
+
it "should return results when passed an array of ids" do
|
38
|
+
items = @client.amg_artist(['468749','5723'])
|
39
|
+
items.result_count.should == 2
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
+
it 'should be aliased as amg_artists' do
|
43
|
+
@client.amg_artist(['468749','5723']).should == @client.amg_artists(['468749','5723'])
|
44
|
+
end
|
45
|
+
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
describe '.amg_album' do
|
48
|
+
it "should return a valid item when passed a single id" do
|
49
|
+
items = @client.amg_album('15197')
|
50
|
+
items.results.first.artist_name.should == 'Wilson Pickett'
|
51
|
+
end
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
+
it "should return results when passed a comma separated string of ids" do
|
54
|
+
items = @client.amg_album('15197,15198')
|
55
|
+
items.results.first.artist_name.should == 'Wilson Pickett'
|
53
56
|
end
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
58
|
+
it "should return results when passed an array of ids" do
|
59
|
+
items = @client.amg_album(['15197','15198'])
|
60
|
+
items.results.first.artist_name.should == 'Wilson Pickett'
|
59
61
|
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
lambda {
|
64
|
-
@client.lookup('1235', :id_type => :lastfm)
|
65
|
-
}.should raise_error
|
66
|
-
end
|
63
|
+
it 'should be aliased as amg_albums' do
|
64
|
+
@client.amg_album(['15197','15198']).should == @client.amg_albums(['15197','15198'])
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
|
-
describe
|
71
|
-
|
72
|
-
|
68
|
+
describe '.upc' do
|
69
|
+
it "should return a valid item when passed a single id" do
|
70
|
+
item = @client.upc('5024545486520')
|
71
|
+
item.results.first.collection_name.should == 'Untrue'
|
72
|
+
item.results.first.artist_name.should == 'Burial'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '.isbn' do
|
77
|
+
it 'should return a valid item when passed a single id' do
|
78
|
+
item = @client.isbn('9780316069359')
|
79
|
+
item.results.first.kind.should == 'ebook'
|
80
|
+
item.results.first.track_name.should == 'The Fifth Witness'
|
73
81
|
end
|
82
|
+
end
|
74
83
|
|
84
|
+
describe "search" do
|
75
85
|
describe ".all" do
|
76
86
|
it "should raise an ArgumentError when passed a nil search term" do
|
77
87
|
lambda {
|
@@ -101,7 +111,7 @@ describe ITunes::Client do
|
|
101
111
|
it "should return music results" do
|
102
112
|
response = @client.music('Jose James')
|
103
113
|
response.results.each do |result|
|
104
|
-
|
114
|
+
['music-artist', 'music-track', 'album', 'music-video', 'mix', 'song'].should include(result.kind)
|
105
115
|
end
|
106
116
|
end
|
107
117
|
end
|
@@ -159,6 +169,24 @@ describe ITunes::Client do
|
|
159
169
|
end
|
160
170
|
end
|
161
171
|
end
|
172
|
+
|
173
|
+
describe ".software" do
|
174
|
+
it "should return tv show results" do
|
175
|
+
response = @client.software('Doodle Jump')
|
176
|
+
response.results.each do |result|
|
177
|
+
['software', 'iPadSoftware', 'macSoftware'].should include(result.kind)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe ".ebook" do
|
183
|
+
it "should return ebook results" do
|
184
|
+
response = @client.ebook('Alice in Wonderland')
|
185
|
+
response.results.each do |result|
|
186
|
+
result.kind.should == 'ebook'
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
162
190
|
end
|
163
191
|
|
164
192
|
end
|
data/spec/itunes_spec.rb
CHANGED
@@ -8,11 +8,27 @@ describe ITunes do
|
|
8
8
|
use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method]
|
9
9
|
|
10
10
|
context "when delegating to a client" do
|
11
|
-
|
12
11
|
it "should return the same results as a client" do
|
13
12
|
ITunes.music('Jose James').should == ITunes::Client.new.music('Jose James')
|
14
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.client' do
|
17
|
+
it 'should return and ITunes::Client' do
|
18
|
+
ITunes.client.should be_a ITunes::Client
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.respond_to?' do
|
23
|
+
it "should take an optional argument" do
|
24
|
+
ITunes.respond_to?(:new, true).should be_true
|
25
|
+
end
|
26
|
+
end
|
15
27
|
|
28
|
+
describe ".new" do
|
29
|
+
it "should return an ITunes::Client" do
|
30
|
+
ITunes.new.should be_a ITunes::Client
|
31
|
+
end
|
16
32
|
end
|
17
33
|
|
18
34
|
describe ".limit" do
|
@@ -42,7 +58,6 @@ describe ITunes do
|
|
42
58
|
end
|
43
59
|
|
44
60
|
describe ".configure" do
|
45
|
-
|
46
61
|
ITunes::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
47
62
|
it "should set the #{key}" do
|
48
63
|
ITunes.configure do |config|
|
metadata
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 13
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 1
|
10
|
-
version: 0.4.1
|
5
|
+
version: 0.5.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Garrett Bjerkhoel
|
9
|
+
- Steve Agalloco
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date: 2011-02
|
14
|
+
date: 2011-06-02 00:00:00 -04:00
|
19
15
|
default_executable:
|
20
16
|
dependencies:
|
21
17
|
- !ruby/object:Gem::Dependency
|
@@ -26,10 +22,6 @@ dependencies:
|
|
26
22
|
requirements:
|
27
23
|
- - ~>
|
28
24
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 15
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
25
|
version: "1.0"
|
34
26
|
type: :development
|
35
27
|
version_requirements: *id001
|
@@ -41,10 +33,6 @@ dependencies:
|
|
41
33
|
requirements:
|
42
34
|
- - ~>
|
43
35
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 27
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 8
|
48
36
|
version: "0.8"
|
49
37
|
type: :development
|
50
38
|
version_requirements: *id002
|
@@ -56,12 +44,7 @@ dependencies:
|
|
56
44
|
requirements:
|
57
45
|
- - ~>
|
58
46
|
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 2
|
62
|
-
- 5
|
63
|
-
- 0
|
64
|
-
version: 2.5.0
|
47
|
+
version: 2.6.0
|
65
48
|
type: :development
|
66
49
|
version_requirements: *id003
|
67
50
|
- !ruby/object:Gem::Dependency
|
@@ -72,11 +55,7 @@ dependencies:
|
|
72
55
|
requirements:
|
73
56
|
- - ~>
|
74
57
|
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 6
|
79
|
-
version: "0.6"
|
58
|
+
version: "0.7"
|
80
59
|
type: :development
|
81
60
|
version_requirements: *id004
|
82
61
|
- !ruby/object:Gem::Dependency
|
@@ -87,10 +66,6 @@ dependencies:
|
|
87
66
|
requirements:
|
88
67
|
- - ~>
|
89
68
|
- !ruby/object:Gem::Version
|
90
|
-
hash: 7
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
- 6
|
94
69
|
version: "0.6"
|
95
70
|
type: :development
|
96
71
|
version_requirements: *id005
|
@@ -102,11 +77,7 @@ dependencies:
|
|
102
77
|
requirements:
|
103
78
|
- - ~>
|
104
79
|
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
107
|
-
- 0
|
108
|
-
- 3
|
109
|
-
version: "0.3"
|
80
|
+
version: 0.4.2
|
110
81
|
type: :development
|
111
82
|
version_requirements: *id006
|
112
83
|
- !ruby/object:Gem::Dependency
|
@@ -117,10 +88,6 @@ dependencies:
|
|
117
88
|
requirements:
|
118
89
|
- - ~>
|
119
90
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
|
-
segments:
|
122
|
-
- 1
|
123
|
-
- 6
|
124
91
|
version: "1.6"
|
125
92
|
type: :development
|
126
93
|
version_requirements: *id007
|
@@ -132,110 +99,53 @@ dependencies:
|
|
132
99
|
requirements:
|
133
100
|
- - ~>
|
134
101
|
- !ruby/object:Gem::Version
|
135
|
-
hash: 7
|
136
|
-
segments:
|
137
|
-
- 1
|
138
|
-
- 4
|
139
|
-
- 0
|
140
102
|
version: 1.4.0
|
141
103
|
type: :development
|
142
104
|
version_requirements: *id008
|
143
105
|
- !ruby/object:Gem::Dependency
|
144
|
-
name:
|
106
|
+
name: hashie
|
145
107
|
prerelease: false
|
146
108
|
requirement: &id009 !ruby/object:Gem::Requirement
|
147
109
|
none: false
|
148
110
|
requirements:
|
149
111
|
- - ~>
|
150
112
|
- !ruby/object:Gem::Version
|
151
|
-
|
152
|
-
|
153
|
-
- 1
|
154
|
-
- 5
|
155
|
-
- 1
|
156
|
-
version: 1.5.1
|
157
|
-
type: :development
|
113
|
+
version: 1.0.0
|
114
|
+
type: :runtime
|
158
115
|
version_requirements: *id009
|
159
116
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
117
|
+
name: rash
|
161
118
|
prerelease: false
|
162
119
|
requirement: &id010 !ruby/object:Gem::Requirement
|
163
120
|
none: false
|
164
121
|
requirements:
|
165
122
|
- - ~>
|
166
123
|
- !ruby/object:Gem::Version
|
167
|
-
|
168
|
-
segments:
|
169
|
-
- 1
|
170
|
-
- 0
|
171
|
-
- 0
|
172
|
-
version: 1.0.0
|
124
|
+
version: 0.3.0
|
173
125
|
type: :runtime
|
174
126
|
version_requirements: *id010
|
175
127
|
- !ruby/object:Gem::Dependency
|
176
|
-
name:
|
128
|
+
name: faraday_middleware
|
177
129
|
prerelease: false
|
178
130
|
requirement: &id011 !ruby/object:Gem::Requirement
|
179
131
|
none: false
|
180
132
|
requirements:
|
181
133
|
- - ~>
|
182
134
|
- !ruby/object:Gem::Version
|
183
|
-
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
- 2
|
187
|
-
- 0
|
188
|
-
version: 0.2.0
|
135
|
+
version: 0.6.3
|
189
136
|
type: :runtime
|
190
137
|
version_requirements: *id011
|
191
138
|
- !ruby/object:Gem::Dependency
|
192
|
-
name:
|
139
|
+
name: multi_json
|
193
140
|
prerelease: false
|
194
141
|
requirement: &id012 !ruby/object:Gem::Requirement
|
195
142
|
none: false
|
196
143
|
requirements:
|
197
144
|
- - ~>
|
198
145
|
- !ruby/object:Gem::Version
|
199
|
-
|
200
|
-
segments:
|
201
|
-
- 0
|
202
|
-
- 5
|
203
|
-
- 4
|
204
|
-
version: 0.5.4
|
146
|
+
version: 1.0.3
|
205
147
|
type: :runtime
|
206
148
|
version_requirements: *id012
|
207
|
-
- !ruby/object:Gem::Dependency
|
208
|
-
name: faraday_middleware
|
209
|
-
prerelease: false
|
210
|
-
requirement: &id013 !ruby/object:Gem::Requirement
|
211
|
-
none: false
|
212
|
-
requirements:
|
213
|
-
- - ~>
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
hash: 17
|
216
|
-
segments:
|
217
|
-
- 0
|
218
|
-
- 3
|
219
|
-
- 1
|
220
|
-
version: 0.3.1
|
221
|
-
type: :runtime
|
222
|
-
version_requirements: *id013
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: multi_json
|
225
|
-
prerelease: false
|
226
|
-
requirement: &id014 !ruby/object:Gem::Requirement
|
227
|
-
none: false
|
228
|
-
requirements:
|
229
|
-
- - ~>
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
hash: 21
|
232
|
-
segments:
|
233
|
-
- 0
|
234
|
-
- 0
|
235
|
-
- 5
|
236
|
-
version: 0.0.5
|
237
|
-
type: :runtime
|
238
|
-
version_requirements: *id014
|
239
149
|
description:
|
240
150
|
email: me@garrettbjerkhoel.com
|
241
151
|
executables: []
|
@@ -246,6 +156,7 @@ extra_rdoc_files:
|
|
246
156
|
- MIT-LICENSE
|
247
157
|
- README.md
|
248
158
|
files:
|
159
|
+
- .gemtest
|
249
160
|
- .gitignore
|
250
161
|
- .rspec
|
251
162
|
- Gemfile
|
@@ -253,7 +164,6 @@ files:
|
|
253
164
|
- README.md
|
254
165
|
- Rakefile
|
255
166
|
- itunes.gemspec
|
256
|
-
- lib/faraday/rashify.rb
|
257
167
|
- lib/itunes.rb
|
258
168
|
- lib/itunes/client.rb
|
259
169
|
- lib/itunes/client/lookup.rb
|
@@ -261,8 +171,6 @@ files:
|
|
261
171
|
- lib/itunes/configuration.rb
|
262
172
|
- lib/itunes/request.rb
|
263
173
|
- lib/itunes/version.rb
|
264
|
-
- spec/faraday/rashify_spec.rb
|
265
|
-
- spec/fixtures/Faraday_Response_Rashify.yml
|
266
174
|
- spec/fixtures/ITunes.yml
|
267
175
|
- spec/fixtures/ITunes_Client.yml
|
268
176
|
- spec/itunes/client_spec.rb
|
@@ -282,29 +190,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
190
|
requirements:
|
283
191
|
- - ">="
|
284
192
|
- !ruby/object:Gem::Version
|
285
|
-
hash: 3
|
286
|
-
segments:
|
287
|
-
- 0
|
288
193
|
version: "0"
|
289
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
290
195
|
none: false
|
291
196
|
requirements:
|
292
197
|
- - ">="
|
293
198
|
- !ruby/object:Gem::Version
|
294
|
-
hash: 3
|
295
|
-
segments:
|
296
|
-
- 0
|
297
199
|
version: "0"
|
298
200
|
requirements: []
|
299
201
|
|
300
202
|
rubyforge_project: itunes
|
301
|
-
rubygems_version: 1.
|
203
|
+
rubygems_version: 1.6.1
|
302
204
|
signing_key:
|
303
205
|
specification_version: 3
|
304
206
|
summary: iTunes API
|
305
207
|
test_files:
|
306
|
-
- spec/faraday/rashify_spec.rb
|
307
|
-
- spec/fixtures/Faraday_Response_Rashify.yml
|
308
208
|
- spec/fixtures/ITunes.yml
|
309
209
|
- spec/fixtures/ITunes_Client.yml
|
310
210
|
- spec/itunes/client_spec.rb
|