discid 1.0.0rc2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWU1OTZiMzAyYzIxNGEzOTliYmRmMjc4MzI5MWNiZjAxM2FlOWJkOA==
5
+ data.tar.gz: !binary |-
6
+ NzRjNTM3MjYwMzQ2NWJlNjVmY2YyNmE0NDBlMDE1ZThiNDIwODcyNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZWI2ZTdjOTNlOTIyMzk5NDNhZDVjOGFmNjk4MTg4ZDVmYWVhNzBmNTQ0ZjI3
10
+ MmM2YWNlZDI3NmZiOTVmNzU1NTk0NGM0YTkwMjAyOWFiNWNiOTY0ZDgyMTYw
11
+ MDQ3ODEyMGVlZDBjYmZiYmFjZTc0N2ZmYzZjYTRhZGE0M2MzNTQ=
12
+ data.tar.gz: !binary |-
13
+ NDUxZmJkOGQ4NTA3ZTdiYjk4Yjg4YjFhOTZkNTBhOThhMDA4NTE5NzE2YzYy
14
+ NDM3NjBlZmZmYzQ5MTUxZmE1NDVlMGYzNmZjMDFiMzgxZTY1YzVmYjEyZmM0
15
+ MjA4ZDljY2Y1NmYzNzg0OWQ1ZDkxNTQxNDJlMzJjNWExMWMzYTY=
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0 (2013-05-01)
4
+ * Final API and documentation cleanup.
5
+ * Fixed library loading on Windows and OSX.
6
+
3
7
  ## 1.0.0.rc2 (2013-04-29)
4
8
  * Fixed loading libdiscid library
5
9
 
data/README.md CHANGED
@@ -6,8 +6,9 @@ It allows calculating DiscIDs (MusicBrainz and freedb) for Audio CDs. Additional
6
6
  the library can extract the MCN/UPC/EAN and the ISRCs from disc.
7
7
 
8
8
  ## Requirements
9
- * Ruby >= 1.8.6
10
- * Ruby-FFI
9
+ * Ruby >= 1.8.7
10
+ * RubyGems >= 1.3.6
11
+ * Ruby-FFI >= 1.6.0
11
12
  * libdiscid >= 0.1.0
12
13
 
13
14
  ## Installation
@@ -18,9 +19,18 @@ Installing ruby-discid is best done using RubyGems:
18
19
 
19
20
  gem install discid
20
21
 
21
- Or install it from the source tarball:
22
+ You can also install from source. This requires RubyGems and Bundler installed.
23
+ First make sure you have installed bundler:
22
24
 
25
+ gem install bundler
26
+
27
+ Then inside the ruby-discid source directory run:
28
+
29
+ bundle install
23
30
  rake install
31
+
32
+ `bundle install` will install additional development dependencies (Rake, Yard
33
+ and Kramdown). `rake install` will build the discid gem and install it.
24
34
 
25
35
  ## Usage
26
36
 
data/discid.gemspec CHANGED
@@ -13,16 +13,19 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/phw/ruby-discid"
14
14
  spec.license = "LGPL-3"
