hallon 0.16.0 → 0.17.0
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.
- data/.gitignore +2 -1
- data/.travis.yml +2 -0
- data/CHANGELOG.md +22 -1
- data/Gemfile +2 -2
- data/README.markdown +2 -2
- data/Rakefile +69 -42
- data/hallon.gemspec +1 -1
- data/lib/hallon.rb +3 -2
- data/lib/hallon/album.rb +6 -4
- data/lib/hallon/artist.rb +6 -4
- data/lib/hallon/audio_queue.rb +1 -1
- data/lib/hallon/base.rb +4 -0
- data/lib/hallon/blob.rb +6 -0
- data/lib/hallon/error.rb +10 -41
- data/lib/hallon/ext/spotify.rb +1 -146
- data/lib/hallon/image.rb +8 -0
- data/lib/hallon/linkable.rb +6 -0
- data/lib/hallon/loadable.rb +6 -0
- data/lib/hallon/observable.rb +1 -1
- data/lib/hallon/observable/playlist_container.rb +2 -2
- data/lib/hallon/observable/session.rb +34 -0
- data/lib/hallon/player.rb +7 -3
- data/lib/hallon/playlist.rb +5 -1
- data/lib/hallon/playlist_container.rb +9 -8
- data/lib/hallon/scrobbler.rb +103 -0
- data/lib/hallon/search.rb +1 -0
- data/lib/hallon/session.rb +69 -13
- data/lib/hallon/toplist.rb +1 -1
- data/lib/hallon/track.rb +2 -2
- data/lib/hallon/version.rb +1 -1
- data/spec/hallon/album_spec.rb +16 -0
- data/spec/hallon/artist_spec.rb +16 -0
- data/spec/hallon/base_spec.rb +1 -1
- data/spec/hallon/error_spec.rb +3 -3
- data/spec/hallon/hallon_spec.rb +1 -1
- data/spec/hallon/image_spec.rb +6 -0
- data/spec/hallon/observable/session_spec.rb +20 -0
- data/spec/hallon/scrobbler_spec.rb +119 -0
- data/spec/hallon/session_spec.rb +38 -4
- data/spec/hallon/spotify_spec.rb +0 -45
- data/spec/mockspotify.rb +6 -1
- data/spec/spec_helper.rb +4 -5
- metadata +59 -20
- data/spec/support/cover_me.rb +0 -7
data/spec/hallon/session_spec.rb
CHANGED
@@ -38,6 +38,20 @@ describe Hallon::Session do
|
|
38
38
|
it "should fail on a huge user agent (> 255 characters)" do
|
39
39
|
expect { create_session(true, :user_agent => 'a' * 256) }.to raise_error(ArgumentError)
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should extract the proxy username and password" do
|
43
|
+
session = create_session(true, :proxy => "socks5://kim:pass@batm.an")
|
44
|
+
session.options[:proxy].should eq "socks5://batm.an"
|
45
|
+
session.options[:proxy_username].should eq "kim"
|
46
|
+
session.options[:proxy_password].should eq "pass"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not override the given username or password" do
|
50
|
+
session = create_session(true, :proxy => "socks5://kim:pass@batm.an", :proxy_username => "batman", :proxy_password => "hidden identity")
|
51
|
+
session.options[:proxy].should eq "socks5://batm.an"
|
52
|
+
session.options[:proxy_username].should eq "batman"
|
53
|
+
session.options[:proxy_password].should eq "hidden identity"
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
43
57
|
describe "options" do
|
@@ -70,7 +84,7 @@ describe Hallon::Session do
|
|
70
84
|
|
71
85
|
describe "#relogin" do
|
72
86
|
it "should raise if no credentials have been saved" do
|
73
|
-
expect { session.relogin }.to raise_error(
|
87
|
+
expect { session.relogin }.to raise_error(Spotify::Error)
|
74
88
|
end
|
75
89
|
|
76
90
|
it "should not raise if credentials have been saved" do
|
@@ -81,6 +95,17 @@ describe Hallon::Session do
|
|
81
95
|
end
|
82
96
|
end
|
83
97
|
|
98
|
+
describe "#username" do
|
99
|
+
it "should be nil if no username is stored in libspotify" do
|
100
|
+
session.username.should eq nil
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should retrieve the current user’s name if logged in" do
|
104
|
+
session.login 'Kim', 'pass'
|
105
|
+
session.username.should eq 'Kim'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
84
109
|
describe "#remembered_user" do
|
85
110
|
it "should be nil if no username is stored in libspotify" do
|
86
111
|
session.remembered_user.should eq nil
|
@@ -160,6 +185,15 @@ describe Hallon::Session do
|
|
160
185
|
end
|
161
186
|
end
|
162
187
|
|
188
|
+
describe "#private= and #private?" do
|
189
|
+
it "sets session privacy mode" do
|
190
|
+
session.private = false
|
191
|
+
session.should_not be_private
|
192
|
+
session.private = true
|
193
|
+
session.should be_private
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
163
197
|
describe "#cache_size" do
|
164
198
|
it "should default to 0" do
|
165
199
|
session.cache_size.should eq 0
|
@@ -247,13 +281,13 @@ describe Hallon::Session do
|
|
247
281
|
|
248
282
|
describe "#offline_bitrate=" do
|
249
283
|
it "should not resync unless explicitly told so" do
|
250
|
-
Spotify.should_receive(:session_preferred_offline_bitrate).with(session.pointer, :'96k', false)
|
284
|
+
Spotify.should_receive(:session_preferred_offline_bitrate).with(session.pointer, :'96k', false).and_return(:ok)
|
251
285
|
session.offline_bitrate = :'96k'
|
252
286
|
end
|
253
287
|
|
254
288
|
it "should resync if asked to" do
|
255
|
-
Spotify.should_receive(:session_preferred_offline_bitrate).with(session.pointer, :'96k', true)
|
256
|
-
session.offline_bitrate = :'96k',
|
289
|
+
Spotify.should_receive(:session_preferred_offline_bitrate).with(session.pointer, :'96k', true).and_return(:ok)
|
290
|
+
session.offline_bitrate = :'96k', :resync
|
257
291
|
end
|
258
292
|
|
259
293
|
it "should fail given an invalid value" do
|
data/spec/hallon/spotify_spec.rb
CHANGED
@@ -1,49 +1,4 @@
|
|
1
1
|
describe Spotify do
|
2
|
-
describe "a wrapped function" do
|
3
|
-
let(:null_pointer) { FFI::Pointer.new(0) }
|
4
|
-
subject do
|
5
|
-
Spotify.should_receive(:session_user).and_return(null_pointer)
|
6
|
-
Spotify.session_user!(session)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should return a Spotify::Pointer" do
|
10
|
-
subject.should be_a Spotify::Pointer
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should not add ref when the result is nil" do
|
14
|
-
Spotify.should_not_receive(:user_add_ref)
|
15
|
-
subject.should be_null
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe Spotify::Pointer do
|
20
|
-
describe ".typechecks?" do
|
21
|
-
it "should return false for non-spotify pointers" do
|
22
|
-
Spotify::Pointer.typechecks?(double(type: :artist), :artist).should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should be false for pointers of another type if type is given" do
|
26
|
-
Spotify::Pointer.typechecks?(mock_album, :artist).should be_false
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should be true for a pointer of the correct type" do
|
30
|
-
Spotify::Pointer.typechecks?(mock_album, :album).should be_true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "garbage collection" do
|
35
|
-
let(:my_pointer) { FFI::Pointer.new(1) }
|
36
|
-
|
37
|
-
it "should work" do
|
38
|
-
# GC tests are a bit funky, but as long as we garbage_release at least once, then
|
39
|
-
# we can assume our GC works properly, but up the stakes just for the sake of it
|
40
|
-
Spotify.should_receive(:garbage_release).with(my_pointer).at_least(3).times
|
41
|
-
5.times { Spotify::Pointer.new(my_pointer, :garbage, false) }
|
42
|
-
5.times { GC.start; sleep 0.01 }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
2
|
describe Spotify::CallbackStruct do
|
48
3
|
subject { Spotify::SessionCallbacks.new }
|
49
4
|
it { should be_a Spotify::CallbackStruct }
|
data/spec/mockspotify.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'ffi'
|
2
3
|
require 'rbconfig'
|
3
4
|
|
@@ -14,9 +15,12 @@ module Spotify
|
|
14
15
|
end
|
15
16
|
|
16
17
|
# Overriden to not throw an error on missing functions.
|
17
|
-
def attach_function(*)
|
18
|
+
def attach_function(name, *)
|
18
19
|
super
|
19
20
|
rescue FFI::NotFoundError => e
|
21
|
+
define_singleton_method(name) do |*args|
|
22
|
+
raise FFI::NotFoundError, "#{name} has not been defined"
|
23
|
+
end
|
20
24
|
warn "#{e.message}" if $VERBOSE
|
21
25
|
end
|
22
26
|
end
|
@@ -79,6 +83,7 @@ module Spotify
|
|
79
83
|
|
80
84
|
# mocked accessors
|
81
85
|
attach_function :mocksp_playlist_get_autolink_tracks, [:playlist], :bool
|
86
|
+
attach_function :mocksp_session_set_is_scrobbling_possible, [:session, :social_provider, :bool], :void
|
82
87
|
|
83
88
|
$VERBOSE = old_verbose
|
84
89
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'bundler'
|
4
4
|
Bundler.setup
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter 'spec/'
|
8
|
+
add_filter 'vendor/'
|
9
|
+
end if defined?(SimpleCov)
|
11
10
|
|
12
11
|
require 'mockspotify'
|
13
12
|
require 'hallon'
|
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.
|
4
|
+
version: 0.17.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ref
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,31 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: spotify
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
37
|
+
version: 12.0.2
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 12.0.2
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0.8'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '2'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: yard
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: bundler
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: rdiscount
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
description:
|
92
127
|
email: kim@burgestrand.se
|
93
128
|
executables: []
|
@@ -144,6 +179,7 @@ files:
|
|
144
179
|
- lib/hallon/player.rb
|
145
180
|
- lib/hallon/playlist.rb
|
146
181
|
- lib/hallon/playlist_container.rb
|
182
|
+
- lib/hallon/scrobbler.rb
|
147
183
|
- lib/hallon/search.rb
|
148
184
|
- lib/hallon/session.rb
|
149
185
|
- lib/hallon/toplist.rb
|
@@ -180,6 +216,7 @@ files:
|
|
180
216
|
- spec/hallon/player_spec.rb
|
181
217
|
- spec/hallon/playlist_container_spec.rb
|
182
218
|
- spec/hallon/playlist_spec.rb
|
219
|
+
- spec/hallon/scrobbler_spec.rb
|
183
220
|
- spec/hallon/search_spec.rb
|
184
221
|
- spec/hallon/session_spec.rb
|
185
222
|
- spec/hallon/spotify_spec.rb
|
@@ -198,7 +235,6 @@ files:
|
|
198
235
|
- spec/support/audio_driver_mock.rb
|
199
236
|
- spec/support/common_objects.rb
|
200
237
|
- spec/support/context_logged_in.rb
|
201
|
-
- spec/support/cover_me.rb
|
202
238
|
- spec/support/enumerable_comparison.rb
|
203
239
|
- spec/support/image_mocks.rb
|
204
240
|
- spec/support/playlist_container_mocks.rb
|
@@ -254,9 +290,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
290
|
- - ! '>='
|
255
291
|
- !ruby/object:Gem::Version
|
256
292
|
version: '0'
|
293
|
+
segments:
|
294
|
+
- 0
|
295
|
+
hash: 995209467900648626
|
257
296
|
requirements: []
|
258
297
|
rubyforge_project:
|
259
|
-
rubygems_version: 1.8.
|
298
|
+
rubygems_version: 1.8.24
|
260
299
|
signing_key:
|
261
300
|
specification_version: 3
|
262
301
|
summary: Hallon allows you to write Ruby applications utilizing the official Spotify
|
@@ -292,6 +331,7 @@ test_files:
|
|
292
331
|
- spec/hallon/player_spec.rb
|
293
332
|
- spec/hallon/playlist_container_spec.rb
|
294
333
|
- spec/hallon/playlist_spec.rb
|
334
|
+
- spec/hallon/scrobbler_spec.rb
|
295
335
|
- spec/hallon/search_spec.rb
|
296
336
|
- spec/hallon/session_spec.rb
|
297
337
|
- spec/hallon/spotify_spec.rb
|
@@ -310,7 +350,6 @@ test_files:
|
|
310
350
|
- spec/support/audio_driver_mock.rb
|
311
351
|
- spec/support/common_objects.rb
|
312
352
|
- spec/support/context_logged_in.rb
|
313
|
-
- spec/support/cover_me.rb
|
314
353
|
- spec/support/enumerable_comparison.rb
|
315
354
|
- spec/support/image_mocks.rb
|
316
355
|
- spec/support/playlist_container_mocks.rb
|