spotify 10.2.0 → 10.2.1

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.
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
@@ -1,3 +1,7 @@
1
+ [v10.2.1][]
2
+ -----------
3
+ - make all strings (both input and output) be in UTF8
4
+
1
5
  [v10.2.0][]
2
6
  -----------
3
7
  - make :sampletypes an array of *actual* FFI types that can be read
@@ -77,6 +81,7 @@ v0.0.0
77
81
  ------
78
82
  - release to register rubygems.org name
79
83
 
84
+ [v10.2.1]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.2.0...v10.2.1
80
85
  [v10.2.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.1.1...v10.2.0
81
86
  [v10.1.1]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.1.0...v10.1.1
82
87
  [v10.1.0]: https://github.com/Burgestrand/libspotify-ruby/compare/v10.0.0...v10.1.0
data/Rakefile CHANGED
@@ -1,5 +1,9 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ begin
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+ rescue LoadError
5
+ # do not require bundler rake tasks
6
+ end
3
7
 
4
8
  require 'rake/testtask'
5
9
  Rake::TestTask.new do |spec|
@@ -9,5 +13,10 @@ end
9
13
  require 'yard'
10
14
  YARD::Rake::YardocTask.new
11
15
 
16
+ desc "re-generate spec/api.h.xml"
17
+ task :gen do
18
+ sh 'gccxml spec/api.h -fxml=spec/api.h.xml'
19
+ end
20
+
12
21
  task :spec => :test
13
- task :default => :test
22
+ task :default => :test
@@ -12,6 +12,29 @@ module Spotify
12
12
  extend FFI::Library
13
13
  ffi_lib ['libspotify', '/Library/Frameworks/libspotify.framework/libspotify']
14
14
 
15
+ module UTF8String
16
+ extend FFI::DataConverter
17
+ native_type FFI::Type::STRING
18
+
19
+ # convert a Ruby string of any encoding to UTF-8 string
20
+ def self.to_native(value, ctx)
21
+ if value.respond_to?(:encode)
22
+ value.encode('UTF-8')
23
+ else
24
+ value
25
+ end
26
+ end
27
+
28
+ # converts encoding from native BINARY string to UTF-8
29
+ def self.from_native(value, ctx)
30
+ if value.respond_to?(:force_encoding)
31
+ value.force_encoding('UTF-8')
32
+ else
33
+ super
34
+ end
35
+ end
36
+ end
37
+
15
38
  # Override FFI::Library#attach_function to always add the `:blocking` option.
16
39
  #
17
40
  # The reason for this is that which libspotify functions may call callbacks
@@ -19,7 +42,7 @@ module Spotify
19
42
  def self.attach_function(*arguments, &block)
20
43
  options = arguments.pop if arguments.last.is_a?(Hash)
21
44
  options ||= {}
22
- options = { blocking: true }.merge(options)
45
+ options = { :blocking => true }.merge(options)
23
46
  arguments << options
24
47
  super(*arguments, &block)
25
48
  end
@@ -49,6 +72,8 @@ module Spotify
49
72
  typedef :pointer, :image_id
50
73
  typedef :pointer, :array
51
74
 
75
+ typedef UTF8String, :utf8_string
76
+
52
77
  #
53
78
  # Error
54
79
  #
@@ -80,13 +105,13 @@ module Spotify
80
105
  #
81
106
  # @method $1($3)
82
107
  # @return [$4]
83
- attach_function :error_message, :sp_error_message, [ :error ], :string
108
+ attach_function :error_message, :sp_error_message, [ :error ], :utf8_string
84
109
 
85
110
  #
86
111
  # Miscellaneous
87
112
  #
88
113
  # These don’t fit anywhere else :(
89
- attach_function :build_id, :sp_build_id, [], :string
114
+ attach_function :build_id, :sp_build_id, [], :utf8_string
90
115
 
91
116
  #
92
117
  # Audio
@@ -128,11 +153,11 @@ module Spotify
128
153
  # @attr [callback(:session):void] logged_out
129
154
  # @attr [callback(:session):void] metadata_updated
130
155
  # @attr [callback(:session, :error):void] connection_error
131
- # @attr [callback(:session, :string):void] message_to_user
156
+ # @attr [callback(:session, :utf8_string):void] message_to_user
132
157
  # @attr [callback(:session):void] notify_main_thread
133
158
  # @attr [callback(:session, AudioFormat, :frames, :int):int] music_delivery
134
159
  # @attr [callback(:session):void] play_token_lost
135
- # @attr [callback(:session, :string):void] log_message
160
+ # @attr [callback(:session, :utf8_string):void] log_message
136
161
  # @attr [callback(:session):void] end_of_track
137
162
  # @attr [callback(:session, :error):void] streaming_error
138
163
  # @attr [callback(:session):void] userinfo_updated
@@ -145,11 +170,11 @@ module Spotify
145
170
  :logged_out, callback([ :session ], :void),
146
171
  :metadata_updated, callback([ :session ], :void),
147
172
  :connection_error, callback([ :session, :error ], :void),
148
- :message_to_user, callback([ :session, :string ], :void),
173
+ :message_to_user, callback([ :session, :utf8_string ], :void),
149
174
  :notify_main_thread, callback([ :session ], :void),
150
175
  :music_delivery, callback([ :session, AudioFormat, :frames, :int ], :int),
151
176
  :play_token_lost, callback([ :session ], :void),
152
- :log_message, callback([ :session, :string ], :void),
177
+ :log_message, callback([ :session, :utf8_string ], :void),
153
178
  :end_of_track, callback([ :session ], :void),
154
179
  :streaming_error, callback([ :session, :error ], :void),
155
180
  :userinfo_updated, callback([ :session ], :void),
@@ -226,7 +251,7 @@ module Spotify
226
251
  attach_function :session_release, :sp_session_release, [ :session ], :void
227
252
 
228
253
  attach_function :session_process_events, :sp_session_process_events, [ :session, :buffer_out ], :void
229
- attach_function :session_login, :sp_session_login, [ :session, :string, :string, :bool ], :void
254
+ attach_function :session_login, :sp_session_login, [ :session, :utf8_string, :utf8_string, :bool ], :void
230
255
  attach_function :session_relogin, :sp_session_relogin, [ :session ], :error
231
256
  attach_function :session_forget_me, :sp_session_forget_me, [ :session ], :void
232
257
  attach_function :session_remembered_user, :sp_session_remembered_user, [ :session, :buffer_out, :size_t ], :int
@@ -244,8 +269,8 @@ module Spotify
244
269
  attach_function :session_playlistcontainer, :sp_session_playlistcontainer, [ :session ], :playlistcontainer
245
270
  attach_function :session_inbox_create, :sp_session_inbox_create, [ :session ], :playlist
246
271
  attach_function :session_starred_create, :sp_session_starred_create, [ :session ], :playlist
247
- attach_function :session_starred_for_user_create, :sp_session_starred_for_user_create, [ :session, :string ], :playlist
248
- attach_function :session_publishedcontainer_for_user_create, :sp_session_publishedcontainer_for_user_create, [ :playlist, :string ], :playlistcontainer
272
+ attach_function :session_starred_for_user_create, :sp_session_starred_for_user_create, [ :session, :utf8_string ], :playlist
273
+ attach_function :session_publishedcontainer_for_user_create, :sp_session_publishedcontainer_for_user_create, [ :playlist, :utf8_string ], :playlistcontainer
249
274
  attach_function :session_preferred_bitrate, :sp_session_preferred_bitrate, [ :session, :bitrate ], :void
250
275
 
251
276
  attach_function :session_set_connection_type, :sp_session_set_connection_type, [ :session, :connection_type ], :void
@@ -271,7 +296,7 @@ module Spotify
271
296
  enum :linktype, [:invalid, :track, :album, :artist, :search,
272
297
  :playlist, :profile, :starred, :localtrack, :image]
273
298
 
274
- attach_function :link_create_from_string, :sp_link_create_from_string, [ :string ], :link
299
+ attach_function :link_create_from_string, :sp_link_create_from_string, [ :utf8_string ], :link
275
300
  attach_function :link_create_from_track, :sp_link_create_from_track, [ :track, :int ], :link
276
301
  attach_function :link_create_from_album, :sp_link_create_from_album, [ :album ], :link
277
302
  attach_function :link_create_from_artist, :sp_link_create_from_artist, [ :artist ], :link
@@ -314,7 +339,7 @@ module Spotify
314
339
  attach_function :track_num_artists, :sp_track_num_artists, [ :track ], :int
315
340
  attach_function :track_artist, :sp_track_artist, [ :track, :int ], :artist
316
341
  attach_function :track_album, :sp_track_album, [ :track ], :album
317
- attach_function :track_name, :sp_track_name, [ :track ], :string
342
+ attach_function :track_name, :sp_track_name, [ :track ], :utf8_string
318
343
  attach_function :track_duration, :sp_track_duration, [ :track ], :int
319
344
  attach_function :track_popularity, :sp_track_popularity, [ :track ], :int
320
345
  attach_function :track_disc, :sp_track_disc, [ :track ], :int
@@ -323,7 +348,7 @@ module Spotify
323
348
 
324
349
  attach_function :track_offline_get_status, :sp_track_offline_get_status, [ :track ], :track_offline_status
325
350
 
326
- attach_function :localtrack_create, :sp_localtrack_create, [ :string, :string, :string, :int ], :track
351
+ attach_function :localtrack_create, :sp_localtrack_create, [ :utf8_string, :utf8_string, :utf8_string, :int ], :track
327
352
 
328
353
  attach_function :track_add_ref, :sp_track_add_ref, [ :track ], :void
329
354
  attach_function :track_release, :sp_track_release, [ :track ], :void
@@ -340,7 +365,7 @@ module Spotify
340
365
  attach_function :album_is_available, :sp_album_is_available, [ :album ], :bool
341
366
  attach_function :album_artist, :sp_album_artist, [ :album ], :artist
342
367
  attach_function :album_cover, :sp_album_cover, [ :album ], :image_id
343
- attach_function :album_name, :sp_album_name, [ :album ], :string
368
+ attach_function :album_name, :sp_album_name, [ :album ], :utf8_string
344
369
  attach_function :album_year, :sp_album_year, [ :album ], :int
345
370
  attach_function :album_type, :sp_album_type, [ :album ], :albumtype
346
371
 
@@ -360,10 +385,10 @@ module Spotify
360
385
  attach_function :albumbrowse_album, :sp_albumbrowse_album, [ :albumbrowse ], :album
361
386
  attach_function :albumbrowse_artist, :sp_albumbrowse_artist, [ :albumbrowse ], :artist
362
387
  attach_function :albumbrowse_num_copyrights, :sp_albumbrowse_num_copyrights, [ :albumbrowse ], :int
363
- attach_function :albumbrowse_copyright, :sp_albumbrowse_copyright, [ :albumbrowse, :int ], :string
388
+ attach_function :albumbrowse_copyright, :sp_albumbrowse_copyright, [ :albumbrowse, :int ], :utf8_string
364
389
  attach_function :albumbrowse_num_tracks, :sp_albumbrowse_num_tracks, [ :albumbrowse ], :int
365
390
  attach_function :albumbrowse_track, :sp_albumbrowse_track, [ :albumbrowse, :int ], :track
366
- attach_function :albumbrowse_review, :sp_albumbrowse_review, [ :albumbrowse ], :string
391
+ attach_function :albumbrowse_review, :sp_albumbrowse_review, [ :albumbrowse ], :utf8_string
367
392
  attach_function :albumbrowse_backend_request_duration, :sp_albumbrowse_backend_request_duration, [ :albumbrowse ], :int
368
393
 
369
394
  attach_function :albumbrowse_add_ref, :sp_albumbrowse_add_ref, [ :albumbrowse ], :void
@@ -375,7 +400,7 @@ module Spotify
375
400
  # @see http://developer.spotify.com/en/libspotify/docs/group__artist.html
376
401
 
377
402
  #
378
- attach_function :artist_name, :sp_artist_name, [ :artist ], :string
403
+ attach_function :artist_name, :sp_artist_name, [ :artist ], :utf8_string
379
404
  attach_function :artist_is_loaded, :sp_artist_is_loaded, [ :artist ], :bool
380
405
  attach_function :artist_portrait, :sp_artist_portrait, [ :artist ], :image_id
381
406
 
@@ -403,7 +428,7 @@ module Spotify
403
428
  attach_function :artistbrowse_album, :sp_artistbrowse_album, [ :artistbrowse, :int ], :album
404
429
  attach_function :artistbrowse_num_similar_artists, :sp_artistbrowse_num_similar_artists, [ :artistbrowse ], :int
405
430
  attach_function :artistbrowse_similar_artist, :sp_artistbrowse_similar_artist, [ :artistbrowse, :int ], :artist
406
- attach_function :artistbrowse_biography, :sp_artistbrowse_biography, [ :artistbrowse ], :string
431
+ attach_function :artistbrowse_biography, :sp_artistbrowse_biography, [ :artistbrowse ], :utf8_string
407
432
  attach_function :artistbrowse_backend_request_duration, :sp_artistbrowse_backend_request_duration, [ :artistbrowse ], :int
408
433
 
409
434
  attach_function :artistbrowse_add_ref, :sp_artistbrowse_add_ref, [ :artistbrowse ], :void
@@ -459,7 +484,7 @@ module Spotify
459
484
  ]
