spotify 10.2.2 → 10.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/spotify.rb +24 -2
- data/lib/spotify/version.rb +1 -1
- data/spec/spotify_spec.rb +55 -4
- metadata +12 -12
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
[v10.3.0][]
|
2
|
+
-----------
|
3
|
+
- map :image_id to a ruby string instead of a pointer
|
4
|
+
|
1
5
|
[v10.2.2][]
|
2
6
|
-----------
|
3
7
|
- allow non-UTF8 strings for link_create_from_string and login password
|
@@ -85,6 +89,7 @@ v0.0.0
|
|
85
89
|
------
|
86
90
|
- release to register rubygems.org name
|
87
91
|
|
92
|
+
[v10.3.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.2.2...v10.3.0
|
88
93
|
[v10.2.2]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.2.1...v10.2.2
|
89
94
|
[v10.2.1]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.2.0...v10.2.1
|
90
95
|
[v10.2.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.1.1...v10.2.0
|
data/lib/spotify.rb
CHANGED
@@ -35,6 +35,28 @@ module Spotify
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
module ImageID
|
39
|
+
extend FFI::DataConverter
|
40
|
+
native_type FFI::Type::POINTER
|
41
|
+
|
42
|
+
def self.to_native(value, ctx)
|
43
|
+
pointer = if value
|
44
|
+
if value.bytesize != 20
|
45
|
+
raise ArgumentError, "image id bytesize must be 20, was #{value.bytesize}"
|
46
|
+
end
|
47
|
+
|
48
|
+
pointer = FFI::MemoryPointer.new(:char, 20)
|
49
|
+
pointer.write_string(value.to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
super(pointer, ctx)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.from_native(value, ctx)
|
56
|
+
value.read_string(20) unless value.null?
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
38
60
|
# Override FFI::Library#attach_function to always add the `:blocking` option.
|
39
61
|
#
|
40
62
|
# The reason for this is that which libspotify functions may call callbacks
|
@@ -69,10 +91,10 @@ module Spotify
|
|
69
91
|
typedef :pointer, :inbox
|
70
92
|
|
71
93
|
typedef :pointer, :userdata
|
72
|
-
typedef :pointer, :image_id
|
73
94
|
typedef :pointer, :array
|
74
95
|
|
75
96
|
typedef UTF8String, :utf8_string
|
97
|
+
typedef ImageID, :image_id
|
76
98
|
|
77
99
|
#
|
78
100
|
# Error
|
@@ -584,7 +606,7 @@ module Spotify
|
|
584
606
|
attach_function :playlist_set_collaborative, :sp_playlist_set_collaborative, [ :playlist, :bool ], :void
|
585
607
|
attach_function :playlist_set_autolink_tracks, :sp_playlist_set_autolink_tracks, [ :playlist, :bool ], :void
|
586
608
|
attach_function :playlist_get_description, :sp_playlist_get_description, [ :playlist ], :utf8_string
|
587
|
-
attach_function :playlist_get_image, :sp_playlist_get_image, [ :playlist, :
|
609
|
+
attach_function :playlist_get_image, :sp_playlist_get_image, [ :playlist, :buffer_out ], :bool
|
588
610
|
attach_function :playlist_has_pending_changes, :sp_playlist_has_pending_changes, [ :playlist ], :bool
|
589
611
|
attach_function :playlist_add_tracks, :sp_playlist_add_tracks, [ :playlist, :array, :int, :int, :session ], :error
|
590
612
|
attach_function :playlist_remove_tracks, :sp_playlist_remove_tracks, [ :playlist, :array, :int ], :error
|
data/lib/spotify/version.rb
CHANGED
data/spec/spotify_spec.rb
CHANGED
@@ -24,6 +24,12 @@ module Spotify
|
|
24
24
|
super
|
25
25
|
end
|
26
26
|
|
27
|
+
def resolve_type(type)
|
28
|
+
type = find_type(type)
|
29
|
+
type = type.type if type.respond_to?(:type)
|
30
|
+
type
|
31
|
+
end
|
32
|
+
|
27
33
|
attr_reader :attached_methods
|
28
34
|
end
|
29
35
|
|
@@ -129,6 +135,51 @@ describe Spotify do
|
|
129
135
|
result.bytesize.must_equal 1
|
130
136
|
end unless "".respond_to?(:force_encoding)
|
131
137
|
end
|
138
|
+
|
139
|
+
describe "Image ID" do
|
140
|
+
let(:context) { nil }
|
141
|
+
let(:subject) { Spotify.find_type(:image_id) }
|
142
|
+
let(:null_pointer) { FFI::Pointer::NULL }
|
143
|
+
|
144
|
+
let(:image_id_pointer) do
|
145
|
+
pointer = FFI::MemoryPointer.new(:char, 20)
|
146
|
+
pointer.write_string(image_id)
|
147
|
+
pointer
|
148
|
+
end
|
149
|
+
|
150
|
+
let(:image_id) do
|
151
|
+
# deliberate NULL in middle of string
|
152
|
+
image_id = ":\xD94#\xAD\xD9\x97f\xE0\x00V6\x05\xC6\xE7n\xD2\xB0\xE4P"
|
153
|
+
image_id.force_encoding("BINARY") if image_id.respond_to?(:force_encoding)
|
154
|
+
image_id
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "from_native" do
|
158
|
+
it "should be nil given a null pointer" do
|
159
|
+
subject.from_native(null_pointer, context).must_be_nil
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be an image id given a non-null pointer" do
|
163
|
+
subject.from_native(image_id_pointer, context).must_equal image_id
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "to_native" do
|
168
|
+
it "should be a null pointer given nil" do
|
169
|
+
subject.to_native(nil, context).must_be_nil
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should be a 20-byte C string given an actual string" do
|
173
|
+
pointer = subject.to_native(image_id, context)
|
174
|
+
pointer.read_string(20).must_equal image_id_pointer.read_string(20)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should raise an error given more or less than a 20 byte string" do
|
178
|
+
proc { subject.to_native(image_id + image_id, context) }.must_raise ArgumentError
|
179
|
+
proc { subject.to_native(image_id[0..10], context) }.must_raise ArgumentError
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
132
183
|
end
|
133
184
|
|
134
185
|
describe "functions" do
|
@@ -140,7 +191,7 @@ describe "functions" do
|
|
140
191
|
return case type.to_cpp
|
141
192
|
when "const char*"
|
142
193
|
:utf8_string
|
143
|
-
when /\A(::)?(char|int|size_t|sp_session
|
194
|
+
when /\A(::)?(char|int|size_t|sp_session\*|byte)\*/
|
144
195
|
return_type ? :pointer : :buffer_out
|
145
196
|
when /::(.+_cb)\*/
|
146
197
|
$1.to_sym
|
@@ -169,15 +220,15 @@ describe "functions" do
|
|
169
220
|
current = Spotify.attached_methods[attached_name][:returns]
|
170
221
|
actual = type_of(func.return_type, true)
|
171
222
|
|
172
|
-
Spotify.
|
223
|
+
Spotify.resolve_type(current).must_equal Spotify.resolve_type(actual)
|
173
224
|
end
|
174
225
|
|
175
226
|
it "should expect the correct types of arguments" do
|
176
227
|
current = Spotify.attached_methods[attached_name][:args]
|
177
228
|
actual = func.arguments.map { |arg| type_of(arg.cpp_type) }
|
178
229
|
|
179
|
-
current = current.map { |x| Spotify.
|
180
|
-
actual = actual.map { |x| Spotify.
|
230
|
+
current = current.map { |x| Spotify.resolve_type(x) }
|
231
|
+
actual = actual.map { |x| Spotify.resolve_type(x) }
|
181
232
|
|
182
233
|
current.must_equal actual
|
183
234
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.3.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: 2011-12-
|
12
|
+
date: 2011-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
16
|
-
requirement: &
|
16
|
+
requirement: &70144148345660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: 1.0.11
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70144148345660
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
|
-
requirement: &
|
30
|
+
requirement: &70144148344940 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '0'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70144148344940
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: yard
|
41
|
-
requirement: &
|
41
|
+
requirement: &70144148344440 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: '0'
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70144148344440
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: rbgccxml
|
52
|
-
requirement: &
|
52
|
+
requirement: &70144148343820 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: '0'
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70144148343820
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: minitest
|
63
|
-
requirement: &
|
63
|
+
requirement: &70144148343120 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: '2.0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70144148343120
|
72
72
|
description: ! " Spotify for Ruby is a primitive wrapper around libspotify using
|
73
73
|
Ruby FFI.\n If all you want is libspotify for Ruby, you should probably use at
|
74
74
|
Hallon\n instead: https://rubygems.org/gems/hallon\n"
|