itunes-search 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -11
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/itunes-search.gemspec +1 -1
- data/lib/itunes-search/base.rb +4 -8
- data/lib/itunes-search/search.rb +3 -5
- data/test/test_itunes-search.rb +5 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -7,20 +7,20 @@ This was created for use on musicxray.com if you think you can do better send yo
|
|
7
7
|
gem install itunes-search
|
8
8
|
|
9
9
|
== Usage
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
<code>
|
11
|
+
base = Itunes::Base.new
|
12
|
+
search_object = base.search("term"=>"The Killers")
|
13
|
+
</code>
|
14
14
|
|
15
15
|
# get an array of the search_objects
|
16
|
+
<code>
|
17
|
+
results = search_object.results
|
18
|
+
results.each do |result|
|
19
|
+
puts result.trackViewUrl
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
results.each do |result|
|
20
|
-
puts result.trackViewUrl
|
21
|
-
end
|
22
|
-
|
23
|
-
puts result.attributes
|
22
|
+
puts result.attributes
|
23
|
+
</code>
|
24
24
|
|
25
25
|
|
26
26
|
== Note on Patches/Pull Requests
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/itunes-search.gemspec
CHANGED
data/lib/itunes-search/base.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
module ItunesSearch
|
2
|
-
|
3
|
-
|
4
2
|
@endpoint = "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch"
|
5
|
-
|
6
3
|
def self.endpoint=(ep)
|
7
4
|
@endpoint = ep
|
8
5
|
end
|
9
6
|
def self.endpoint
|
10
7
|
@endpoint
|
11
8
|
end
|
12
|
-
|
9
|
+
def search(*args)
|
10
|
+
ItunesSearch::Search.new(*args)
|
11
|
+
end
|
13
12
|
class Base
|
14
|
-
|
15
13
|
def search(*args)
|
16
|
-
|
14
|
+
ItunesSearch::Search.new(*args)
|
17
15
|
end
|
18
|
-
|
19
16
|
end
|
20
|
-
|
21
17
|
end
|
data/lib/itunes-search/search.rb
CHANGED
@@ -5,13 +5,11 @@ module ItunesSearch
|
|
5
5
|
attr_accessor :options, :result_hash, :json
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
|
-
@options = args.inject({}) { |
|
8
|
+
@options = args.inject({}) { |element, result| result.merge(element); result }
|
9
9
|
end
|
10
10
|
|
11
|
-
def results
|
12
|
-
|
13
|
-
ra = to_hash["results"].collect {|r| OpenStruct.new(r) } unless to_hash["results"].empty?
|
14
|
-
return ra
|
11
|
+
def results
|
12
|
+
to_hash.empty? ? [] : to_hash["results"].collect { |r| OpenStruct.new(r) }
|
15
13
|
end
|
16
14
|
|
17
15
|
protected
|
data/test/test_itunes-search.rb
CHANGED
@@ -9,6 +9,11 @@ class TestItunesSearch < Test::Unit::TestCase
|
|
9
9
|
setup do
|
10
10
|
@base = Base.new()
|
11
11
|
end
|
12
|
+
context "module method" do
|
13
|
+
should "be able to search without creating object" do
|
14
|
+
assert search("term"=>"The Killers").results.first.trackViewUrl!=""
|
15
|
+
end
|
16
|
+
end
|
12
17
|
context "Band exists on itunes" do
|
13
18
|
setup do
|
14
19
|
@so = @base.search("term"=>"The Killers")
|