460
485
 
461
486
  callback :search_complete_cb, [:search, :userdata], :void
462
- attach_function :search_create, :sp_search_create, [ :session, :string, :int, :int, :int, :int, :int, :int, :search_complete_cb, :userdata ], :search
487
+ attach_function :search_create, :sp_search_create, [ :session, :utf8_string, :int, :int, :int, :int, :int, :int, :search_complete_cb, :userdata ], :search
463
488
  attach_function :radio_search_create, :sp_radio_search_create, [ :session, :uint, :uint, :radio_genre, :search_complete_cb, :userdata ], :search
464
489
  attach_function :search_is_loaded, :sp_search_is_loaded, [ :search ], :bool
465
490
  attach_function :search_error, :sp_search_error, [ :search ], :error
@@ -469,8 +494,8 @@ module Spotify
469
494
  attach_function :search_album, :sp_search_album, [ :search, :int ], :album
470
495
  attach_function :search_num_artists, :sp_search_num_artists, [ :search ], :int
471
496
  attach_function :search_artist, :sp_search_artist, [ :search, :int ], :artist
472
- attach_function :search_query, :sp_search_query, [ :search ], :string
473
- attach_function :search_did_you_mean, :sp_search_did_you_mean, [ :search ], :string
497
+ attach_function :search_query, :sp_search_query, [ :search ], :utf8_string
498
+ attach_function :search_did_you_mean, :sp_search_did_you_mean, [ :search ], :utf8_string
474
499
  attach_function :search_total_tracks, :sp_search_total_tracks, [ :search ], :int
