discid 1.3.0 → 1.4.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.
- checksums.yaml +5 -5
- data/CHANGES.md +14 -0
- data/README.md +3 -4
- data/examples/discfromtoc.rb +33 -0
- data/examples/parsetoc.rb +32 -0
- data/lib/discid/disc.rb +17 -10
- data/lib/discid/disc_error.rb +1 -0
- data/lib/discid/lib.rb +16 -8
- data/lib/discid/track.rb +1 -1
- data/lib/discid/version.rb +2 -2
- data/lib/discid.rb +24 -1
- data/test/helper.rb +2 -2
- data/test/test_disc.rb +7 -1
- data/test/test_discid.rb +52 -5
- data/test/test_lib.rb +40 -0
- data/test/test_track.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0c1f99777183d8decf97ffb214d424300ae1546f72d30e0a9fe3891e24b66882
|
4
|
+
data.tar.gz: 65cc1ffde114bcd7860697ac081d266f434d294a86094a0f26efdd418096f1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccdebac904df0839af7ce5ad36d130e7c00d36324fabf72e64bdebf686bdb7a290c82d520dcd909b4b83295cc8ea0389540b66086b06e2f3a39646d277d70c1
|
7
|
+
data.tar.gz: 6fe953875c071bd33973596c4bc9e18c1313a58df2273e4b929ca628e0923f79b93efa8bbf1c7fb26067278cf2f46588a3c2754a72b3f0febfb311b860725aa5
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.4.1 (2021-09-23)
|
4
|
+
* Fix Ruby 3 compatibility if {DiscId.tracks} gets called with a block
|
5
|
+
|
6
|
+
## 1.4.0 (2019-05-06)
|
7
|
+
* Fixed {DiscId.put} handling of first_track being > 1
|
8
|
+
* Added {DiscId.parse} to parse a TOC string
|
9
|
+
* Documentation fixes
|
10
|
+
|
11
|
+
## 1.3.2 (2017-12-19)
|
12
|
+
* Fixed call to {DiscId::Disc#toc_string} with native implementation
|
13
|
+
|
14
|
+
## 1.3.1 (2017-02-16)
|
15
|
+
* codeclimate-test-reporter is no longer a development dependency
|
16
|
+
|
3
17
|
## 1.3.0 (2016-02-19)
|
4
18
|
* Add support for {DiscId::Disc#toc_string}. Will use the implementation from
|
5
19
|
libdiscid 0.6 or a fallback for older versions.
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Ruby bindings for MusicBrainz libdiscid
|
2
|
-
[](https://travis-ci.org/phw/ruby-discid)
|
3
|
-
[](https://codeclimate.com/github/phw/ruby-discid)
|
4
|
-
[](https://codeclimate.com/github/phw/ruby-discid)
|
5
2
|
[](http://badge.fury.io/rb/discid)
|
3
|
+
[](https://codeclimate.com/github/phw/ruby-discid/maintainability)
|
4
|
+
[](https://codeclimate.com/github/phw/ruby-discid/test_coverage)
|
6
5
|
|
7
6
|
## About
|
8
7
|
ruby-discid provides Ruby bindings for the MusicBrainz DiscID library [libdiscid](http://musicbrainz.org/doc/libdiscid).
|
@@ -112,7 +111,7 @@ Please report any issues on the
|
|
112
111
|
[issue tracker](https://github.com/phw/ruby-discid/issues).
|
113
112
|
|
114
113
|
## License
|
115
|
-
ruby-discid Copyright (c) 2007-
|
114
|
+
ruby-discid Copyright (c) 2007-2021 by Philipp Wolfer <ph.wolfer@gmail.com>
|
116
115
|
|
117
116
|
ruby-discid is free software: you can redistribute it and/or modify
|
118
117
|
it under the terms of the GNU Lesser General Public License as published by
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Example script for DiscId.
|
4
|
+
#
|
5
|
+
# This script shows how to generate a disc ID for given TOC data
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# ./discid.rb /dev/dvd
|
9
|
+
|
10
|
+
# Just make sure we can run this example from the command
|
11
|
+
# line even if DiscId is not yet installed properly.
|
12
|
+
$: << 'lib/' << 'ext/' << '../ext/' << '../lib/'
|
13
|
+
|
14
|
+
require 'discid'
|
15
|
+
|
16
|
+
offsets = [150, 44942, 61305, 72755, 96360, 130485, 147315, 164275, 190702, 205412, 220437]
|
17
|
+
|
18
|
+
disc = DiscId.put(1, 242457, offsets)
|
19
|
+
|
20
|
+
|
21
|
+
print <<EOF
|
22
|
+
|
23
|
+
Device : #{disc.device}
|
24
|
+
DiscID : #{disc.id}
|
25
|
+
FreeDB ID : #{disc.freedb_id}
|
26
|
+
TOC string : #{disc.toc_string}
|
27
|
+
First track : #{disc.first_track_number}
|
28
|
+
Last track : #{disc.last_track_number}
|
29
|
+
Total length: #{disc.seconds} seconds
|
30
|
+
Sectors : #{disc.sectors}
|
31
|
+
|
32
|
+
Submit via #{disc.submission_url}
|
33
|
+
EOF
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Example script for DiscId.
|
4
|
+
#
|
5
|
+
# This script shows how to generate a disc ID by parsing a given TOC string
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# ./discid.rb /dev/dvd
|
9
|
+
|
10
|
+
# Just make sure we can run this example from the command
|
11
|
+
# line even if DiscId is not yet installed properly.
|
12
|
+
$: << 'lib/' << 'ext/' << '../ext/' << '../lib/'
|
13
|
+
|
14
|
+
require 'discid'
|
15
|
+
|
16
|
+
toc = '1 11 242457 150 44942 61305 72755 96360 130485 147315 164275 190702 205412 220437'
|
17
|
+
|
18
|
+
disc = DiscId.parse(toc)
|
19
|
+
|
20
|
+
print <<EOF
|
21
|
+
|
22
|
+
Device : #{disc.device}
|
23
|
+
DiscID : #{disc.id}
|
24
|
+
FreeDB ID : #{disc.freedb_id}
|
25
|
+
TOC string : #{disc.toc_string}
|
26
|
+
First track : #{disc.first_track_number}
|
27
|
+
Last track : #{disc.last_track_number}
|
28
|
+
Total length: #{disc.seconds} seconds
|
29
|
+
Sectors : #{disc.sectors}
|
30
|
+
|
31
|
+
Submit via #{disc.submission_url}
|
32
|
+
EOF
|
data/lib/discid/disc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013-2014 Philipp Wolfer
|
1
|
+
# Copyright (C) 2013-2014, 2021 Philipp Wolfer
|
2
2
|
#
|
3
3
|
# This program is free software: you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU Lesser General Public License as published by
|
@@ -18,6 +18,7 @@ require 'discid/disc_error'
|
|
18
18
|
require 'discid/lib'
|
19
19
|
require 'discid/track'
|
20
20
|
|
21
|
+
#
|
21
22
|
module DiscId
|
22
23
|
# This class holds information about a disc (TOC, MCN, ISRCs).
|
23
24
|
#
|
@@ -59,11 +60,14 @@ module DiscId
|
|
59
60
|
def put(first_track, sectors, offsets)
|
60
61
|
@read = false
|
61
62
|
@device = nil
|
62
|
-
last_track = offsets.length
|
63
|
+
last_track = first_track - 1 + offsets.length
|
63
64
|
|
64
65
|
# discid_put expects always an offsets array with exactly 100 elements.
|
65
66
|
FFI::MemoryPointer.new(:int, 100) do |p|
|
66
|
-
|
67
|
+
if last_track > offsets.length
|
68
|
+
offsets = Array.new(last_track - offsets.length, 0) + offsets
|
69
|
+
end
|
70
|
+
p.write_array_of_int(([sectors] + offsets)[0, 100])
|
67
71
|
result = Lib.put @handle, first_track, last_track, p
|
68
72
|
|
69
73
|
if result == 0
|
@@ -132,12 +136,15 @@ module DiscId
|
|
132
136
|
|
133
137
|
# Return a string representing CD Table Of Contents (TOC).
|
134
138
|
#
|
135
|
-
# The TOC suitable as value of the toc parameter when accessing the
|
139
|
+
# The TOC suitable as a value of the toc parameter when accessing the
|
136
140
|
# MusicBrainz Web Service. This enables fuzzy searching when the actual
|
137
141
|
# DiscID is not found.
|
138
142
|
#
|
139
143
|
# Note that this is the unencoded value, which still contains spaces.
|
140
144
|
#
|
145
|
+
# For libdiscid >= 0.6 the native implementation will be used. For older
|
146
|
+
# versions falls back to extract the TOC from {Disc#submission_url}.
|
147
|
+
#
|
141
148
|
# @since 1.3
|
142
149
|
#
|
143
150
|
# @raise [RuntimeError] get_toc_string is unsupported by libdiscid and
|
@@ -145,13 +152,13 @@ module DiscId
|
|
145
152
|
# @return [String] The TOC string or `nil` if no ID was yet read.
|
146
153
|
def toc_string
|
147
154
|
return nil if not @read
|
148
|
-
result = Lib.get_toc_string
|
155
|
+
result = Lib.get_toc_string @handle
|
149
156
|
if not result
|
150
157
|
# probably an old version of libdiscid (< 0.6.0)
|
151
158
|
# gather toc string from submission_url
|
152
159
|
match = /toc=([0-9+]+)/.match self.submission_url
|
153
160
|
if match
|
154
|
-
result = match[1].
|
161
|
+
result = match[1].tr("+", " ")
|
155
162
|
else
|
156
163
|
raise "can't get toc string from submission url"
|
157
164
|
end
|
@@ -186,16 +193,16 @@ module DiscId
|
|
186
193
|
# Returns always `nil` if no ID was yet read. The block won't be
|
187
194
|
# called in this case.
|
188
195
|
#
|
189
|
-
# @yield [
|
196
|
+
# @yield [Track] If a block is given this method returns `nil` and
|
190
197
|
# instead iterates over the block calling the block with one argument.
|
191
198
|
# @yieldreturn [nil]
|
192
199
|
# @return [Array<Track>] Array of {Track} objects.
|
193
|
-
def tracks
|
200
|
+
def tracks(&block)
|
194
201
|
if @read
|
195
202
|
read_tracks if @tracks.nil?
|
196
203
|
|
197
|
-
if
|
198
|
-
@tracks.each(&
|
204
|
+
if block
|
205
|
+
@tracks.each(&block)
|
199
206
|
return nil
|
200
207
|
else
|
201
208
|
return @tracks
|
data/lib/discid/disc_error.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
#
|
16
17
|
module DiscId
|
17
18
|
# This exception is thrown on errors reading the disc or setting the TOC.
|
18
19
|
class DiscError < StandardError
|
data/lib/discid/lib.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
require "ffi"
|
17
17
|
|
18
|
+
#
|
18
19
|
module DiscId
|
19
20
|
|
20
21
|
# This module encapsulates the C interface for libdiscid using FFI.
|
@@ -35,7 +36,7 @@ module DiscId
|
|
35
36
|
rescue FFI::NotFoundError
|
36
37
|
attach_function :legacy_read, :discid_read, [:pointer, :string], :int
|
37
38
|
|
38
|
-
def self.read(handle, device,
|
39
|
+
def self.read(handle, device, _features)
|
39
40
|
legacy_read(handle, device)
|
40
41
|
end
|
41
42
|
end
|
@@ -73,7 +74,7 @@ module DiscId
|
|
73
74
|
begin
|
74
75
|
attach_function :get_mcn, :discid_get_mcn, [:pointer], :string
|
75
76
|
rescue FFI::NotFoundError
|
76
|
-
def self.get_mcn(
|
77
|
+
def self.get_mcn(_handle)
|
77
78
|
return nil
|
78
79
|
end
|
79
80
|
end
|
@@ -81,7 +82,7 @@ module DiscId
|
|
81
82
|
begin
|
82
83
|
attach_function :get_track_isrc, :discid_get_track_isrc, [:pointer, :int], :string
|
83
84
|
rescue FFI::NotFoundError
|
84
|
-
def self.get_track_isrc(
|
85
|
+
def self.get_track_isrc(_handle, _track)
|
85
86
|
return nil
|
86
87
|
end
|
87
88
|
end
|
@@ -109,17 +110,24 @@ module DiscId
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def self.features_to_int(features)
|
112
|
-
|
113
|
+
feature_flags = 0
|
113
114
|
features.each do |feature|
|
114
115
|
if feature.respond_to? :to_sym
|
115
116
|
feature = feature.to_sym
|
116
|
-
|
117
|
-
self::Features.symbols.include?(feature) and
|
118
|
-
self.has_feature(feature)
|
117
|
+
feature_flags = self.add_feature_to_flags(feature_flags, feature)
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
122
|
-
return
|
121
|
+
return feature_flags
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def self.add_feature_to_flags(flags, feature)
|
127
|
+
flags |= self::Features[feature] if
|
128
|
+
self::Features.symbols.include?(feature) and
|
129
|
+
self.has_feature(feature)
|
130
|
+
return flags
|
123
131
|
end
|
124
132
|
end
|
125
133
|
end
|
data/lib/discid/track.rb
CHANGED
data/lib/discid/version.rb
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
-
|
16
|
+
#
|
17
17
|
module DiscId
|
18
18
|
# The version of ruby-discid.
|
19
|
-
VERSION = "1.
|
19
|
+
VERSION = "1.4.1"
|
20
20
|
end
|
data/lib/discid.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Philipp Wolfer
|
1
|
+
# Copyright (C) 2013-2017, 2019 Philipp Wolfer
|
2
2
|
#
|
3
3
|
# This program is free software: you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU Lesser General Public License as published by
|
@@ -120,6 +120,29 @@ module DiscId
|
|
120
120
|
return disc
|
121
121
|
end
|
122
122
|
|
123
|
+
# Parses a TOC string and returns a [Disc] instance for it.
|
124
|
+
#
|
125
|
+
# This function can be used if you already have a TOC string like e.g.
|
126
|
+
# `1 11 242457 150 44942 61305 72755 96360 130485 147315 164275 190702 205412 220437`
|
127
|
+
#
|
128
|
+
# @raise [DiscError] The TOC string was invalid and could not be parsed.
|
129
|
+
# @param toc [String] A TOC string in the format `1 11 242457 150 44942 61305 72755 96360 130485 147315 164275 190702 205412 220437`.
|
130
|
+
# @return [Disc]
|
131
|
+
def self.parse(toc)
|
132
|
+
if toc.nil? || toc.empty?
|
133
|
+
raise DiscError, "Invalid TOC #{toc.inspect}"
|
134
|
+
end
|
135
|
+
begin
|
136
|
+
parts = toc.split(' ')
|
137
|
+
first_track = Integer(parts[0])
|
138
|
+
sectors = Integer(parts[2])
|
139
|
+
offsets = parts[3..-1].map{|i| Integer(i)}
|
140
|
+
rescue ArgumentError, TypeError => e
|
141
|
+
raise DiscError, e
|
142
|
+
end
|
143
|
+
return self.put(first_track, sectors, offsets)
|
144
|
+
end
|
145
|
+
|
123
146
|
# Return the name of the default disc drive for this operating system.
|
124
147
|
#
|
125
148
|
# @return [String] An operating system dependent device identifier
|
data/test/helper.rb
CHANGED
@@ -14,9 +14,9 @@
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
16
|
begin
|
17
|
-
require '
|
17
|
+
require 'simplecov'
|
18
18
|
|
19
|
-
|
19
|
+
SimpleCov.start do
|
20
20
|
add_filter "/test/"
|
21
21
|
end
|
22
22
|
rescue LoadError
|
data/test/test_disc.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
require_relative 'helper'
|
16
17
|
require 'test/unit'
|
17
18
|
require 'discid'
|
18
|
-
require_relative 'helper'
|
19
19
|
|
20
20
|
# Unit test for the DiscId::Disc class.
|
21
21
|
class TestDisc < Test::Unit::TestCase
|
@@ -85,4 +85,10 @@ class TestDisc < Test::Unit::TestCase
|
|
85
85
|
assert_equal @fiction_lengths, disc.tracks.map{|t| t.sectors}
|
86
86
|
end
|
87
87
|
|
88
|
+
def test_toc_string
|
89
|
+
disc = DiscId.put(@fiction_first_track, @fiction_sectors, @fiction_offsets)
|
90
|
+
expected_toc = '1 10 206535 150 18901 39738 59557 79152 100126 124833 147278 166336 182560'
|
91
|
+
assert_equal expected_toc, disc.toc_string
|
92
|
+
end
|
93
|
+
|
88
94
|
end
|
data/test/test_discid.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
require_relative 'helper'
|
16
17
|
require 'test/unit'
|
17
18
|
require 'discid'
|
18
|
-
require_relative 'helper'
|
19
19
|
|
20
20
|
# Helper class which can't be converted into a string.
|
21
21
|
class NotAString
|
@@ -55,20 +55,26 @@ class TestDiscId < Test::Unit::TestCase
|
|
55
55
|
# Those reads should all fail, but they must never cause a segmentation fault.
|
56
56
|
def test_read_invalid_arguments
|
57
57
|
assert_raise(TypeError) {DiscId.read(NotAString.new)}
|
58
|
-
assert_raise(DiscId::DiscError) {DiscId.read(
|
59
|
-
assert_raise(DiscId::DiscError) {DiscId.read(
|
60
|
-
assert_raise(DiscId::DiscError) {DiscId.read(:invalid_device)}
|
58
|
+
assert_raise(DiscId::DiscError) { DiscId.read('invalid_device') }
|
59
|
+
assert_raise(DiscId::DiscError) { DiscId.read(:invalid_device) }
|
61
60
|
end
|
62
61
|
|
63
62
|
def test_put_first_track_not_one
|
64
63
|
disc = DiscId.put(3, @fiction_sectors,
|
65
|
-
[
|
64
|
+
[150, 18901, 39738, 59557, 79152, 100126,
|
66
65
|
124833, 147278, 166336, 182560])
|
66
|
+
assert_equal "ByBKvJM1hBL7XtvsPyYtIjlX0Bw-", disc.id
|
67
67
|
assert_equal 3, disc.first_track_number
|
68
68
|
assert_equal 12, disc.last_track_number
|
69
69
|
assert_equal 10, disc.tracks.size
|
70
70
|
end
|
71
71
|
|
72
|
+
def test_put_invalid_track_count
|
73
|
+
assert_raise(DiscId::DiscError) {
|
74
|
+
disc = DiscId.put(1, @fiction_sectors, Array.new(101) {|i| i + 150 })
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
72
78
|
# Test the tracks method and TrackInfo objects
|
73
79
|
def test_put_and_tracks
|
74
80
|
disc = nil
|
@@ -113,6 +119,47 @@ class TestDiscId < Test::Unit::TestCase
|
|
113
119
|
assert_equal disc.last_track_number, number
|
114
120
|
end
|
115
121
|
|
122
|
+
def test_parse
|
123
|
+
toc = '1 11 242457 150 44942 61305 72755 96360 130485 147315 164275 190702 205412 220437'
|
124
|
+
assert_nothing_raised do
|
125
|
+
disc = DiscId.parse(toc)
|
126
|
+
assert_equal 'lSOVc5h6IXSuzcamJS1Gp4_tRuA-', disc.id
|
127
|
+
assert_equal toc, disc.toc_string
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_parse_minimal
|
132
|
+
toc = '1 1 44942 150'
|
133
|
+
assert_nothing_raised do
|
134
|
+
disc = DiscId.parse(toc)
|
135
|
+
assert_equal 'ANJa4DGYN_ktpzOwvVPtcjwP7mE-', disc.id
|
136
|
+
assert_equal toc, disc.toc_string
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_parse_first_track_not_one
|
141
|
+
toc = '3 12 242457 150 18901 39738 59557 79152 100126 124833 147278 166336 182560'
|
142
|
+
assert_nothing_raised do
|
143
|
+
disc = DiscId.parse(toc)
|
144
|
+
assert_equal 'fC1yNbC5bVjbvphqlAY9JyYoWEY-', disc.id
|
145
|
+
assert_equal toc, disc.toc_string
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_parse_invalid_empty
|
150
|
+
assert_raise(DiscId::DiscError) { DiscId.parse("") }
|
151
|
+
assert_raise(DiscId::DiscError) { DiscId.parse(nil) }
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_parse_invalid_nan
|
155
|
+
assert_raise(DiscId::DiscError) { DiscId.parse("1 2 242457 150 a") }
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_parse_invalid_not_enough_elements
|
159
|
+
assert_raise(DiscId::DiscError) { DiscId.parse("1 2 242457") }
|
160
|
+
assert_raise(DiscId::DiscError) { DiscId.parse("1 242457") }
|
161
|
+
end
|
162
|
+
|
116
163
|
# Test the conversion from sectors to seconds
|
117
164
|
def test_sectors_to_seconds
|
118
165
|
assert_equal 0, DiscId.sectors_to_seconds(0)
|
data/test/test_lib.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (C) 2013-2014 Philipp Wolfer
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
require_relative 'helper'
|
17
|
+
require 'test/unit'
|
18
|
+
require 'discid/lib'
|
19
|
+
|
20
|
+
class TestTrack < Test::Unit::TestCase
|
21
|
+
def test_features_to_int
|
22
|
+
assert_equal 1, DiscId::Lib.features_to_int([:read])
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_features_to_int_no_features
|
26
|
+
assert_equal 0, DiscId::Lib.features_to_int([])
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_features_to_int_as_strings
|
30
|
+
assert_equal 1, DiscId::Lib.features_to_int(['read'])
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_features_to_int_ignores_unknown
|
34
|
+
assert_equal 1, DiscId::Lib.features_to_int([:read, :fake])
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_has_feature
|
38
|
+
assert_equal 1, DiscId::Lib.has_feature(:read)
|
39
|
+
end
|
40
|
+
end
|
data/test/test_track.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
require_relative 'helper'
|
16
17
|
require 'test/unit'
|
17
18
|
require 'discid/track'
|
18
|
-
require_relative 'helper'
|
19
19
|
|
20
20
|
# Unit test for the DiscId::Track class.
|
21
21
|
class TestTrack < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Wolfer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -122,7 +122,9 @@ files:
|
|
122
122
|
- LICENSE
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
|
+
- examples/discfromtoc.rb
|
125
126
|
- examples/discidinfo.rb
|
127
|
+
- examples/parsetoc.rb
|
126
128
|
- examples/readdiscid.rb
|
127
129
|
- lib/discid.rb
|
128
130
|
- lib/discid/disc.rb
|
@@ -133,6 +135,7 @@ files:
|
|
133
135
|
- test/helper.rb
|
134
136
|
- test/test_disc.rb
|
135
137
|
- test/test_discid.rb
|
138
|
+
- test/test_lib.rb
|
136
139
|
- test/test_track.rb
|
137
140
|
homepage: https://github.com/phw/ruby-discid
|
138
141
|
licenses:
|
@@ -155,8 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
158
|
version: 1.3.6
|
156
159
|
requirements:
|
157
160
|
- libdiscid >= 0.1.0
|
158
|
-
|
159
|
-
rubygems_version: 2.5.1
|
161
|
+
rubygems_version: 3.0.3.1
|
160
162
|
signing_key:
|
161
163
|
specification_version: 4
|
162
164
|
summary: Ruby bindings for libdiscid
|
@@ -164,5 +166,5 @@ test_files:
|
|
164
166
|
- test/helper.rb
|
165
167
|
- test/test_disc.rb
|
166
168
|
- test/test_discid.rb
|
169
|
+
- test/test_lib.rb
|
167
170
|
- test/test_track.rb
|
168
|
-
has_rdoc:
|