spotify 0.0.0 → 7.0.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.
@@ -0,0 +1,120 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/spec'
4
+
5
+ begin require 'minitest-rg'
6
+ rescue LoadError; end
7
+
8
+ require 'rbgccxml'
9
+
10
+ #
11
+ # Hooking FFI for extra introspection
12
+ #
13
+ require 'ffi'
14
+
15
+ module Spotify
16
+ extend FFI::Library
17
+ extend self
18
+
19
+ def attach_function(name, func, arguments, returns = nil, options = nil)
20
+ args = [name, func, arguments, returns, options].compact
21
+ args.unshift name.to_s if func.is_a?(Array)
22
+
23
+ hargs = [:name, :func, :args, :returns].zip args
24
+ @attached_methods ||= {}
25
+ @attached_methods[name.to_s] = hash = Hash[hargs]
26
+
27
+ super
28
+ end
29
+
30
+ attr_reader :attached_methods
31
+ end
32
+
33
+ require 'spotify'
34
+
35
+ #
36
+ # Utility
37
+ #
38
+ API_H_PATH = File.expand_path('../api.h', __FILE__)
39
+ API_H_SRC = File.read API_H_PATH
40
+ API_H_XML = RbGCCXML.parse(API_H_PATH)
41
+
42
+ #
43
+ # General
44
+ #
45
+ describe Spotify do
46
+ describe "VERSION" do
47
+ it "should be defined" do
48
+ defined?(Spotify::VERSION).must_equal "constant"
49
+ end
50
+
51
+ it "should be the same version as in api.h" do
52
+ spotify_version = API_H_SRC.match(/#define\s+SPOTIFY_API_VERSION\s+(\d+)/)[1]
53
+ Spotify::API_VERSION.must_equal spotify_version.to_i
54
+ end
55
+ end
56
+ end
57
+
58
+ describe "functions" do
59
+ API_H_XML.functions.each do |func|
60
+ next unless func["name"] =~ /\Asp_/
61
+ attached_name = func["name"].sub(/\Asp_/, '')
62
+
63
+ describe func["name"] do
64
+ it "should be attached" do
65
+ Spotify.must_respond_to attached_name
66
+ end
67
+
68
+ it "should expect the correct number of arguments" do
69
+ Spotify.attached_methods[attached_name][:args].count.
70
+ must_equal func.arguments.count
71
+ end
72
+
73
+ # it "should expect the correct types of arguments"
74
+ # it "should return the correct type"
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "enums" do
80
+ API_H_XML.enumerations.each do |enum|
81
+ attached_enum = Spotify.enum_type enum["name"].sub(/\Asp_/, '').to_sym
82
+ original_enum = Hash[enum.values.map do |v|
83
+ [v["name"].downcase, v["init"]]
84
+ end]
85
+
86
+ describe enum["name"] do
87
+ it "should exist" do
88
+ attached_enum.wont_be_nil
89
+ end
90
+
91
+ it "should match the definition" do
92
+ attached_enum.symbol_map.sort_by { |k, v| -k.size }.each do |(key, value)|
93
+ k, v = original_enum.find { |x, _| x.match key.to_s }
94
+ v.must_equal value.to_s
95
+ original_enum.delete(k)
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "structs" do
103
+ API_H_XML.structs.each do |struct|
104
+ next if struct["incomplete"]
105
+
106
+ attached_struct = Spotify.constants.find do |const|
107
+ struct["name"].gsub('_', '').match(/#{const}/i)
108
+ end
109
+
110
+ describe struct["name"] do
111
+ it "should contain the same attributes" do
112
+ original_members = struct.variables.map(&:name)
113
+
114
+ Spotify.const_get(attached_struct).members.each do |member|
115
+ original_members.must_include member.to_s
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -3,7 +3,7 @@ require './lib/spotify/version'
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'spotify'
6
- gem.summary = 'Clean-cut Ruby bindings to libspotify'
6
+ gem.summary = 'Bare-bones Ruby bindings for libspotify'
7
7
  gem.homepage = 'https://github.com/Burgestrand/libspotify-ruby'
8
8
  gem.authors = ["Kim Burgestrand"]
9
9
  gem.email = ['kim@burgestrand.se']
@@ -18,4 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.platform = Gem::Platform::RUBY
19
19
 
20
20
  gem.add_dependency 'ffi', '~> 1.0.0'
21
+ gem.add_development_dependency 'yard'
22
+ gem.add_development_dependency 'rbgccxml'
23
+ gem.add_development_dependency 'minitest', '~> 2.0.0'
21
24
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: spotify
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.0
5
+ version: 7.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kim Burgestrand
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-07 00:00:00 +02:00
13
+ date: 2011-04-08 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -24,6 +24,39 @@ dependencies:
24
24
  version: 1.0.0
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: yard
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rbgccxml
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: minitest
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 2.0.0
58
+ type: :development
59
+ version_requirements: *id004
27
60
  description:
28
61
  email:
29
62
  - kim@burgestrand.se
@@ -36,9 +69,13 @@ extra_rdoc_files: []
36
69
  files:
37
70
  - .gitignore
38
71
  - Gemfile
72
+ - LICENSE
73
+ - README.markdown
39
74
  - Rakefile
40
75
  - lib/spotify.rb
41
76
  - lib/spotify/version.rb
77
+ - spec/api.h
78
+ - spec/spotify_spec.rb
42
79
  - spotify.gemspec
43
80
  has_rdoc: true
44
81
  homepage: https://github.com/Burgestrand/libspotify-ruby
@@ -67,6 +104,7 @@ rubyforge_project:
67
104
  rubygems_version: 1.6.2
68
105
  signing_key:
69
106
  specification_version: 3
70
- summary: Clean-cut Ruby bindings to libspotify
71
- test_files: []
72
-
107
+ summary: Bare-bones Ruby bindings for libspotify
108
+ test_files:
109
+ - spec/api.h
110
+ - spec/spotify_spec.rb