475
500
  attach_function :search_total_albums, :sp_search_total_albums, [ :search ], :int
476
501
  attach_function :search_total_artists, :sp_search_total_artists, [ :search ], :int
@@ -494,9 +519,9 @@ module Spotify
494
519
  # @attr [callback(:playlist, :userdata):void] playlist_metadata_updated
495
520
  # @attr [callback(:playlist, :int, :user, :int, :userdata):void] track_created_changed
496
521
  # @attr [callback(:playlist, :int, :bool, :userdata):void] track_seen_changed
497
- # @attr [callback(:playlist, :string, :userdata):void] description_changed
522
+ # @attr [callback(:playlist, :utf8_string, :userdata):void] description_changed
498
523
  # @attr [callback(:playlist, :image_id, :userdata):void] image_changed
499
- # @attr [callback(:playlist, :int, :string, :userdata):void] track_message_changed
524
+ # @attr [callback(:playlist, :int, :utf8_string, :userdata):void] track_message_changed
500
525
  # @attr [callback(:playlist, :userdata):void] subscribers_changed
501
526
  class PlaylistCallbacks < FFI::Struct
502
527
  layout :tracks_added, callback([ :playlist, :array, :int, :int, :userdata ], :void),
@@ -508,9 +533,9 @@ module Spotify
508
533
  :playlist_metadata_updated, callback([ :playlist, :userdata ], :void),
