mb-discid 0.1.0 → 0.1.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.
- data/README +14 -1
- data/Rakefile +15 -7
- data/examples/discid.rb +1 -1
- data/ext/extconf.rb +6 -2
- data/ext/{discid.c → mb_discid.c} +75 -53
- data/lib/mb-discid.rb +12 -0
- metadata +5 -3
data/README
CHANGED
@@ -9,9 +9,22 @@ to find the release entry for your CD in the MusicBrainz database.
|
|
9
9
|
Before installing rdiscid make sure you have libdiscid installed. See
|
10
10
|
http://musicbrainz.org/doc/libdiscid for more information on how to do this.
|
11
11
|
|
12
|
-
===
|
12
|
+
=== Installation with RubyGems
|
13
13
|
gem install mb-discid
|
14
14
|
|
15
|
+
== Installation on Windows operating systems.
|
16
|
+
For Windows a binary gem "mb-discid-0.1.1-mswin32.gem" is available. To install
|
17
|
+
it follow the instructions below:
|
18
|
+
|
19
|
+
1. Make sure you have at least Ruby 1.8.6 installed.
|
20
|
+
2. Install RubyGems, if you don't already have it.
|
21
|
+
3. Download "libdiscid-0.1.1-win32bin.zip" from
|
22
|
+
http://musicbrainz.org/doc/libdiscid.
|
23
|
+
4. Copy the file "discid.dll" from "libdiscid-0.1.1-win32bin.zip" to your Ruby
|
24
|
+
bin directory (normally "C:\ruby\bin".
|
25
|
+
5. Run "gem install mb-discid" to install MB-DiscID.
|
26
|
+
6. To test the installation try to run "discid.rb" in the examples directory.
|
27
|
+
|
15
28
|
=== Installing from source
|
16
29
|
rake install
|
17
30
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id$
|
1
|
+
# $Id: Rakefile 69 2007-06-03 14:14:25Z phw $
|
2
2
|
# Copyright (c) 2007, Philipp Wolfer
|
3
3
|
# All rights reserved.
|
4
4
|
# See LICENSE for permissions.
|
@@ -15,7 +15,7 @@ end
|
|
15
15
|
# Packaging tasks: -------------------------------------------------------
|
16
16
|
|
17
17
|
PKG_NAME = 'mb-discid'
|
18
|
-
PKG_VERSION = '0.1.
|
18
|
+
PKG_VERSION = '0.1.1'
|
19
19
|
PKG_SUMMARY = 'Ruby bindings for libdiscid.'
|
20
20
|
PKG_AUTHOR = 'Philipp Wolfer'
|
21
21
|
PKG_EMAIL = 'phw@rubyforge.org'
|
@@ -27,19 +27,27 @@ EOF
|
|
27
27
|
PKG_FILES = FileList[
|
28
28
|
'Rakefile', 'LICENSE', 'README',
|
29
29
|
'examples/**/*',
|
30
|
-
'ext/**/*.{c,rb}'
|
30
|
+
'ext/**/*.{c,rb}',
|
31
|
+
'lib/**/*.rb'
|
31
32
|
]
|
32
33
|
|
33
34
|
spec = Gem::Specification.new do |spec|
|
34
|
-
spec.platform = Gem::Platform::RUBY
|
35
35
|
spec.name = PKG_NAME
|
36
36
|
spec.version = PKG_VERSION
|
37
37
|
spec.summary = PKG_SUMMARY
|
38
|
+
if ENV['BINARY_GEM'] == 'win32'
|
39
|
+
spec.platform = Gem::Platform::WIN32
|
40
|
+
spec.files = PKG_FILES << 'ext/MB_DiscID.so'
|
41
|
+
spec.bindir = 'bin'
|
42
|
+
spec.required_ruby_version = ">= #{RUBY_VERSION}"
|
43
|
+
else
|
44
|
+
spec.platform = Gem::Platform::RUBY
|
45
|
+
spec.files = PKG_FILES
|
46
|
+
spec.extensions << 'ext/extconf.rb'
|
47
|
+
end
|
38
48
|
spec.requirements << 'libdiscid (http://musicbrainz.org/doc/libdiscid)'
|
39
|
-
spec.
|
49
|
+
spec.require_paths = ['lib', 'ext']
|
40
50
|
spec.autorequire = spec.name
|
41
|
-
spec.files = PKG_FILES
|
42
|
-
spec.extensions << 'ext/extconf.rb'
|
43
51
|
spec.description = PKG_DESCRIPTION
|
44
52
|
spec.author = PKG_AUTHOR
|
45
53
|
spec.email = PKG_EMAIL
|
data/examples/discid.rb
CHANGED
data/ext/extconf.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# $Id: extconf.rb 69 2007-06-03 14:14:25Z phw $
|
2
3
|
|
3
4
|
require 'mkmf'
|
4
5
|
|
5
|
-
if have_library('discid', 'discid_new')
|
6
|
-
|
6
|
+
if have_library('discid', 'discid_new') or
|
7
|
+
have_library('discid.dll', 'discid_new')
|
8
|
+
# Remove -MD from compiler flags on Windows.
|
9
|
+
$CFLAGS.sub!('-MD', '') if RUBY_PLATFORM.include? 'win32'
|
10
|
+
create_makefile('MB_DiscID')
|
7
11
|
else
|
8
12
|
puts 'Required library libdiscid not found.'
|
9
13
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*---------------------------------------------------------------------------
|
2
|
-
$Id:
|
2
|
+
$Id: mb_discid.c 67 2007-06-03 14:09:23Z phw $
|
3
3
|
Copyright (c) 2007, Philipp Wolfer
|
4
4
|
All rights reserved.
|
5
5
|
See LICENSE for permissions.
|
@@ -30,11 +30,13 @@ static VALUE mb_discid_id(VALUE self)
|
|
30
30
|
{
|
31
31
|
if (rb_iv_get(self, "@read") == Qfalse)
|
32
32
|
return Qnil;
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
else
|
34
|
+
{
|
35
|
+
DiscId *disc;
|
36
|
+
Data_Get_Struct(self, DiscId, disc);
|
37
|
+
|
38
|
+
return rb_str_new2(discid_get_id(disc));
|
39
|
+
}
|
38
40
|
}
|
39
41
|
|
40
42
|
/**
|
@@ -46,11 +48,13 @@ static VALUE mb_discid_submission_url(VALUE self)
|
|
46
48
|
{
|
47
49
|
if (rb_iv_get(self, "@read") == Qfalse)
|
48
50
|
return Qnil;
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
else
|
52
|
+
{
|
53
|
+
DiscId *disc;
|
54
|
+
Data_Get_Struct(self, DiscId, disc);
|
55
|
+
|
56
|
+
return rb_str_new2(discid_get_submission_url(disc));
|
57
|
+
}
|
54
58
|
}
|
55
59
|
|
56
60
|
/**
|
@@ -62,11 +66,13 @@ static VALUE mb_discid_freedb_id(VALUE self)
|
|
62
66
|
{
|
63
67
|
if (rb_iv_get(self, "@read") == Qfalse)
|
64
68
|
return Qnil;
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
else
|
70
|
+
{
|
71
|
+
DiscId *disc;
|
72
|
+
Data_Get_Struct(self, DiscId, disc);
|
73
|
+
|
74
|
+
return rb_str_new2(discid_get_freedb_id(disc));
|
75
|
+
}
|
70
76
|
}
|
71
77
|
|
72
78
|
/**
|
@@ -78,11 +84,13 @@ static VALUE mb_discid_first_track_num(VALUE self)
|
|
78
84
|
{
|
79
85
|
if (rb_iv_get(self, "@read") == Qfalse)
|
80
86
|
return Qnil;
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
87
|
+
else
|
88
|
+
{
|
89
|
+
DiscId *disc;
|
90
|
+
Data_Get_Struct(self, DiscId, disc);
|
91
|
+
|
92
|
+
return INT2FIX(discid_get_first_track_num(disc));
|
93
|
+
}
|
86
94
|
}
|
87
95
|
|
88
96
|
/**
|
@@ -94,11 +102,13 @@ static VALUE mb_discid_last_track_num(VALUE self)
|
|
94
102
|
{
|
95
103
|
if (rb_iv_get(self, "@read") == Qfalse)
|
96
104
|
return Qnil;
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
105
|
+
else
|
106
|
+
{
|
107
|
+
DiscId *disc;
|
108
|
+
Data_Get_Struct(self, DiscId, disc);
|
109
|
+
|
110
|
+
return INT2FIX(discid_get_last_track_num(disc));
|
111
|
+
}
|
102
112
|
}
|
103
113
|
|
104
114
|
/**
|
@@ -110,11 +120,13 @@ static VALUE mb_discid_sectors(VALUE self)
|
|
110
120
|
{
|
111
121
|
if (rb_iv_get(self, "@read") == Qfalse)
|
112
122
|
return Qnil;
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
123
|
+
else
|
124
|
+
{
|
125
|
+
DiscId *disc;
|
126
|
+
Data_Get_Struct(self, DiscId, disc);
|
127
|
+
|
128
|
+
return INT2FIX(discid_get_sectors(disc));
|
129
|
+
}
|
118
130
|
}
|
119
131
|
|
120
132
|
/**
|
@@ -130,31 +142,37 @@ static VALUE mb_discid_tracks(VALUE self)
|
|
130
142
|
{
|
131
143
|
if (rb_iv_get(self, "@read") == Qfalse)
|
132
144
|
return Qnil;
|
133
|
-
|
134
|
-
DiscId *disc;
|
135
|
-
Data_Get_Struct(self, DiscId, disc);
|
136
|
-
|
137
|
-
VALUE result = rb_ary_new(); // Array of all [offset, length] tuples
|
138
|
-
VALUE tuple; // Array to store one [offset, length] tuple.
|
139
|
-
int track = discid_get_first_track_num(disc); // Track number
|
140
|
-
while (track <= discid_get_last_track_num(disc))
|
145
|
+
else
|
141
146
|
{
|
142
|
-
|
143
|
-
|
144
|
-
INT2FIX(discid_get_track_length(disc, track)) );
|
147
|
+
DiscId *disc;
|
148
|
+
Data_Get_Struct(self, DiscId, disc);
|
145
149
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
+
{ // Stupid MS compiler.
|
151
|
+
|
152
|
+
VALUE result = rb_ary_new(); // Array of all [offset, length] tuples
|
153
|
+
VALUE tuple; // Array to store one [offset, length] tuple.
|
154
|
+
int track = discid_get_first_track_num(disc); // Track number
|
155
|
+
while (track <= discid_get_last_track_num(disc))
|
156
|
+
{
|
157
|
+
tuple = rb_ary_new3(2,
|
158
|
+
INT2FIX(discid_get_track_offset(disc, track)),
|
159
|
+
INT2FIX(discid_get_track_length(disc, track)) );
|
150
160
|
|
151
|
-
|
161
|
+
if (rb_block_given_p())
|
162
|
+
rb_yield(tuple);
|
163
|
+
else
|
164
|
+
rb_ary_push(result, tuple);
|
165
|
+
|
166
|
+
track++;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (rb_block_given_p())
|
170
|
+
return Qnil;
|
171
|
+
else
|
172
|
+
return result;
|
173
|
+
|
174
|
+
} // Stupid MS compiler.
|
152
175
|
}
|
153
|
-
|
154
|
-
if (rb_block_given_p())
|
155
|
-
return Qnil;
|
156
|
-
else
|
157
|
-
return result;
|
158
176
|
}
|
159
177
|
|
160
178
|
/**
|
@@ -167,6 +185,8 @@ static VALUE mb_discid_read(int argc, VALUE *argv, VALUE self)
|
|
167
185
|
DiscId *disc;
|
168
186
|
Data_Get_Struct(self, DiscId, disc);
|
169
187
|
|
188
|
+
{ // Stupid MS compiler.
|
189
|
+
|
170
190
|
VALUE device = Qnil; // The device string as a Ruby string.
|
171
191
|
char* cdevice; // The device string as a C string.
|
172
192
|
|
@@ -190,6 +210,8 @@ static VALUE mb_discid_read(int argc, VALUE *argv, VALUE self)
|
|
190
210
|
rb_iv_set(self, "@read", Qtrue);
|
191
211
|
|
192
212
|
return Qnil;
|
213
|
+
|
214
|
+
} // Stupid MS compiler.
|
193
215
|
}
|
194
216
|
|
195
217
|
/**
|
@@ -227,7 +249,7 @@ VALUE mb_discid_default_device(VALUE class)
|
|
227
249
|
/**
|
228
250
|
* Initialize the DiscID class and make it available in Ruby.
|
229
251
|
*/
|
230
|
-
void
|
252
|
+
void Init_MB_DiscID() {
|
231
253
|
mMusicBrainz = rb_define_module("MusicBrainz");
|
232
254
|
cDiscID = rb_define_class_under(mMusicBrainz, "DiscID", rb_cObject);
|
233
255
|
rb_define_singleton_method(cDiscID, "new", mb_discid_new, -1);
|
data/lib/mb-discid.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# $Id: mb-discid.rb 67 2007-06-03 14:09:23Z phw $
|
2
|
+
# Copyright (c) 2007, Philipp Wolfer
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE for permissions.
|
5
|
+
|
6
|
+
# Just a helper file to allow loading the MB-DiscID library with
|
7
|
+
# <tt>require 'mb-discid'</tt>, which is the only recommended way
|
8
|
+
# to load the library.
|
9
|
+
# This file may even provide extensions to the library in the future
|
10
|
+
# to avoid to have to write everything in C.
|
11
|
+
|
12
|
+
require 'MB_DiscID.so'
|
metadata
CHANGED
@@ -3,11 +3,12 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mb-discid
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2007-06-03 00:00:00 +02:00
|
8
8
|
summary: Ruby bindings for libdiscid.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
+
- ext
|
11
12
|
email: phw@rubyforge.org
|
12
13
|
homepage: http://rbrainz.rubyforge.org
|
13
14
|
rubyforge_project: rbrainz
|
@@ -33,8 +34,9 @@ files:
|
|
33
34
|
- LICENSE
|
34
35
|
- README
|
35
36
|
- examples/discid.rb
|
36
|
-
- ext/
|
37
|
+
- ext/mb_discid.c
|
37
38
|
- ext/extconf.rb
|
39
|
+
- lib/mb-discid.rb
|
38
40
|
test_files: []
|
39
41
|
|
40
42
|
rdoc_options: []
|