discid 1.2.0 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da3abc81eca7a228d26984a9db667b91477ea068
4
- data.tar.gz: d7fd697e3d2b833734417240b9be5919159338e3
3
+ metadata.gz: 04925bc0ab19f720f642b3cdc2421138d26d2b5a
4
+ data.tar.gz: 57815371438236e32ec759332070e307893edef1
5
5
  SHA512:
6
- metadata.gz: 22ae22372a5d41b633eef98a56609f5dd8f5152e140c922fef1b606ce62a4ae57acec27005f317ef633f3879455f0df0ba76df24cf885dd9a8b77f40885e1af5
7
- data.tar.gz: a9761bc666fa56fb5e16112911e3536d702cf69722037b155390217e9e180950754bd2f922568c752c81bf0a7ee93507eb0a1e20bb7a649a7441bed3c975b29f
6
+ metadata.gz: 1e479cecb1a34c9002397a1c959b547942156d32592822ea1e0312a63efec7c8f5470af20b7eb51a06132887d6f2e905ad6df1bd8c47b15299d7777eaed776c8
7
+ data.tar.gz: 2dd736a7d7c23cd01076d0703270982d10aa0268f11234b95376294a4b5e5b38f1ad7a54496d7571a422e0de94967eb48c2ee84427e5538eb0f3f3a884062617
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --no-private --markup markdown --markup-provider redcarpet - CHANGES.md examples/*.rb
data/CHANGES.md CHANGED
@@ -1,10 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 (2016-02-19)
4
+ * Add support for {DiscId::Disc#toc_string}. Will use the implementation from
5
+ libdiscid 0.6 or a fallback for older versions.
6
+ * Removed support for Ruby 1.8
7
+ * codeclimate-test-reporter is not required anymore for running the tests
8
+ * Updated documentation
9
+
3
10
  ## 1.2.0 (2016-02-12)
4
- * `DiscId.sectors_to_seconds`: Truncate instead of round resulting float
11
+ * {DiscId.sectors_to_seconds}: Truncate instead of round resulting float
5
12
 
6
13
  ## 1.1.2 (2016-02-11)
7
- * Fixed first and last track being swapped in example readdiscid.rb
14
+ * Fixed first and last track being swapped in {file:examples/readdiscid.rby example readdiscid.rb}
8
15
  * Restricted dependencies for Ruby 1.8 to maintain compatibility
9
16
  * Test against Ruby 2.3
10
17
 
@@ -12,7 +19,7 @@
12
19
  * Fixed gem file permissions
13
20
 
14
21
  ## 1.1.0 (2015-08-26)
15
- * Fixed Disc#put handling of first_track being > 1
22
+ * Fixed {DiscId.put} handling of first_track being > 1
16
23
 
17
24
  ## 1.0.0 (2013-05-01)
18
25
  * Final API and documentation cleanup.
data/README.md CHANGED
@@ -5,12 +5,17 @@
5
5
  [![Gem Version](https://badge.fury.io/rb/discid.svg)](http://badge.fury.io/rb/discid)
6
6
 
7
7
  ## About
8
- ruby-discid provides Ruby bindings for the MusicBrainz DiscID library libdiscid.
8
+ ruby-discid provides Ruby bindings for the MusicBrainz DiscID library [libdiscid](http://musicbrainz.org/doc/libdiscid).
9
9
  It allows calculating DiscIDs (MusicBrainz and freedb) for Audio CDs. Additionally
10
10
  the library can extract the MCN/UPC/EAN and the ISRCs from disc.
11
11
 
12
+ ruby-discid supports all features from libdiscid 0.6, but will also work with
13
+ any earlier version. If a feature is unsupported in the libdiscid version used
14
+ ruby-discid will just return a default value. The version required for a feature
15
+ is documented in the [API documentation](http://www.rubydoc.info/github/phw/ruby-discid/master).
16
+
12
17
  ## Requirements
13
- * Ruby >= 1.8.7
18
+ * Ruby >= 1.9.0
14
19
  * RubyGems >= 1.3.6
15
20
  * Ruby-FFI >= 1.6.0
16
21
  * libdiscid >= 0.1.0
@@ -18,54 +23,83 @@ the library can extract the MCN/UPC/EAN and the ISRCs from disc.
18
23
  ## Installation
19
24
  Before installing ruby-discid make sure you have libdiscid installed. See
20
25
  http://musicbrainz.org/doc/libdiscid for more information on how to do this.
26
+ For Windows see also the notes below.
21
27
 
28
+ ### Installing with RubyGems
22
29
  Installing ruby-discid is best done using RubyGems:
23
30
 
24
31
  gem install discid
25
32
 
33
+ ### Installing from package repository
34
+ For some Linux distributions packages are available:
35
+
36
+ * [Arch Linux AUR package](https://aur.archlinux.org/packages/ruby-discid/)
37
+ * [Ubuntu PPA](https://launchpad.net/~musicbrainz-developers/+archive/ubuntu/stable)
38
+
39
+ ### Install from source
26
40
  You can also install from source. This requires RubyGems and Bundler installed.
27
41
  First make sure you have installed bundler:
28
42
 
29
43
  gem install bundler
30
44
 
31
45
  Then inside the ruby-discid source directory run:
32
-
46
+
33
47
  bundle install
34
48
  rake install
35
49
 
36
- `bundle install` will install additional development dependencies (Rake, Yard
37
- and Kramdown). `rake install` will build the discid gem and install it.
38
-
50
+ `bundle install` will install additional development dependencies (Rake,
51
+ Yard etc.). `rake install` will build the discid gem and install it.
52
+
53
+ ### Windows installation notes
54
+ On Windows you will need `discid.dll` available in a place where Windows can
55
+ find it, see [Search Path Used by Windows to Locate a DLL](https://msdn.microsoft.com/en-us/library/7d83bc18.aspx).
56
+ You can install the `discid.dll` system wide, but it is recommended to place
57
+ it in the local working directory of your application.
58
+
59
+ Also the architecture (32 or 64 bit) of the DLL must match your Ruby version.
60
+ As the official build of libdiscid contains only a 32 bit version of `discid.dll`
61
+ it is recommended to use the 32 bit version of Ruby.
62
+
63
+ If you want or need to use 64 bit Ruby you will have to compile libdiscid
64
+ yourself. Refer to the [libdiscid install instructions](https://github.com/metabrainz/libdiscid/blob/master/INSTALL)
65
+ for further details.
66
+
39
67
  ## Usage
40
68
 
41
69
  ### Read only the TOC
42
70
 
43
- require 'discid'
71
+ ```ruby
72
+ require 'discid'
44
73
 
45
- device = "/dev/cdrom"
46
- disc = DiscId.read(device)
47
- puts disc.id
74
+ # Specifying the device is optional. If omitted a platform
75
+ # specific default will be used.
76
+ device = "/dev/cdrom"
77
+ disc = DiscId.read(device)
78
+ puts disc.id
79
+ ```
48
80
 
49
81
  ### Read the TOC, MCN and ISRCs
50
82
 
51
- require 'discid'
52
-
53
- device = "/dev/cdrom"
54
- disc = DiscId.read(device, :mcn, :isrc)
55
-
56
- # Print information about the disc:
57
- puts "DiscID : #{disc.id}"
58
- puts "FreeDB ID : #{disc.freedb_id}"
59
- puts "Total length: #{disc.seconds} seconds"
60
- puts "MCN : #{disc.mcn}"
61
-
62
- # Print information about individual tracks:
63
- disc.tracks do |track|
64
- puts "Track ##{track.number}"
65
- puts " Length: %02d:%02d (%i sectors)" %
66
- [track.seconds / 60, track.seconds % 60, track.sectors]
67
- puts " ISRC : %s" % track.isrc
68
- end
83
+ ```ruby
84
+ require 'discid'
85
+
86
+ device = "/dev/cdrom"
87
+ disc = DiscId.read(device, :mcn, :isrc)
88
+
89
+ # Print information about the disc:
90
+ puts "DiscID : #{disc.id}"
91
+ puts "FreeDB ID : #{disc.freedb_id}"
92
+ puts "Total length: #{disc.seconds} seconds"
93
+ puts "MCN : #{disc.mcn}"
94
+
95
+ # Print information about individual tracks:
96
+ disc.tracks do |track|
97
+ puts "Track ##{track.number}"
98
+ puts " Length: %02d:%02d (%i sectors)" %
99
+ [track.seconds / 60, track.seconds % 60, track.sectors]
100
+ puts " ISRC : %s" % track.isrc
101
+ end
102
+ ```
69
103
 
70
104
  See the [API documentation](http://www.rubydoc.info/github/phw/ruby-discid/master)
71
105
  of {DiscId} or the files in the `examples` directory for more usage information.
@@ -78,5 +112,16 @@ Please report any issues on the
78
112
  [issue tracker](https://github.com/phw/ruby-discid/issues).
79
113
 
80
114
  ## License
81
- ruby-discid is released under the GNU Lesser General Public License Version 3.
115
+ ruby-discid Copyright (c) 2007-2016 by Philipp Wolfer <ph.wolfer@gmail.com>
116
+
117
+ ruby-discid is free software: you can redistribute it and/or modify
118
+ it under the terms of the GNU Lesser General Public License as published by
119
+ the Free Software Foundation, either version 3 of the License, or
120
+ (at your option) any later version.
121
+
122
+ This program is distributed in the hope that it will be useful,
123
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
124
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125
+ GNU Lesser General Public License for more details.
126
+
82
127
  See LICENSE for details.
@@ -37,6 +37,7 @@ print <<EOF
37
37
  Device : #{disc.device}
38
38
  DiscID : #{disc.id}
39
39
  FreeDB ID : #{disc.freedb_id}
40
+ TOC string : #{disc.toc_string}
40
41
  First track : #{disc.first_track_number}
41
42
  Last track : #{disc.last_track_number}
42
43
  Total length: #{disc.seconds} seconds
data/lib/discid/disc.rb CHANGED
@@ -130,6 +130,36 @@ module DiscId
130
130
  return Lib.get_mcn @handle if @read
131
131
  end
132
132
 
133
+ # Return a string representing CD Table Of Contents (TOC).
134
+ #
135
+ # The TOC suitable as value of the toc parameter when accessing the
136
+ # MusicBrainz Web Service. This enables fuzzy searching when the actual
137
+ # DiscID is not found.
138
+ #
139
+ # Note that this is the unencoded value, which still contains spaces.
140
+ #
141
+ # @since 1.3
142
+ #
143
+ # @raise [RuntimeError] get_toc_string is unsupported by libdiscid and
144
+ # could not get extracted from {Disc#submission_url}
145
+ # @return [String] The TOC string or `nil` if no ID was yet read.
146
+ def toc_string
147
+ return nil if not @read
148
+ result = Lib.get_toc_string
149
+ if not result
150
+ # probably an old version of libdiscid (< 0.6.0)
151
+ # gather toc string from submission_url
152
+ match = /toc=([0-9+]+)/.match self.submission_url
153
+ if match
154
+ result = match[1].gsub("+", " ")
155
+ else
156
+ raise "can't get toc string from submission url"
157
+ end
158
+ end
159
+
160
+ return result
161
+ end
162
+
133
163
  # An URL for submitting the DiscID to MusicBrainz.
134
164
  #
135
165
  # The URL leads to an interactive disc submission wizard that guides the
data/lib/discid/lib.rb CHANGED
@@ -62,6 +62,14 @@ module DiscId
62
62
 
63
63
  attach_function :get_track_length, :discid_get_track_length, [:pointer, :int], :int
64
64
 
65
+ begin
66
+ attach_function :get_toc_string, :discid_get_toc_string, [:pointer], :string
67
+ rescue FFI::NotFoundError
68
+ def self.get_toc_string
69
+ return nil
70
+ end
71
+ end
72
+
65
73
  begin
66
74
  attach_function :get_mcn, :discid_get_mcn, [:pointer], :string
67
75
  rescue FFI::NotFoundError
@@ -16,5 +16,5 @@
16
16
 
17
17
  module DiscId
18
18
  # The version of ruby-discid.
19
- VERSION = "1.2.0"
19
+ VERSION = "1.3.0"
20
20
  end
data/test/helper.rb CHANGED
@@ -13,11 +13,12 @@
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
- # The code coverage is only supported for Ruby >= 1.9
17
- if (RUBY_VERSION.split('.').map{|s|s.to_i} <=> [1, 9, 0]) >= 0
16
+ begin
18
17
  require 'codeclimate-test-reporter'
19
18
 
20
19
  CodeClimate::TestReporter.start do
21
20
  add_filter "/test/"
22
21
  end
22
+ rescue LoadError
23
+ puts 'WARNING: codeclimate-test-reporter not available, no code coverage reported.'
23
24
  end
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 'helper'
17
16
  require 'test/unit'
18
17
  require 'discid'
18
+ require_relative 'helper'
19
19
 
20
20
  # Unit test for the DiscId::Disc class.
21
21
  class TestDisc < Test::Unit::TestCase
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 'helper'
17
16
  require 'test/unit'
18
17
  require 'discid'
18
+ require_relative 'helper'
19
19
 
20
20
  # Helper class which can't be converted into a string.
21
21
  class NotAString
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 'helper'
17
16
  require 'test/unit'
18
17
  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.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Wolfer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -25,35 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yard
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: kramdown
56
+ name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -117,6 +117,7 @@ executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
+ - ".yardopts"
120
121
  - CHANGES.md
121
122
  - LICENSE
122
123
  - README.md
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
147
  requirements:
147
148
  - - ">="
148
149
  - !ruby/object:Gem::Version
149
- version: 1.8.7
150
+ version: 1.9.0
150
151
  required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  requirements:
152
153
  - - ">="