hallon 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/CHANGELOG.md +12 -1
- data/README.markdown +13 -5
- data/Rakefile +23 -74
- data/examples/example_support.rb +2 -0
- data/hallon.gemspec +1 -1
- data/lib/hallon.rb +1 -6
- data/lib/hallon/album.rb +4 -4
- data/lib/hallon/album_browse.rb +6 -6
- data/lib/hallon/artist.rb +3 -3
- data/lib/hallon/artist_browse.rb +9 -9
- data/lib/hallon/audio_queue.rb +2 -1
- data/lib/hallon/base.rb +10 -10
- data/lib/hallon/enumerator.rb +3 -3
- data/lib/hallon/ext/spotify.rb +1 -47
- data/lib/hallon/image.rb +4 -4
- data/lib/hallon/link.rb +4 -4
- data/lib/hallon/linkable.rb +10 -10
- data/lib/hallon/observable/playlist.rb +2 -3
- data/lib/hallon/observable/playlist_container.rb +3 -12
- data/lib/hallon/player.rb +2 -2
- data/lib/hallon/playlist.rb +6 -6
- data/lib/hallon/playlist_container.rb +8 -8
- data/lib/hallon/scrobbler.rb +4 -4
- data/lib/hallon/search.rb +20 -5
- data/lib/hallon/session.rb +18 -17
- data/lib/hallon/toplist.rb +4 -4
- data/lib/hallon/track.rb +5 -5
- data/lib/hallon/user.rb +7 -7
- data/lib/hallon/version.rb +1 -1
- data/spec/hallon/album_browse_spec.rb +1 -1
- data/spec/hallon/artist_browse_spec.rb +1 -1
- data/spec/hallon/base_spec.rb +6 -3
- data/spec/hallon/enumerator_spec.rb +2 -2
- data/spec/hallon/hallon_spec.rb +0 -4
- data/spec/hallon/link_spec.rb +1 -1
- data/spec/hallon/linkable_spec.rb +4 -4
- data/spec/hallon/observable/playlist_container_spec.rb +3 -3
- data/spec/hallon/observable/playlist_spec.rb +1 -1
- data/spec/hallon/player_spec.rb +9 -9
- data/spec/hallon/playlist_container_spec.rb +2 -2
- data/spec/hallon/playlist_spec.rb +8 -8
- data/spec/hallon/scrobbler_spec.rb +8 -7
- data/spec/hallon/search_spec.rb +3 -3
- data/spec/hallon/session_spec.rb +10 -10
- data/spec/hallon/toplist_spec.rb +4 -4
- data/spec/hallon/track_spec.rb +6 -6
- data/spec/hallon/user_post_spec.rb +1 -1
- data/spec/hallon/user_spec.rb +1 -1
- data/spec/mockspotify.rb +36 -42
- data/spec/mockspotify/mockspotify_spec.rb +15 -15
- data/spec/spec_helper.rb +25 -21
- data/spec/support/album_mocks.rb +4 -4
- data/spec/support/artist_mocks.rb +5 -5
- data/spec/support/image_mocks.rb +4 -4
- data/spec/support/playlist_container_mocks.rb +4 -4
- data/spec/support/playlist_mocks.rb +6 -6
- data/spec/support/search_mocks.rb +2 -2
- data/spec/support/session_mocks.rb +1 -1
- data/spec/support/shared_for_callbacks.rb +1 -1
- data/spec/support/shared_for_linkable_objects.rb +3 -2
- data/spec/support/toplist_mocks.rb +2 -2
- data/spec/support/track_mocks.rb +4 -4
- data/spec/support/user_mocks.rb +2 -2
- metadata +5 -5
data/spec/spec_helper.rb
CHANGED
@@ -28,8 +28,8 @@ RSpec.configure do |config|
|
|
28
28
|
Hallon::Session.stub(:instance).and_return(session)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
Spotify
|
31
|
+
def spotify_api
|
32
|
+
Spotify::API
|
33
33
|
end
|
34
34
|
|
35
35
|
def fixture_image_path
|
@@ -60,8 +60,8 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
60
60
|
let(:options) do
|
61
61
|
{
|
62
62
|
:user_agent => "Hallon (rspec)",
|
63
|
-
:
|
64
|
-
:
|
63
|
+
:settings_location => "tmp",
|
64
|
+
:cache_location => ""
|
65
65
|
}
|
66
66
|
end
|
67
67
|
|
@@ -73,30 +73,34 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
73
73
|
Dir["#{File.dirname(__FILE__)}/fixtures/**/*.rb"].each {|f| require f}
|
74
74
|
|
75
75
|
RSpec.configure do |config|
|
76
|
+
config.after do
|
77
|
+
Spotify.mock_registry_clean
|
78
|
+
end
|
79
|
+
|
76
80
|
config.before do
|
77
|
-
Spotify.
|
78
|
-
Spotify.
|
79
|
-
Spotify.
|
80
|
-
Spotify.
|
81
|
+
Spotify.mock_registry_add 'spotify:image:3ad93423add99766e02d563605c6e76ed2b0e400', mock_image
|
82
|
+
Spotify.mock_registry_add 'spotify:user:burgestrand:playlist:megaplaylist', mock_playlist_two
|
83
|
+
Spotify.mock_registry_add 'spotify:search:my+%C3%A5+utf8+%EF%A3%BF+query', mock_search
|
84
|
+
Spotify.mock_registry_add 'spotify:search:', mock_empty_search
|
81
85
|
|
82
|
-
Spotify.
|
83
|
-
Spotify.
|
86
|
+
Spotify.mock_registry_add 'spotify:albumbrowse:1xvnWMz2PNFf7mXOSRuLws', mock_albumbrowse
|
87
|
+
Spotify.mock_registry_add 'spotify:album:1xvnWMz2PNFf7mXOSRuLws', mock_album
|
84
88
|
|
85
|
-
Spotify.
|
86
|
-
Spotify.
|
89
|
+
Spotify.mock_registry_add 'spotify:albumbrowse:thisisanemptyalbumyoow', mock_empty_albumbrowse
|
90
|
+
Spotify.mock_registry_add 'spotify:album:thisisanemptyalbumyoow', mock_empty_album
|
87
91
|
|
88
|
-
Spotify.
|
89
|
-
Spotify.
|
92
|
+
Spotify.mock_registry_add 'spotify:artist:3bftcFwl4vqRNNORRsqm1G', mock_artist
|
93
|
+
Spotify.mock_registry_add 'spotify:artistbrowse:3bftcFwl4vqRNNORRsqm1G', mock_artistbrowse
|
90
94
|
|
91
|
-
Spotify.
|
92
|
-
Spotify.
|
95
|
+
Spotify.mock_registry_add 'spotify:artist:thisisanemptyartistyow', mock_empty_artist
|
96
|
+
Spotify.mock_registry_add 'spotify:artistbrowse:thisisanemptyartistyow', mock_empty_artistbrowse
|
93
97
|
|
94
|
-
Spotify.
|
98
|
+
Spotify.mock_registry_add 'spotify:container:burgestrand', mock_container
|
95
99
|
|
96
|
-
Spotify.
|
100
|
+
Spotify.mock_registry_add 'spotify:track:7N2Vc8u56VGA4KUrGbikC2', mock_track
|
97
101
|
|
98
|
-
Spotify.
|
99
|
-
Spotify.
|
100
|
-
Spotify.
|
102
|
+
Spotify.mock_registry_add 'spotify:user:burgestrand', mock_user
|
103
|
+
Spotify.mock_registry_add 'spotify:user:burgestrand:playlist:07AX9IY9Hqmj1RqltcG0fi', mock_playlist
|
104
|
+
Spotify.mock_registry_add 'spotify:user:burgestrand:starred', mock_playlist
|
101
105
|
end
|
102
106
|
end
|
data/spec/support/album_mocks.rb
CHANGED
@@ -9,11 +9,11 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:mock_album) do
|
12
|
-
Spotify.
|
12
|
+
Spotify.mock_album_create("Finally Woken", mock_artist, 2004, mock_image_id, :single, true, true)
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:mock_empty_album) do
|
16
|
-
Spotify.
|
16
|
+
Spotify.mock_album_create(nil, nil, 0, nil, :single, false, false)
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:mock_albumbrowse) do
|
@@ -21,10 +21,10 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
21
21
|
copyrights = pointer_array_with(*copyrights)
|
22
22
|
tracks = pointer_array_with(mock_track, mock_track_two)
|
23
23
|
review = "This album is AWESOME"
|
24
|
-
Spotify.
|
24
|
+
Spotify.mock_albumbrowse_create(:ok, 2751, mock_album, mock_artist, 2, copyrights, 2, tracks, review, nil, nil)
|
25
25
|
end
|
26
26
|
|
27
27
|
let(:mock_empty_albumbrowse) do
|
28
|
-
Spotify.
|
28
|
+
Spotify.mock_albumbrowse_create(:ok, -1, nil, nil, 0, nil, 0, nil, nil, nil, nil)
|
29
29
|
end
|
30
30
|
end
|
@@ -9,15 +9,15 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:mock_artist) do
|
12
|
-
Spotify.
|
12
|
+
Spotify.mock_artist_create("Jem", mock_image_id, true)
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:mock_artist_two) do
|
16
|
-
Spotify.
|
16
|
+
Spotify.mock_artist_create("Maroon 5", mock_image_id, true)
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:mock_empty_artist) do
|
20
|
-
Spotify.
|
20
|
+
Spotify.mock_artist_create(nil, nil, false)
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:mock_artistbrowse) do
|
@@ -27,10 +27,10 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
27
27
|
albums = pointer_array_with(mock_album)
|
28
28
|
tophits = pointer_array_with(mock_track)
|
29
29
|
|
30
|
-
Spotify.
|
30
|
+
Spotify.mock_artistbrowse_create(:ok, 2751, mock_artist, portraits.length, portraits, tracks.length, tracks, albums.length, albums, similar_artists.length, similar_artists, tophits.length, tophits, "grew up in DA BLOCK", :full, nil, nil)
|
31
31
|
end
|
32
32
|
|
33
33
|
let(:mock_empty_artistbrowse) do
|
34
|
-
Spotify.
|
34
|
+
Spotify.mock_artistbrowse_create(:ok, 0, nil, 0, nil, 0, nil, 0, nil, 0, nil, 0, nil, nil, :full, nil, nil)
|
35
35
|
end
|
36
36
|
end
|
data/spec/support/image_mocks.rb
CHANGED
@@ -13,11 +13,11 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
13
13
|
let(:mock_image_id) { ":\xD94#\xAD\xD9\x97f\xE0-V6\x05\xC6\xE7n\xD2\xB0\xE4\0".force_encoding("BINARY") }
|
14
14
|
|
15
15
|
let(:mock_image) do
|
16
|
-
Spotify.
|
16
|
+
Spotify.mock_image_create(mock_image_id, :jpeg, File.size(fixture_image_path), File.read(fixture_image_path), :ok)
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:mock_empty_image) do
|
20
|
-
Spotify.
|
20
|
+
Spotify.mock_image_create(mock_image_id, :jpeg, 0, nil, :ok)
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:mock_image_id_pointer) do
|
@@ -25,10 +25,10 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
let(:mock_image_link) do
|
28
|
-
Spotify.link_create_from_string
|
28
|
+
Spotify.link_create_from_string(mock_image_uri)
|
29
29
|
end
|
30
30
|
|
31
31
|
let(:mock_image_link_two) do
|
32
|
-
Spotify.link_create_from_string
|
32
|
+
Spotify.link_create_from_string("spotify:image:ce9da340323614dc95ae96b68843b1c726dc5c8a")
|
33
33
|
end
|
34
34
|
end
|
@@ -16,21 +16,21 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
16
16
|
items[0][:playlist] = mock_playlist
|
17
17
|
items[0][:type] = :playlist
|
18
18
|
|
19
|
-
items[1][:folder_name] =
|
19
|
+
items[1][:folder_name] = "Boogie"
|
20
20
|
items[1][:type] = :start_folder
|
21
21
|
items[1][:folder_id] = 1337
|
22
22
|
|
23
23
|
items[2][:playlist] = mock_playlist_two
|
24
24
|
items[2][:type] = :playlist
|
25
25
|
|
26
|
-
items[3][:folder_name] =
|
26
|
+
items[3][:folder_name] = nil
|
27
27
|
items[3][:type] = :end_folder
|
28
28
|
items[3][:folder_id] = 1337
|
29
29
|
|
30
|
-
Spotify.
|
30
|
+
Spotify.mock_playlistcontainer_create(mock_user, true, num_items, items_ptr, nil, nil)
|
31
31
|
end
|
32
32
|
|
33
33
|
let(:mock_empty_container) do
|
34
|
-
Spotify.
|
34
|
+
Spotify.mock_playlistcontainer_create(nil, false, 0, nil, nil, nil)
|
35
35
|
end
|
36
36
|
end
|
@@ -32,19 +32,19 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
32
32
|
tracks[0][:track] = mock_track
|
33
33
|
tracks[0][:create_time] = Time.parse("2009-11-04").to_i
|
34
34
|
tracks[0][:creator] = mock_user
|
35
|
-
tracks[0][:message] =
|
35
|
+
tracks[0][:message] = "message this, YO!"
|
36
36
|
tracks[0][:seen] = true
|
37
37
|
|
38
38
|
tracks[1][:track] = mock_track_two
|
39
39
|
tracks[1][:create_time] = Time.parse("2009-11-05").to_i
|
40
40
|
tracks[1][:creator] = mock_user
|
41
|
-
tracks[1][:message] =
|
41
|
+
tracks[1][:message] = "message this, YO!"
|
42
42
|
tracks[1][:seen] = true
|
43
43
|
|
44
44
|
tracks[2][:track] = mock_track
|
45
45
|
tracks[2][:create_time] = Time.parse("2009-11-06").to_i
|
46
46
|
tracks[2][:creator] = mock_user
|
47
|
-
tracks[2][:message] =
|
47
|
+
tracks[2][:message] = "message this, YO!"
|
48
48
|
tracks[2][:seen] = true
|
49
49
|
|
50
50
|
tracks[3][:track] = mock_track_two
|
@@ -53,15 +53,15 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
53
53
|
tracks[3][:message] = nil
|
54
54
|
tracks[3][:seen] = true
|
55
55
|
|
56
|
-
Spotify.
|
56
|
+
Spotify.mock_playlist_create("Megaplaylist", true, mock_user, true, "Playlist description...?", mock_image_id, false, 1000, mock_subscribers, true, :no, 67, num_tracks, tracks_ptr)
|
57
57
|
end
|
58
58
|
|
59
59
|
let(:mock_playlist_two) do
|
60
|
-
Spotify.
|
60
|
+
Spotify.mock_playlist_create("Dunderlist", true, mock_user, true, nil, mock_image_id, false, 1000, nil, true, :no, 0, 0, nil)
|
61
61
|
end
|
62
62
|
|
63
63
|
let(:mock_empty_playlist) do
|
64
|
-
Spotify.
|
64
|
+
Spotify.mock_playlist_create(nil, false, nil, false, nil, nil, false, 0, nil, false, :no, 0, 0, nil)
|
65
65
|
end
|
66
66
|
|
67
67
|
let(:mock_playlist_raw) do
|
@@ -14,10 +14,10 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
14
14
|
tracks = pointer_array_with(mock_track, mock_track_two)
|
15
15
|
playlists = pointer_array_with(mock_playlist_two)
|
16
16
|
|
17
|
-
Spotify.
|
17
|
+
Spotify.mock_search_create(:ok, "my å utf8 query", "another thing", 1337, tracks.length, tracks, 42, albums.length, albums, 81104, artists.length, artists, 0716, playlists.length, playlists, nil, nil)
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:mock_empty_search) do
|
21
|
-
Spotify.
|
21
|
+
Spotify.mock_search_create(:ok, "", nil, 0, 0, nil, 0, 0, nil, 0, 0, nil, 0, 0, nil, nil, nil)
|
22
22
|
end
|
23
23
|
end
|
@@ -26,7 +26,7 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
26
26
|
sstatus = mock_offline_sync_status
|
27
27
|
inbox = mock_playlist
|
28
28
|
session.instance_eval do
|
29
|
-
@pointer = Spotify.
|
29
|
+
@pointer = Spotify.mock_session_create(nil, :undefined, 60 * 60 * 24 * 30, sstatus, 7, 3, inbox)
|
30
30
|
end
|
31
31
|
session
|
32
32
|
end
|
@@ -52,7 +52,7 @@ RSpec.configure do
|
|
52
52
|
# sure the methods have the correct arity
|
53
53
|
# (also, we can’t find the struct callback arity in any nice way)
|
54
54
|
it "should have the correct arity" do
|
55
|
-
fn = Spotify.find_type(type)
|
55
|
+
fn = Spotify::API.find_type(type)
|
56
56
|
subject_callback.arity.should eq fn.param_types.size
|
57
57
|
end if method_defined?(:type)
|
58
58
|
end
|
@@ -6,8 +6,9 @@ shared_examples_for "a Linkable object" do
|
|
6
6
|
let(:spotify_pointer) do
|
7
7
|
ptr_type = Hallon::Link.new(spotify_uri).type
|
8
8
|
ptr_type = :user if ptr_type == :profile
|
9
|
-
|
10
|
-
Spotify
|
9
|
+
ptr_class = Spotify.const_get(ptr_type.to_s.sub(/\A\w/) { |x| x.upcase })
|
10
|
+
ffi_pointer = Spotify.mock_registry_find(spotify_uri[/[^#]+/]) # up to pound sign for track#offset
|
11
|
+
ptr_class.new(ffi_pointer)
|
11
12
|
end
|
12
13
|
|
13
14
|
it "should work with a string URI" do
|
@@ -10,10 +10,10 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
10
10
|
artists = pointer_array_with(mock_artist, mock_artist_two)
|
11
11
|
albums = pointer_array_with(mock_album)
|
12
12
|
tracks = pointer_array_with(mock_track, mock_track_two)
|
13
|
-
Spotify.
|
13
|
+
Spotify.mock_toplistbrowse_create(:ok, 2751, artists.length, artists, albums.length, albums, tracks.length, tracks)
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:mock_empty_toplistbrowse) do
|
17
|
-
Spotify.
|
17
|
+
Spotify.mock_toplistbrowse_create(:ok, -1, 0, nil, 0, nil, 0, nil)
|
18
18
|
end
|
19
19
|
end
|
data/spec/support/track_mocks.rb
CHANGED
@@ -9,20 +9,20 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
9
9
|
|
10
10
|
let(:mock_track) do
|
11
11
|
artists = pointer_array_with(mock_artist, mock_artist_two)
|
12
|
-
Spotify.
|
12
|
+
Spotify.mock_track_create("They", artists.length, artists, mock_album, 123_456, 42, 2, 7, :ok, true, :available, :done, false, true, nil, true, false)
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:mock_track_two) do
|
16
16
|
artists = pointer_array_with(mock_artist)
|
17
|
-
Spotify.
|
17
|
+
Spotify.mock_track_create("Amazing", artists.length, artists, mock_album, 123_456, 42, 2, 7, :ok, true, :available, :no, false, true, nil, true, true)
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:mock_linked_track) do
|
21
21
|
artists = pointer_array_with(mock_artist_two)
|
22
|
-
Spotify.
|
22
|
+
Spotify.mock_track_create("They", artists.length, artists, mock_album, 60, 100, 1, 1, :ok, true, :available, :no, false, true, mock_track, false, false)
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:mock_empty_track) do
|
26
|
-
Spotify.
|
26
|
+
Spotify.mock_track_create(nil, 0, nil, nil, 0, 0, 0, 0, :ok, false, :unavailable, :no, false, true, nil, false, false)
|
27
27
|
end
|
28
28
|
end
|
data/spec/support/user_mocks.rb
CHANGED
@@ -7,11 +7,11 @@ RSpec::Core::ExampleGroup.instance_eval do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:mock_user) do
|
10
|
-
Spotify.
|
10
|
+
Spotify.mock_user_create("burgestrand", "Burgestrand", true)
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:mock_empty_user) do
|
14
|
-
Spotify.
|
14
|
+
Spotify.mock_user_create(nil, nil, false)
|
15
15
|
end
|
16
16
|
|
17
17
|
let(:mock_user_raw) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hallon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ref
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 12.
|
37
|
+
version: 12.3.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 12.
|
45
|
+
version: 12.3.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
version: '0'
|
294
294
|
segments:
|
295
295
|
- 0
|
296
|
-
hash:
|
296
|
+
hash: 1548945263546800899
|
297
297
|
requirements: []
|
298
298
|
rubyforge_project:
|
299
299
|
rubygems_version: 1.8.24
|