509
534
  :track_created_changed, callback([ :playlist, :int, :user, :int, :userdata ], :void),
510
535
  :track_seen_changed, callback([ :playlist, :int, :bool, :userdata ], :void),
511
- :description_changed, callback([ :playlist, :string, :userdata ], :void),
536
+ :description_changed, callback([ :playlist, :utf8_string, :userdata ], :void),
512
537
  :image_changed, callback([ :playlist, :image_id, :userdata ], :void),
513
- :track_message_changed, callback([ :playlist, :int, :string, :userdata ], :void),
538
+ :track_message_changed, callback([ :playlist, :int, :utf8_string, :userdata ], :void),
514
539
  :subscribers_changed, callback([ :playlist, :userdata ], :void)
515
540
  end
516
541
 
@@ -551,14 +576,14 @@ module Spotify
551
576
  attach_function :playlist_track_creator, :sp_playlist_track_creator, [ :playlist, :int ], :user
552
577
  attach_function :playlist_track_seen, :sp_playlist_track_seen, [ :playlist, :int ], :bool
553
578
  attach_function :playlist_track_set_seen, :sp_playlist_track_set_seen, [ :playlist, :int, :bool ], :error
554
- attach_function :playlist_track_message, :sp_playlist_track_message, [ :playlist, :int ], :string
555
- attach_function :playlist_name, :sp_playlist_name, [ :playlist ], :string
556
- attach_function :playlist_rename, :sp_playlist_rename, [ :playlist, :string ], :error
579
+ attach_function :playlist_track_message, :sp_playlist_track_message, [ :playlist, :int ], :utf8_string
580
+ attach_function :playlist_name, :sp_playlist_name, [ :playlist ], :utf8_string
581
+ attach_function :playlist_rename, :sp_playlist_rename, [ :playlist, :utf8_string ], :error
557
582
  attach_function :playlist_owner, :sp_playlist_owner, [ :playlist ], :user