15
15
  spec.post_install_message = %q{Please make sure you have libdiscid (http://musicbrainz.org/doc/libdiscid) installed.}
16
- spec.requirements = "libdiscid >= 0.1.0"
16
+
17
+ spec.requirements = "libdiscid >= 0.1.0"
18
+ spec.required_ruby_version = ">= 1.8.7"
19
+ spec.required_rubygems_version = ">= 1.3.6"
17
20
 
18
21
  spec.files = `git ls-files`.split($/)
19
22
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
24
  spec.require_paths = ["lib"]
22
25
 
23
- spec.add_dependency "ffi", "~> 1.6.0"
26
+ spec.add_dependency "ffi", ">= 1.6.0"
24
27
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
28
+ spec.add_development_dependency "bundler", ">= 1.3"
26
29
  spec.add_development_dependency "rake"
27
30
  spec.add_development_dependency "yard"
28
31
  spec.add_development_dependency "kramdown"
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Example script for DiscId.
4
+ #
5
+ # This script will read the disc ID from the default device and print
6
+ # the results. You can specify an alternate device to use by giving the
7
+ # device's name as the first command line argument.
8
+ #
9
+ # Example:
10
+ # ./discid.rb /dev/dvd
11
+
12
+ # Just make sure we can run this example from the command
13
+ # line even if DiscId is not yet installed properly.
14
+ $: << 'lib/' << 'ext/' << '../ext/' << '../lib/'
15
+
16
+ require 'discid'
17
+
18
+ # Print information about libdiscid
19
+ print <<EOF
20
+ Version : #{DiscId::LIBDISCID_VERSION}
21
+ Default device : #{DiscId.default_device}
22
+ Supported features: #{DiscId.feature_list.join(', ')}
23
+ EOF
@@ -52,7 +52,7 @@ disc.tracks do |track|
52
52
  puts " Length: %02d:%02d (%i sectors)" %
53
53
  [track.seconds / 60, track.seconds % 60, track.sectors]
54
54
  puts " Start : %02d:%02d (sector %i)" %
55
- [track.start_time / 60, track.start_time % 60, track.start_sector]
55
+ [track.start_time / 60, track.start_time % 60, track.offset]
56
56
  puts " End : %02d:%02d (sector %i)" %
57
57
  [track.end_time / 60, track.end_time % 60, track.end_sector]
58
58
  puts " ISRC : %s" % track.isrc if DiscId.has_feature?(:isrc)
data/lib/discid/disc.rb CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  require 'ffi'
17
17
  require 'discid/lib'
18
- require 'discid/track_info'
18
+ require 'discid/track'
19
19
 
20
20
  module DiscId
21
21
  # This class holds information about a disc (TOC, MCN, ISRCs).
@@ -149,7 +149,7 @@ module DiscId
149
149
  id.to_s
150
150
  end
151
151
 
152
- # Returns an array of {TrackInfo} objects. Each TrackInfo object contains
152
+ # Returns an array of {Track} objects. Each Track object contains
153
153
  # detailed information about the track.
154
154
  #
155
155
  # Returns always `nil` if no ID was yet read. The block won't be
@@ -158,7 +158,7 @@ module DiscId
158
158
  # @yield [track_info] If a block is given this method returns `nil` and
159
159
  # instead iterates over the block calling the block with one argument.
160
160
  # @yieldreturn [nil]
161
- # @return [Array<TrackInfo>] Array of {TrackInfo} objects.
161
+ # @return [Array<Track>] Array of {Track} objects.
162
162
  def tracks
163
163
  if @read
164
164
  read_tracks if @tracks.nil?
@@ -183,7 +183,7 @@ module DiscId
183
183
  isrc = Lib.get_track_isrc(@handle, track_number)
184
184
  offset = Lib.get_track_offset(@handle, track_number)
185
185
  length = Lib.get_track_length(@handle, track_number)
186
- track_info = TrackInfo.new(track_number, offset, length, isrc)
186
+ track_info = Track.new(track_number, offset, length, isrc)
187
187
 
188
188
  @tracks << track_info
189
189
  end
data/lib/discid/lib.rb CHANGED
@@ -24,7 +24,7 @@ module DiscId
24
24
  # @private
25
25
  module Lib
26
26
  extend FFI::Library
27
- ffi_lib %w[discid libdiscid.so.0]
27
+ ffi_lib %w[discid libdiscid.so.0 libdiscid.0.dylib]
28
28
 
29
29
  attach_function :new, :discid_new, [], :pointer
30
30
 
@@ -22,7 +22,7 @@ module DiscId
22
22
  #
23
23
  # * number: The number of the track on the disc.
24
24
  # * sectors: Length of the track in sectors.
25
- # * start_sector: Start position of the track on the disc in sectors.
25
+ # * offset: Start position of the track on the disc in sectors.
26
26
  # * end_sector: End position of the track on the disc in sectors.
27
27
  # * seconds: Length of the track in seconds.
28
28
  # * start_time: Start position of the track on the disc in seconds.
@@ -33,12 +33,12 @@ module DiscId
33
33
  # You can access all fields either directly or with the square bracket
34
34
  # notation:
35
35
  #
36
- # track = TrackInfo.new(1, 150, 16007)
36
+ # track = Track.new(1, 150, 16007)
37
37
  # puts track.sectors # 16007
38
38
  # puts track[:sectors] # 16007
39
39
  #
40
40
  # @see DiscId::Disc#tracks
41
- class TrackInfo
41
+ class Track
42
42
 
43
43
  # The number of the track on the disc.
44
44
  #
@@ -53,7 +53,7 @@ module DiscId
53
53
  # Start position of the track on the disc in sectors.
54
54
  #
55
55
  # @return [Integer]
56
- attr_reader :start_sector
56
+ attr_reader :offset
57
57
 
58
58
  # ISRC number of the track.
59
59
  #
@@ -64,11 +64,11 @@ module DiscId
64
64
  # @return [String]
65
65
  attr_reader :isrc
66
66
 
67
- # Returns a new TrackInfo.
68
- def initialize(number, offset, length, isrc)
67
+ # Initializes a new Track object.
68
+ def initialize(number, offset, sectors, isrc)
69
69
  @number = number
70
- @start_sector = offset
71
- @sectors = length
70
+ @offset = offset
71
+ @sectors = sectors
72
72
  @isrc = isrc
73
73
  end
74
74
 
@@ -76,7 +76,7 @@ module DiscId
76
76
  #
77
77
  # @return [Integer]
78
78
  def end_sector
79
- start_sector + sectors
79
+ offset + sectors
80
80
  end
81
81
 
82
82
  # Length of the track in seconds.
@@ -90,7 +90,7 @@ module DiscId
90
90
  #
91
91
  # @return [Integer]
92
92
  def start_time
93
- DiscId.sectors_to_seconds(start_sector)
93
+ DiscId.sectors_to_seconds(offset)
94
94
  end
95
95
 
96
96
  # End position of the track on the disc in seconds.
@@ -104,24 +104,24 @@ module DiscId
104
104
  #
105
105
  # Example:
106
106
  #
107
- # track = TrackInfo.new(1, 150, 16007)
107
+ # track = Track.new(1, 150, 16007)
108
108
  # puts track.sectors # 16007
109
109
  # puts track[:sectors] # 16007
110
110
  def [](key)
111
- if [:number, :sectors, :start_sector, :end_sector,
111
+ if [:number, :sectors, :offset, :end_sector,
112
112
  :seconds, :start_time, :end_time, :isrc].include?(key.to_sym)
113
113
  method(key).call
114
114
  end
115
115
  end
116
116
 
117
- # Converts the TrackInfo into a Hash.
117
+ # Converts the Track into a Hash.
118
118
  #
119
119
  # @return [Hash]
120
120
  def to_hash
121
121
  {
122
122
  :number => number,
123
123
  :sectors => sectors,
124
- :start_sector => start_sector,
124
+ :offset => offset,
125
125
  :end_sector => end_sector,
126
126
  :seconds => seconds,
127
127
  :start_time => start_time,
@@ -16,5 +16,5 @@
16
16
 
17
17
  module DiscId
18
18
  # The version of ruby-discid.
19
- VERSION = "1.0.0rc2"
19
+ VERSION = "1.0.0"
20
20
  end
data/test/test_disc.rb CHANGED
@@ -80,7 +80,7 @@ class TestDisc < Test::Unit::TestCase
80
80
  assert_equal @fiction_last_track, disc.last_track_number
81
81
  assert_equal @fiction_sectors, disc.sectors
82
82
  assert_equal @fiction_seconds, disc.seconds
83
- assert_equal @fiction_offsets, disc.tracks.map{|t| t.start_sector}
83
+ assert_equal @fiction_offsets, disc.tracks.map{|t| t.offset}
84
84
  assert_equal @fiction_lengths, disc.tracks.map{|t| t.sectors}
85
85
  end
86
86
 
data/test/test_discid.rb CHANGED
@@ -81,7 +81,7 @@ class TestDiscId < Test::Unit::TestCase
81
81
  proc_test_track = lambda do |track|
82
82
  assert_equal number + 1, track.number
83
83
 
84
- assert_equal @fiction_offsets[number], track.start_sector
84
+ assert_equal @fiction_offsets[number], track.offset
85
85
  assert_equal @fiction_lengths[number], track.sectors
86
86
  assert_equal @fiction_offsets[number]+ @fiction_lengths[number],
87
87
  track.end_sector
@@ -14,10 +14,10 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  require 'test/unit'
17
- require 'discid/track_info'
17
+ require 'discid/track'
18
18
 
19
- # Unit test for the DiscId::TrackInfo class.
20
- class TestTrackInfo < Test::Unit::TestCase
19
+ # Unit test for the DiscId::Track class.
20
+ class TestTrack < Test::Unit::TestCase
21
21
 
22
22
  def setup
23
23
  @number = 3
@@ -27,10 +27,10 @@ class TestTrackInfo < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_init_track_info
30
- track = DiscId::TrackInfo.new @number, @offset, @length, @isrc
30
+ track = DiscId::Track.new @number, @offset, @length, @isrc
31
31
 
32
32
  assert_equal @number, track.number
33
- assert_equal @offset, track.start_sector
33
+ assert_equal @offset, track.offset
34
34
  assert_equal @length, track.sectors
35
35
  assert_equal @isrc, track.isrc
36
36
 
@@ -41,11 +41,11 @@ class TestTrackInfo < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  def test_to_hash
44
- track = DiscId::TrackInfo.new @number, @offset, @length, @isrc
44
+ track = DiscId::Track.new @number, @offset, @length, @isrc
45
45
  hash = track.to_hash
46
46
 
47
47
  assert_equal track.number, hash[:number]
48
- assert_equal track.start_sector, hash[:start_sector]
48
+ assert_equal track.offset, hash[:offset]
49
49
  assert_equal track.sectors, hash[:sectors]
50
50
  assert_equal track.isrc, hash[:isrc]
51
51
 
@@ -56,10 +56,10 @@ class TestTrackInfo < Test::Unit::TestCase
56
56
  end
57
57
 
58
58
  def test_selector_access
59
- track = DiscId::TrackInfo.new @number, @offset, @length, @isrc
59
+ track = DiscId::Track.new @number, @offset, @length, @isrc
60
60
 
61
61
  assert_equal track.number, track[:number]
62
- assert_equal track.start_sector, track[:start_sector]
62
+ assert_equal track.offset, track[:offset]
63
63
  assert_equal track.sectors, track[:sectors]
64
64
  assert_equal track.isrc, track[:isrc]
65
65
 
@@ -70,7 +70,7 @@ class TestTrackInfo < Test::Unit::TestCase
70
70
  end
71
71
 
72
72
  def test_invalid_selector_value
73
- track = DiscId::TrackInfo.new @number, @offset, @length, @isrc
73
+ track = DiscId::Track.new @number, @offset, @length, @isrc
74
74
  assert_equal nil, track[:invalid_value]
75
75
  end
76
76
 
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0rc2
5
- prerelease: 5
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Philipp Wolfer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
11
+ date: 2013-05-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffi
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.6.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ! '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.6.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - ! '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '1.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '1.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: yard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: kramdown
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -109,44 +98,44 @@ files:
109
98
  - README.md
110
99
  - Rakefile
111
100
  - discid.gemspec
101
+ - examples/discidinfo.rb
112
102
  - examples/readdiscid.rb
113
103
  - lib/discid.rb
114
104
  - lib/discid/disc.rb
115
105
  - lib/discid/lib.rb
116
- - lib/discid/track_info.rb
106
+ - lib/discid/track.rb
117
107
  - lib/discid/version.rb
118
108
  - test/test_disc.rb
119
109
  - test/test_discid.rb
120
- - test/test_track_info.rb
110
+ - test/test_track.rb
121
111
  homepage: https://github.com/phw/ruby-discid
122
112
  licenses:
123
113
  - LGPL-3
114
+ metadata: {}
124
115
  post_install_message: Please make sure you have libdiscid (http://musicbrainz.org/doc/libdiscid)
125
116
  installed.
126
117
  rdoc_options: []
127
118
  require_paths:
128
119
  - lib
129
120
  required_ruby_version: !ruby/object:Gem::Requirement
130
- none: false
131
121
  requirements:
132
122
  - - ! '>='
133
123
  - !ruby/object:Gem::Version
134
- version: '0'
124
+ version: 1.8.7
135
125
  required_rubygems_version: !ruby/object:Gem::Requirement
136
- none: false
137
126
  requirements:
138
- - - ! '>'
127
+ - - ! '>='
139
128
  - !ruby/object:Gem::Version
140
- version: 1.3.1
129
+ version: 1.3.6
141
130
  requirements:
142
131
  - libdiscid >= 0.1.0
143
132
  rubyforge_project:
144
- rubygems_version: 1.8.23
133
+ rubygems_version: 2.0.3
145
134
  signing_key:
146
- specification_version: 3
135
+ specification_version: 4
147
136
  summary: Ruby bindings for libdiscid
148
137
  test_files:
149
138
  - test/test_disc.rb
150
139
  - test/test_discid.rb
151
- - test/test_track_info.rb
140
+ - test/test_track.rb
152
141
  has_rdoc: