spof 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/spof/version.rb +1 -1
- data/lib/wrapper.rb +33 -4
- data/test/test_wrapper_basic_search.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d45c7f6f97bfa4030b84355b1e8aba9ba9dffa6b
|
4
|
+
data.tar.gz: bdb7e3dc76cf2343855c0cfe4a203ff6f19abb32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1627c65e6b37bac9efe25fce5551451c34bf176cef6957dbb83d2d9fd29deb8b2e35d0639bc2104755a97295129f72a630c96cd7f1d7131d6d9866a168fa30
|
7
|
+
data.tar.gz: 8348ea7d148b0109c21ce4b7b558d5e1c025a33591164f546322ca850840de0675d456417709b6d518f3e59bdb4752bf67890a048c2ac898aa8868156a2b1d15
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@ Ruby wrapper for the Spotify Search & Lookup API. Under development.
|
|
7
7
|
|
8
8
|
[](http://badge.fury.io/rb/spof)
|
9
9
|
|
10
|
+
[](https://waffle.io/ignaciocontreras/spof)
|
11
|
+
|
10
12
|
|
11
13
|
Usage
|
12
14
|
-----
|
data/lib/spof/version.rb
CHANGED
data/lib/wrapper.rb
CHANGED
@@ -25,12 +25,41 @@ module Spof
|
|
25
25
|
self
|
26
26
|
end
|
27
27
|
|
28
|
+
def all(num)
|
29
|
+
@all = true
|
30
|
+
end
|
31
|
+
|
28
32
|
def search(text)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
@type ||= :all
|
34
|
+
@all ||= false
|
35
|
+
|
36
|
+
continue = true
|
37
|
+
|
38
|
+
result = []
|
39
|
+
while continue
|
40
|
+
res = case @type
|
41
|
+
when :album
|
42
|
+
Spof::Search.album(text)[:albums]
|
43
|
+
when :artist
|
44
|
+
Spof::Search.artist(text)[:artists]
|
45
|
+
when :track
|
46
|
+
Spof::Search.track(text)[:tracks]
|
47
|
+
when :all?
|
48
|
+
else
|
49
|
+
raise Spof::SpofError, "Invalid search type #{@type}"
|
50
|
+
end
|
51
|
+
result |= res
|
52
|
+
if res.empty?
|
53
|
+
continue = false
|
54
|
+
else
|
55
|
+
continue = @all
|
56
|
+
end
|
33
57
|
end
|
58
|
+
|
59
|
+
@type = nil # TODO: reset search type?
|
60
|
+
@all = nil
|
61
|
+
|
62
|
+
return result
|
34
63
|
end
|
35
64
|
|
36
65
|
end
|
@@ -4,23 +4,23 @@ require 'test/unit'
|
|
4
4
|
class TestBasicWrapper < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
@w = Spof::Wrapper.new :testing =>
|
7
|
+
@w = Spof::Wrapper.new :testing => false # testing actual responses!
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
expected = Spof::Search.album('space oddity')
|
10
|
+
def test_search_album_response
|
11
|
+
expected = Spof::Search.album('space oddity')[:albums]
|
12
12
|
real = @w.album.search('space oddity')
|
13
13
|
assert_equal expected, real
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
expected = Spof::Search.artist('david bowie')
|
16
|
+
def test_search_artist_response
|
17
|
+
expected = Spof::Search.artist('david bowie')[:artists]
|
18
18
|
real = @w.artist.search('david bowie')
|
19
19
|
assert_equal expected, real
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
expected = Spof::Search.track('life on mars')
|
22
|
+
def test_search_track_response
|
23
|
+
expected = Spof::Search.track('life on mars')[:tracks]
|
24
24
|
real = @w.track.search('life on mars')
|
25
25
|
assert_equal expected, real
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Contreras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|