558
583
  attach_function :playlist_is_collaborative, :sp_playlist_is_collaborative, [ :playlist ], :bool
559
584
  attach_function :playlist_set_collaborative, :sp_playlist_set_collaborative, [ :playlist, :bool ], :void
560
585
  attach_function :playlist_set_autolink_tracks, :sp_playlist_set_autolink_tracks, [ :playlist, :bool ], :void
561
- attach_function :playlist_get_description, :sp_playlist_get_description, [ :playlist ], :string
586
+ attach_function :playlist_get_description, :sp_playlist_get_description, [ :playlist ], :utf8_string
562
587
  attach_function :playlist_get_image, :sp_playlist_get_image, [ :playlist, :image_id ], :bool
563
588
  attach_function :playlist_has_pending_changes, :sp_playlist_has_pending_changes, [ :playlist ], :bool
564
589
  attach_function :playlist_add_tracks, :sp_playlist_add_tracks, [ :playlist, :array, :int, :int, :session ], :error
@@ -603,11 +628,11 @@ module Spotify
603
628
  attach_function :playlistcontainer_playlist_type, :sp_playlistcontainer_playlist_type, [ :playlistcontainer, :int ], :playlist_type
604
629
  attach_function :playlistcontainer_playlist_folder_name, :sp_playlistcontainer_playlist_folder_name, [ :playlistcontainer, :int, :buffer_out, :int ], :error
605
630
  attach_function :playlistcontainer_playlist_folder_id, :sp_playlistcontainer_playlist_folder_id, [ :playlistcontainer, :int ], :uint64
606
- attach_function :playlistcontainer_add_new_playlist, :sp_playlistcontainer_add_new_playlist, [ :playlistcontainer, :string ], :playlist
631
+ attach_function :playlistcontainer_add_new_playlist, :sp_playlistcontainer_add_new_playlist, [ :playlistcontainer, :utf8_string ], :playlist
607
632
  attach_function :playlistcontainer_add_playlist, :sp_playlistcontainer_add_playlist, [ :playlistcontainer, :link ], :playlist
608
633
  attach_function :playlistcontainer_remove_playlist, :sp_playlistcontainer_remove_playlist, [ :playlistcontainer, :int ], :error
609
634
  attach_function :playlistcontainer_move_playlist, :sp_playlistcontainer_move_playlist, [ :playlistcontainer, :int, :int, :bool ], :error
610
- attach_function :playlistcontainer_add_folder, :sp_playlistcontainer_add_folder, [ :playlistcontainer, :int, :string ], :error
635
+ attach_function :playlistcontainer_add_folder, :sp_playlistcontainer_add_folder, [ :playlistcontainer, :int, :utf8_string ], :error
611
636
  attach_function :playlistcontainer_owner, :sp_playlistcontainer_owner, [ :playlistcontainer ], :user
612
637
  attach_function :playlistcontainer_is_loaded, :sp_playlistcontainer_is_loaded, [ :playlistcontainer ], :bool
613
638
 
@@ -622,8 +647,8 @@ module Spotify
622
647
  #
623
648
  enum :relation_type, [:unknown, :none, :unidirectional, :bidirectional]
624
649
 
625
- attach_function :user_canonical_name, :sp_user_canonical_name, [ :user ], :string
626
- attach_function :user_display_name, :sp_user_display_name, [ :user ], :string
650
+ attach_function :user_canonical_name, :sp_user_canonical_name, [ :user ], :utf8_string
651
+ attach_function :user_display_name, :sp_user_display_name, [ :user ], :utf8_string
627
652
  attach_function :user_is_loaded, :sp_user_is_loaded, [ :user ], :bool
