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/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ Hallon’s Changelog
|
|
4
4
|
[HEAD][]
|
5
5
|
------------------
|
6
6
|
|
7
|
+
[v0.18.1][]
|
8
|
+
------------------
|
9
|
+
Hallon now supports spotify ~> 12.3.0. As a result, you no longer need to manually install
|
10
|
+
libspotify except in cases where the gem does not exist for your platform. I’ve tried to be
|
11
|
+
as liberal as possible in the gem platform choice, so manual installation should be a rare
|
12
|
+
occurrence.
|
13
|
+
|
14
|
+
This release mostly brings an internal change, and should not affect the public API, and as
|
15
|
+
such only the patch version has been increased.
|
16
|
+
|
7
17
|
[v0.18.0][]
|
8
18
|
------------------
|
9
19
|
This issue is to plug a bug of libspotify on Linux (see issue #125). The reason that
|
@@ -396,4 +406,5 @@ easier to handle.
|
|
396
406
|
[v0.16.0]: https://github.com/Burgestrand/Hallon/compare/v0.15.0...v0.16.0
|
397
407
|
[v0.17.0]: https://github.com/Burgestrand/Hallon/compare/v0.16.0...v0.17.0
|
398
408
|
[v0.18.0]: https://github.com/Burgestrand/Hallon/compare/v0.17.0...v0.18.0
|
399
|
-
[
|
409
|
+
[v0.18.1]: https://github.com/Burgestrand/Hallon/compare/v0.18.0...v0.18.1
|
410
|
+
[HEAD]: https://github.com/Burgestrand/Hallon/compare/v0.18.1...HEAD
|
data/README.markdown
CHANGED
@@ -15,9 +15,7 @@ Before you start using Hallon you’ll need to complete the following steps.
|
|
15
15
|
2. [Download your application key from developer.spotify.com](https://developer.spotify.com/en/libspotify/application-key/),
|
16
16
|
and place it in a known location. You’ll have the option of downloading it either in **binary** or c-code. You want the
|
17
17
|
**binary** one. If you do not have an application key already, you will be asked to create one.
|
18
|
-
3.
|
19
|
-
versions are not supported. For help installing libspotify, please see the wiki on [How to install libspotify][].
|
20
|
-
4. Once the above are done, you are ready to try out Hallon.
|
18
|
+
3. Once the above are done, you are ready to try out Hallon.
|
21
19
|
|
22
20
|
### Using Hallon
|
23
21
|
|
@@ -160,7 +158,11 @@ Finally, here are some important notes
|
|
160
158
|
[Fork](http://help.github.com/forking/) Hallon, write tests for everything you do (so I don’t break your stuff during my own development) and send a pull request. If you modify existing files, please adhere to the coding standard surrounding your code.
|
161
159
|
|
162
160
|
### Hallon uses [semantic versioning](http://semver.org) as of v0.0.0
|
163
|
-
As long as Hallon stays at major version 0
|
161
|
+
As long as Hallon stays at major version 0 its API should be considered experimental. I expect it to change a lot to version v1.0.0.
|
162
|
+
|
163
|
+
Hallon is not without version policy, however. As of version **v0.18.0** I aim to only increase the minor version when backwards-incompatible
|
164
|
+
changes are made. Therefore, it should be safe to upgrade between minor versions, i.e. specify version constraints with the patch version as
|
165
|
+
the variable version: `hallon ~> v0.18.0`.
|
164
166
|
|
165
167
|
### Hallon only supports one session per process
|
166
168
|
You can only keep one session with Spotify alive at a time within the same process, due to a limitation of libspotify.
|
@@ -168,6 +170,12 @@ You can only keep one session with Spotify alive at a time within the same proce
|
|
168
170
|
### When forking, you need to be extra careful
|
169
171
|
If you fork, you need to instantiate the session within the process you plan to use Hallon in. You want to use Hallon in the parent? Create the session in the parent. You want to use it in the child? Create the session in the child! This is a limitation of libspotify itself.
|
170
172
|
|
173
|
+
### Hallon and platforms
|
174
|
+
Hallon aims to support the available platforms of the Spotify gem, which in turn depends somewhat on the platforms that libspotify support. As of current, Hallon officially supports Mac OS and Linux distributions that libspotify supports. Windows support is possible, but is yet to have been needed.
|
175
|
+
|
176
|
+
### Having trouble with libspotify missing?
|
177
|
+
If so, it may be the case that your platform is not supported by the [libspotify gem](http://rubygems.org/gems/libspotify). Hallon’s wiki has an article on [How to install libspotify](https://github.com/Burgestrand/Hallon/wiki/How-to-install-libspotify) for you. However, please also [report an issue on the libspotify gem](https://github.com/Burgestrand/libspotify/issues), I’d appreciate it, thank you!
|
178
|
+
|
171
179
|
Credits
|
172
180
|
-------
|
173
181
|
- Per Reimers, cracking synchronization bugs with me deep in the night (4 AM), thanks. :)
|
@@ -180,7 +188,7 @@ License
|
|
180
188
|
Hallon is licensed under a 2-clause (Simplified) BSD license. More information can be found in the `LICENSE.txt` file.
|
181
189
|
|
182
190
|
[Raspberry]: http://images.google.com/search?q=raspberry&tbm=isch
|
183
|
-
[Spotify for Ruby]: https://github.com/Burgestrand/
|
191
|
+
[Spotify for Ruby]: https://github.com/Burgestrand/spotify
|
184
192
|
[spotify gem]: https://rubygems.org/gems/spotify
|
185
193
|
[libspotify]: http://developer.spotify.com/en/libspotify/overview/
|
186
194
|
[Greenstripes]: http://github.com/sarnesjo/greenstripes
|
data/Rakefile
CHANGED
@@ -33,36 +33,6 @@ task 'spotify:coverage' do
|
|
33
33
|
|
34
34
|
require 'pry'
|
35
35
|
require 'set'
|
36
|
-
|
37
|
-
module Spotify
|
38
|
-
# Wrapped functions return pointers that are auto-GC’d by Ruby,
|
39
|
-
# so we ignore add_ref and release for these methods; but since
|
40
|
-
# we don’t know their type by mere name, we must resort to this
|
41
|
-
# hack to do it automatically (because we can).
|
42
|
-
class << self
|
43
|
-
def lookup_return_value(name)
|
44
|
-
@function_to_return_type[name.to_s]
|
45
|
-
end
|
46
|
-
|
47
|
-
def define_singleton_method(name, &block)
|
48
|
-
return_type = block.binding.eval <<-CODE
|
49
|
-
begin
|
50
|
-
return_type if __method__ == :wrap_function
|
51
|
-
rescue NameError
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
CODE
|
55
|
-
|
56
|
-
if return_type
|
57
|
-
@function_to_return_type ||= {}
|
58
|
-
@function_to_return_type[name.to_s] = return_type
|
59
|
-
end
|
60
|
-
|
61
|
-
super
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
36
|
require 'spotify'
|
67
37
|
|
68
38
|
begin
|
@@ -72,19 +42,20 @@ task 'spotify:coverage' do
|
|
72
42
|
abort
|
73
43
|
end
|
74
44
|
|
75
|
-
methods = Spotify.methods(false).map(&:to_s)
|
76
|
-
auto_gc = Set.new(methods.grep(/!\z/).select { |m| Spotify.lookup_return_value(m) })
|
77
|
-
auto_err = Set.new(methods.grep(/!\z/)).difference(auto_gc)
|
45
|
+
methods = Spotify.methods(false).map(&:to_s).reject { |x| x =~ /_add_ref|_release/ }
|
78
46
|
covered = Set.new(methods)
|
79
|
-
|
47
|
+
auto_error = Set.new(methods.select { |x| x =~ /!/ })
|
48
|
+
inexisting = []
|
80
49
|
ignored = [
|
81
50
|
'attach_function', # spotify overloads this
|
82
51
|
'session_release', # segfaults on libspotify <= 9, and sometimes deadlocks on libspotify <= v12
|
83
|
-
'session_release!', # …
|
84
52
|
'session_userdata', # wont support this
|
53
|
+
'build_id', # no use for it
|
54
|
+
'platform', # not necessary yet
|
55
|
+
'mac?', # has no use for it
|
56
|
+
'search_playlist', # does not GC convention, dangerous to use!
|
85
57
|
'error_message', # supported by Hallon::Error.explain
|
86
58
|
'link_as_track', # using link_as_track_and_offset instead
|
87
|
-
'link_as_track!', # using link_as_track_and_offset! instead
|
88
59
|
'wrap_function', # not a spotify function
|
89
60
|
'lookup_return_value', # custom method
|
90
61
|
'define_singleton_method', # overloaded by us
|
@@ -95,58 +66,36 @@ task 'spotify:coverage' do
|
|
95
66
|
# Handlers for different AST nodes
|
96
67
|
printer = proc { |*args| p args }
|
97
68
|
silencer = proc { }
|
69
|
+
dsl_method = proc { |recv, meth, (_, name)| name }
|
98
70
|
handlers = Hash.new(Hash.new(silencer))
|
99
71
|
|
100
72
|
# Direct calls
|
101
73
|
handlers[Sexp.new(:const, :Spotify)] = Hash.new(proc do |_, meth, _|
|
102
|
-
|
103
|
-
warning << [$file, meth]
|
104
|
-
end
|
74
|
+
meth &&= meth.to_s
|
105
75
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
# we are doing the right thing here
|
112
|
-
if auto_err.member?(auto_err_lookup)
|
113
|
-
result << auto_err_lookup
|
114
|
-
result << auto_err_lookup.delete('!')
|
115
|
-
result.uniq!
|
116
|
-
end
|
117
|
-
|
118
|
-
if meth =~ /(.+)!\z/
|
119
|
-
# if it’s auto-GC’d, we can also account for _release and _add_ref
|
120
|
-
if (return_type = Spotify.lookup_return_value(meth))
|
121
|
-
result << $1
|
122
|
-
result << "#{return_type}_release"
|
123
|
-
result << "#{return_type}_add_ref"
|
124
|
-
result << "#{return_type}_release!"
|
125
|
-
result << "#{return_type}_add_ref!"
|
76
|
+
[meth].tap do |result|
|
77
|
+
if meth =~ /!/ && auto_error.include?(meth)
|
78
|
+
result << meth.delete("!")
|
79
|
+
else
|
80
|
+
result << "#{meth}!"
|
126
81
|
end
|
127
|
-
end
|
128
82
|
|
129
|
-
|
83
|
+
inexisting << meth unless Spotify.respond_to?(meth)
|
84
|
+
end
|
130
85
|
end)
|
131
86
|
|
132
87
|
# DSL Methods
|
133
88
|
no_receiver = handlers[nil] = Hash.new(silencer)
|
134
89
|
no_receiver[:from_link] = no_receiver[:to_link] = proc do |recv, meth, (_, name)|
|
135
90
|
prefix = meth == :to_link ? "link_create" : "link"
|
136
|
-
|
137
|
-
[method, "#{method}!"]
|
91
|
+
"%s_%s" % [prefix, name]
|
138
92
|
end
|
139
93
|
|
140
94
|
# Hallon::Enumerator
|
141
|
-
no_receiver[:size] =
|
142
|
-
name
|
143
|
-
end
|
95
|
+
no_receiver[:size] = dsl_method
|
144
96
|
|
145
97
|
# Hallon::Enumerator
|
146
|
-
no_receiver[:item] =
|
147
|
-
method = name.to_s
|
148
|
-
[method.delete("!"), method]
|
149
|
-
end
|
98
|
+
no_receiver[:item] = dsl_method
|
150
99
|
|
151
100
|
fails = {}
|
152
101
|
FileList['lib/**/*.rb'].each do |file|
|
@@ -186,10 +135,10 @@ task 'spotify:coverage' do
|
|
186
135
|
puts
|
187
136
|
end
|
188
137
|
|
189
|
-
unless
|
190
|
-
puts "
|
191
|
-
|
192
|
-
puts " #{
|
138
|
+
unless inexisting.empty?
|
139
|
+
puts "Non-existing methods (but used; remove!):"
|
140
|
+
inexisting.each do |fail|
|
141
|
+
puts " #{fail}"
|
193
142
|
end
|
194
143
|
puts
|
195
144
|
end
|
data/examples/example_support.rb
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
# If at any point you feel lost, do not hesitate to consult with my superiors. You may
|
10
10
|
# find them at https://github.com/Burgestrand/Hallon. Thank you!
|
11
11
|
|
12
|
+
$stdout.sync = true
|
13
|
+
|
12
14
|
# First, I need the power to ask you questions. You need not care much about this particular
|
13
15
|
# piece of me; only keep in mind that it should help keep the rest of me less cluttered.
|
14
16
|
def prompt(string, options = {})
|
data/hallon.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.required_ruby_version = '>= 1.9'
|
23
23
|
|
24
24
|
gem.add_dependency 'ref', '~> 1.0'
|
25
|
-
gem.add_dependency 'spotify', '~> 12.
|
25
|
+
gem.add_dependency 'spotify', '~> 12.3.0'
|
26
26
|
gem.add_development_dependency 'rake', '~> 0.8'
|
27
27
|
gem.add_development_dependency 'rspec', '~> 2'
|
28
28
|
gem.add_development_dependency 'yard'
|
data/lib/hallon.rb
CHANGED
@@ -49,12 +49,7 @@ Thread.abort_on_exception = true
|
|
49
49
|
# be looking for the documentation on {Hallon::Session}.
|
50
50
|
module Hallon
|
51
51
|
# @see Spotify::API_VERSION
|
52
|
-
API_VERSION = Spotify::API_VERSION
|
53
|
-
|
54
|
-
# Spotify API build.
|
55
|
-
#
|
56
|
-
# @see Spotify#api_build
|
57
|
-
API_BUILD = Spotify.build_id
|
52
|
+
API_VERSION = Spotify::API_VERSION.to_i
|
58
53
|
|
59
54
|
# A regex that matches all Spotify URIs
|
60
55
|
#
|
data/lib/hallon/album.rb
CHANGED
@@ -41,9 +41,9 @@ module Hallon
|
|
41
41
|
# link = Hallon::Link.new("spotify:album:6TECAywzyJGh0kwxfeBgGc")
|
42
42
|
# album = Hallon::Album.new(link)
|
43
43
|
#
|
44
|
-
# @param [String, Link, Spotify::
|
44
|
+
# @param [String, Link, Spotify::Album] link
|
45
45
|
def initialize(link)
|
46
|
-
@pointer = to_pointer(link,
|
46
|
+
@pointer = to_pointer(link, Spotify::Album)
|
47
47
|
end
|
48
48
|
|
49
49
|
# @return [String] name of the album.
|
@@ -74,7 +74,7 @@ module Hallon
|
|
74
74
|
|
75
75
|
# @return [Artist, nil] album artist.
|
76
76
|
def artist
|
77
|
-
artist = Spotify.album_artist
|
77
|
+
artist = Spotify.album_artist(pointer)
|
78
78
|
Artist.from(artist)
|
79
79
|
end
|
80
80
|
|
@@ -90,7 +90,7 @@ module Hallon
|
|
90
90
|
# @param [Symbol] size (see {Image.sizes})
|
91
91
|
# @return [Link, nil] album cover as a spotify URI.
|
92
92
|
def cover_link(size = :normal)
|
93
|
-
cover = Spotify.link_create_from_album_cover
|
93
|
+
cover = Spotify.link_create_from_album_cover(pointer, size)
|
94
94
|
Link.from(cover)
|
95
95
|
end
|
96
96
|
|
data/lib/hallon/album_browse.rb
CHANGED
@@ -20,7 +20,7 @@ module Hallon
|
|
20
20
|
size :albumbrowse_num_tracks
|
21
21
|
|
22
22
|
# @return [Track, nil]
|
23
|
-
item :albumbrowse_track
|
23
|
+
item :albumbrowse_track do |track|
|
24
24
|
Track.from(track)
|
25
25
|
end
|
26
26
|
end
|
@@ -31,18 +31,18 @@ module Hallon
|
|
31
31
|
# Creates an AlbumBrowse instance from an Album or an Album pointer.
|
32
32
|
#
|
33
33
|
# @note Also {Album#browse} to browse an Album.
|
34
|
-
# @param [Album, Spotify::
|
34
|
+
# @param [Album, Spotify::Album] album
|
35
35
|
def initialize(album)
|
36
36
|
pointer = album
|
37
37
|
pointer = pointer.pointer if pointer.respond_to?(:pointer)
|
38
38
|
|
39
|
-
unless
|
39
|
+
unless pointer.is_a?(Spotify::Album)
|
40
40
|
given = pointer.respond_to?(:type) ? pointer.type : pointer.inspect
|
41
41
|
raise TypeError, "expected album pointer, was given #{given}"
|
42
42
|
end
|
43
43
|
|
44
44
|
subscribe_for_callbacks do |callback|
|
45
|
-
@pointer = Spotify.albumbrowse_create
|
45
|
+
@pointer = Spotify.albumbrowse_create(session.pointer, pointer, callback, nil)
|
46
46
|
end
|
47
47
|
|
48
48
|
raise FFI::NullPointerError, "album browsing failed" if @pointer.null?
|
@@ -66,13 +66,13 @@ module Hallon
|
|
66
66
|
|
67
67
|
# @return [Artist, nil] artist performing this album.
|
68
68
|
def artist
|
69
|
-
artist = Spotify.albumbrowse_artist
|
69
|
+
artist = Spotify.albumbrowse_artist(pointer)
|
70
70
|
Artist.from(artist)
|
71
71
|
end
|
72
72
|
|
73
73
|
# @return [Album, nil] album this object is browsing.
|
74
74
|
def album
|
75
|
-
album = Spotify.albumbrowse_album
|
75
|
+
album = Spotify.albumbrowse_album(pointer)
|
76
76
|
Album.from(album)
|
77
77
|
end
|
78
78
|
|
data/lib/hallon/artist.rb
CHANGED
@@ -28,9 +28,9 @@ module Hallon
|
|
28
28
|
# link = Hallon::Link.new("spotify:artist:6uSKeCyQEhvPC2NODgiqFE")
|
29
29
|
# artist = Hallon::Artist.new(link)
|
30
30
|
#
|
31
|
-
# @param [String, Link,
|
31
|
+
# @param [String, Link, Spotify::Artist] link
|
32
32
|
def initialize(link)
|
33
|
-
@pointer = to_pointer(link,
|
33
|
+
@pointer = to_pointer(link, Spotify::Artist)
|
34
34
|
end
|
35
35
|
|
36
36
|
# @return [String] name of the artist.
|
@@ -55,7 +55,7 @@ module Hallon
|
|
55
55
|
# @param [Symbol] size (see {Image.sizes})
|
56
56
|
# @return [Link, nil] artist portrait as a Link.
|
57
57
|
def portrait_link(size = :normal)
|
58
|
-
portrait = Spotify.link_create_from_artist_portrait
|
58
|
+
portrait = Spotify.link_create_from_artist_portrait(pointer, size)
|
59
59
|
Link.from(portrait)
|
60
60
|
end
|
61
61
|
|
data/lib/hallon/artist_browse.rb
CHANGED
@@ -21,7 +21,7 @@ module Hallon
|
|
21
21
|
size :artistbrowse_num_portraits
|
22
22
|
|
23
23
|
# @return [Link, nil]
|
24
|
-
item :link_create_from_artistbrowse_portrait
|
24
|
+
item :link_create_from_artistbrowse_portrait do |portrait|
|
25
25
|
Link.from(portrait)
|
26
26
|
end
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module Hallon
|
|
31
31
|
size :artistbrowse_num_tracks
|
32
32
|
|
33
33
|
# @return [Track, nil]
|
34
|
-
item :artistbrowse_track
|
34
|
+
item :artistbrowse_track do |track|
|
35
35
|
Track.from(track)
|
36
36
|
end
|
37
37
|
end
|
@@ -41,7 +41,7 @@ module Hallon
|
|
41
41
|
size :artistbrowse_num_albums
|
42
42
|
|
43
43
|
# @return [Album, nil]
|
44
|
-
item :artistbrowse_album
|
44
|
+
item :artistbrowse_album do |album|
|
45
45
|
Album.from(album)
|
46
46
|
end
|
47
47
|
end
|
@@ -51,7 +51,7 @@ module Hallon
|
|
51
51
|
size :artistbrowse_num_similar_artists
|
52
52
|
|
53
53
|
# @return [Artist, nil]
|
54
|
-
item :artistbrowse_similar_artist
|
54
|
+
item :artistbrowse_similar_artist do |artist|
|
55
55
|
Artist.from(artist)
|
56
56
|
end
|
57
57
|
end
|
@@ -61,7 +61,7 @@ module Hallon
|
|
61
61
|
size :artistbrowse_num_tophit_tracks
|
62
62
|
|
63
63
|
# @return [Track, nil]
|
64
|
-
item :artistbrowse_tophit_track
|
64
|
+
item :artistbrowse_tophit_track do |track|
|
65
65
|
Track.from(track)
|
66
66
|
end
|
67
67
|
end
|
@@ -77,19 +77,19 @@ module Hallon
|
|
77
77
|
# Creates an ArtistBrowse instance from an Artist or an Artist pointer.
|
78
78
|
#
|
79
79
|
# @note Also use {Artist#browse} to browse an Artist.
|
80
|
-
# @param [Artist, Spotify::
|
80
|
+
# @param [Artist, Spotify::Artist] artist
|
81
81
|
# @param [Symbol] type (see {.types})
|
82
82
|
def initialize(artist, type = :full)
|
83
83
|
pointer = artist
|
84
84
|
pointer = pointer.pointer if pointer.respond_to?(:pointer)
|
85
85
|
|
86
|
-
unless
|
86
|
+
unless pointer.is_a?(Spotify::Artist)
|
87
87
|
given = pointer.respond_to?(:type) ? pointer.type : pointer.inspect
|
88
88
|
raise TypeError, "expected artist pointer, was given #{given}"
|
89
89
|
end
|
90
90
|
|
91
91
|
subscribe_for_callbacks do |callback|
|
92
|
-
@pointer = Spotify.artistbrowse_create
|
92
|
+
@pointer = Spotify.artistbrowse_create(session.pointer, pointer, type, callback, nil)
|
93
93
|
end
|
94
94
|
|
95
95
|
raise FFI::NullPointerError, "artist browsing failed" if @pointer.null?
|
@@ -108,7 +108,7 @@ module Hallon
|
|
108
108
|
|
109
109
|
# @return [Artist, nil] artist this browser is browsing.
|
110
110
|
def artist
|
111
|
-
artist = Spotify.artistbrowse_artist
|
111
|
+
artist = Spotify.artistbrowse_artist(pointer)
|
112
112
|
Artist.from(artist)
|
113
113
|
end
|
114
114
|
|
data/lib/hallon/audio_queue.rb
CHANGED
data/lib/hallon/base.rb
CHANGED
@@ -57,8 +57,8 @@ module Hallon
|
|
57
57
|
# @method from_link
|
58
58
|
# @scope instance
|
59
59
|
# @visibility private
|
60
|
-
# @param [String, Hallon::Link, Spotify::
|
61
|
-
# @return [Spotify::
|
60
|
+
# @param [String, Hallon::Link, Spotify::Link] link
|
61
|
+
# @return [Spotify::Link] pointer representation of given link.
|
62
62
|
def self.from_link(as_object, &block)
|
63
63
|
# this is here to work around a YARD limitation, see
|
64
64
|
# {Linkable} for the actual source
|
@@ -73,18 +73,18 @@ module Hallon
|
|
73
73
|
|
74
74
|
# Convert a given object to a pointer by best of ability.
|
75
75
|
#
|
76
|
-
# @param [Spotify::
|
77
|
-
# @return [Spotify::
|
76
|
+
# @param [Spotify::ManagedPointer, String, Link] resource
|
77
|
+
# @return [Spotify::ManagedPointer]
|
78
78
|
# @raise [TypeError] when the pointer is of the wrong type
|
79
79
|
# @raise [ArgumentError] when pointer could not be created, or null
|
80
80
|
def to_pointer(resource, type, *args)
|
81
|
-
if resource.is_a?(FFI::Pointer) and not resource.is_a?(Spotify::
|
82
|
-
raise TypeError, "Hallon does not support raw FFI::Pointers, wrap it in a Spotify::
|
81
|
+
if resource.is_a?(FFI::Pointer) and not resource.is_a?(Spotify::ManagedPointer)
|
82
|
+
raise TypeError, "Hallon does not support raw FFI::Pointers, wrap it in a Spotify::ManagedPointer"
|
83
83
|
end
|
84
84
|
|
85
|
-
pointer = if
|
85
|
+
pointer = if resource.is_a?(type)
|
86
86
|
resource
|
87
|
-
elsif is_linkable? and
|
87
|
+
elsif is_linkable? and resource.is_a?(Spotify::Link)
|
88
88
|
from_link(resource, *args)
|
89
89
|
elsif is_linkable? and Link.valid?(resource)
|
90
90
|
from_link(resource, *args)
|
@@ -94,8 +94,8 @@ module Hallon
|
|
94
94
|
|
95
95
|
if pointer.nil? or pointer.null?
|
96
96
|
raise ArgumentError, "#{resource.inspect} could not be converted to a spotify #{type} pointer"
|
97
|
-
elsif not
|
98
|
-
raise TypeError, "“#{resource}” is
|
97
|
+
elsif not pointer.is_a?(type)
|
98
|
+
raise TypeError, "“#{resource}” is a #{resource.class}, #{type} expected"
|
99
99
|
else
|
100
100
|
pointer
|
101
101
|
end
|