628
653
 
629
654
  attach_function :user_add_ref, :sp_user_add_ref, [ :user ], :void
@@ -639,7 +664,7 @@ module Spotify
639
664
  enum :toplistregion, [:everywhere, :user]
640
665
 
641
666
  callback :toplistbrowse_complete_cb, [:toplistbrowse, :userdata], :void
642
- attach_function :toplistbrowse_create, :sp_toplistbrowse_create, [ :session, :toplisttype, :toplistregion, :string, :toplistbrowse_complete_cb, :userdata ], :toplistbrowse
667
+ attach_function :toplistbrowse_create, :sp_toplistbrowse_create, [ :session, :toplisttype, :toplistregion, :utf8_string, :toplistbrowse_complete_cb, :userdata ], :toplistbrowse
643
668
  attach_function :toplistbrowse_is_loaded, :sp_toplistbrowse_is_loaded, [ :toplistbrowse ], :bool
644
669
  attach_function :toplistbrowse_error, :sp_toplistbrowse_error, [ :toplistbrowse ], :error
645
670
  attach_function :toplistbrowse_num_artists, :sp_toplistbrowse_num_artists, [ :toplistbrowse ], :int
@@ -660,7 +685,7 @@ module Spotify
660
685
 
661
686
  #
662
687
  callback :inboxpost_complete_cb, [:inbox, :userdata], :void
663
- attach_function :inbox_post_tracks, :sp_inbox_post_tracks, [ :session, :string, :array, :int, :string, :inboxpost_complete_cb, :userdata ], :inbox
688
+ attach_function :inbox_post_tracks, :sp_inbox_post_tracks, [ :session, :utf8_string, :array, :int, :utf8_string, :inboxpost_complete_cb, :userdata ], :inbox
664
689
  attach_function :inbox_error, :sp_inbox_error, [ :inbox ], :error
665
690
 
666
691
  attach_function :inbox_add_ref, :sp_inbox_add_ref, [ :inbox ], :void
@@ -1,4 +1,4 @@
1
1
  module Spotify
2
2
  # See README for versioning policy.
3
- VERSION = [10, 2, 0].join('.')
3
+ VERSION = [10, 2, 1].join('.')
4
4
  end
@@ -1,9 +1,7 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- retry if require 'rubygems'
5
- end
1
+ # coding: utf-8
2
+ require 'rubygems' # needed for 1.8, does not matter in 1.9
6
3
 
4
+ require 'rbgccxml'
7
5
  require 'minitest/autorun'
8
6
 
9
7
  #
@@ -29,13 +27,23 @@ module Spotify
29
27
  attr_reader :attached_methods
30
28
  end
31
29
 
32
- Bundler.require(:default, :development)
30
+ require 'spotify'
31
+
32
+ module C
33
+ extend FFI::Library
34
+ ffi_lib 'C'
35
+
36
+ typedef Spotify::UTF8String, :utf8_string
37
+
38
+ attach_function :strncpy, [ :pointer, :utf8_string, :size_t ], :utf8_string
39
+ end
33
40
 
34
41
  #
35
42
  # Utility
36
43
  #
44
+
37
45
  API_H_PATH = File.expand_path('../api.h', __FILE__)
38
- API_H_SRC = File.read API_H_PATH
46
+ API_H_SRC = File.read(API_H_PATH)
39
47
  API_H_XML = RbGCCXML.parse(API_H_PATH)
40
48
 
41
49
  #
@@ -96,6 +104,31 @@ describe Spotify do
96
104
  end
97
105
  end
98
106
  end
107
+
108
+ describe "UTF8 string" do
109
+ let(:char) do
110
+ char = "\xC4"
111
+ char.force_encoding('ISO-8859-1') if char.respond_to?(:force_encoding)
112
+ char
113
+ end
114
+
115
+ it "should convert any strings to UTF-8 before reading and writing" do
116
+ dest = FFI::MemoryPointer.new(:char, 3) # two bytes for the ä, one for the NULL
117
+ result = C.strncpy(dest, char, 3)
118
+
119
+ result.encoding.must_equal Encoding::UTF_8
120
+ result.must_equal "Ä"
121
+ result.bytesize.must_equal 2
122
+ end if "".respond_to?(:force_encoding)
123
+
124
+ it "should do nothing if strings does not respond to #encode or #force_encoding" do
125
+ dest = FFI::MemoryPointer.new(:char, 3) # two bytes for the ä, one for the NULL
126
+ result = C.strncpy(dest, char, 3)
127
+
128
+ result.must_equal "\xC4"
129
+ result.bytesize.must_equal 1
130
+ end unless "".respond_to?(:force_encoding)
131
+ end
99
132
  end
100
133
 
101
134
  describe "functions" do
@@ -106,7 +139,7 @@ describe "functions" do
106
139
  def type_of(type, return_type = false)
107
140
  return case type.to_cpp
108
141
  when "const char*"
109
- :string
142
+ :utf8_string
110
143
  when /\A(::)?(char|int|size_t|sp_session\*)\*/
111
144
  return_type ? :pointer : :buffer_out
112
145
  when /::(.+_cb)\*/
@@ -165,7 +198,7 @@ describe "enums" do
165
198
  it "should match the definition" do
166
199
  attached_enum_map = attached_enum.symbol_map
167
200
  original_enum.each do |(name, value)|
168
- a_name, a_value = attached_enum_map.find { |(n, v)| name.match n.to_s }
201
+ a_name, a_value = attached_enum_map.max_by { |(n, v)| (n.to_s.length if name.match(n.to_s)).to_i }
169
202
  attached_enum_map.delete(a_name)
170
203
  a_value.to_s.must_equal value
171
204
  end
@@ -27,7 +27,5 @@ Gem::Specification.new do |gem|
27
27
  gem.add_development_dependency 'rake'
28
28
  gem.add_development_dependency 'yard'
29
29
  gem.add_development_dependency 'rbgccxml'
30
- gem.add_development_dependency 'gccxml_gem', '!= 0.9.3'
31
30
  gem.add_development_dependency 'minitest', '~> 2.0'
32
- gem.add_development_dependency 'bundler', '~> 1.0'
33
31
  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.2.0
4
+ version: 10.2.1
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-14 00:00:00.000000000 Z
12
+ date: 2011-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
- requirement: &70158630598380 !ruby/object:Gem::Requirement
16
+ requirement: &70128859865560 !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: *70158630598380
27
+ version_requirements: *70128859865560
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
- requirement: &70158630597040 !ruby/object:Gem::Requirement
30
+ requirement: &70128859862920 !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: *70158630597040
38
+ version_requirements: *70128859862920
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: yard
41
- requirement: &70158630594380 !ruby/object:Gem::Requirement
41
+ requirement: &70128859861560 !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: *70158630594380
49
+ version_requirements: *70128859861560
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rbgccxml
52
- requirement: &70158630605980 !ruby/object:Gem::Requirement
52
+ requirement: &70128859876120 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,21 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *70158630605980
61
- - !ruby/object:Gem::Dependency
62
- name: gccxml_gem
63
- requirement: &70158630603140 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ! '!='
67
- - !ruby/object:Gem::Version
68
- version: 0.9.3
69
- type: :development
70
- prerelease: false
71
- version_requirements: *70158630603140
60
+ version_requirements: *70128859876120
72
61
  - !ruby/object:Gem::Dependency
73
62
  name: minitest
74
- requirement: &70158630602340 !ruby/object:Gem::Requirement
63
+ requirement: &70128859872120 !ruby/object:Gem::Requirement
75
64
  none: false
76
65
  requirements:
77
66
  - - ~>
@@ -79,18 +68,7 @@ dependencies:
79
68
  version: '2.0'
80
69
  type: :development
81
70
  prerelease: false
82
- version_requirements: *70158630602340
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: &70158630616080 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ~>
89
- - !ruby/object:Gem::Version
90
- version: '1.0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: *70158630616080
71
+ version_requirements: *70128859872120
94
72
  description: ! " Spotify for Ruby is a primitive wrapper around libspotify using
95
73
  Ruby FFI.\n If all you want is libspotify for Ruby, you should probably use at
96
74
  Hallon\n instead: https://rubygems.org/gems/hallon\n"
@@ -102,6 +80,7 @@ extra_rdoc_files: []
102
80
  files:
103
81
  - .gemtest
104
82
  - .gitignore
83
+ - .travis.yml
105
84
  - CHANGELOG.md
106
85
  - Gemfile
107
86
  - LICENSE