discid 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f441af810cb786ff29ca6a8ce97f563feb671071
4
- data.tar.gz: 7d8a7cb27691858ce104aa9ff5fcb725bca28284
2
+ SHA256:
3
+ metadata.gz: fa1e17690165aeec4fbcbba04e78b7e24ceda6f44b409149d682e8a24b83692b
4
+ data.tar.gz: c8b61ae0fef04a93105e9e2d120fcc2b67281086696f22a6f3ee8f5c67395c76
5
5
  SHA512:
6
- metadata.gz: 45d18463877605ece3ed62e5f33d1a8ba2540e5a8e7546d462690d22b3d38fd2e6720cc7d468d0d01c854c5a49421c22ccc2bbb33989334debb5a96bf0fc086d
7
- data.tar.gz: 3d20253983f3aa7df9a97244f8f4bd80b15a0f2dce6de1359958c1320f5df24125f68e13c9833152581ade6fba22500e45a264bb4fdc09ba4126fa4ae72b594c
6
+ metadata.gz: 854bd221c4e17c2828a7ede9586f797715ef138f94fa5d039eae227f72e133913db01541e7f7f9f984dbd51dcf8f14c914b7a1b9752b4dc69400e55bca71b5f8
7
+ data.tar.gz: b4a832781ed273f892a6268cd2a79e2318619b4536e6c49a4b267f10537b9bbaf89d3b1cea64e141496f7b22ee42093f5be48cacd7c06a740da7d07a9fbbc1cb
data/CHANGES.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.2 (2017-12-19)
4
+ * Fixed call to {DiscId::Disc#toc_string} with native implementation
5
+
3
6
  ## 1.3.1 (2017-02-16)
4
- * codeclimate-test-reporter is no longer a development depdendency
7
+ * codeclimate-test-reporter is no longer a development dependency
5
8
 
6
9
  ## 1.3.0 (2016-02-19)
7
10
  * Add support for {DiscId::Disc#toc_string}. Will use the implementation from
@@ -145,13 +145,13 @@ module DiscId
145
145
  # @return [String] The TOC string or `nil` if no ID was yet read.
146
146
  def toc_string
147
147
  return nil if not @read
148
- result = Lib.get_toc_string
148
+ result = Lib.get_toc_string @handle
149
149
  if not result
150
150
  # probably an old version of libdiscid (< 0.6.0)
151
151
  # gather toc string from submission_url
152
152
  match = /toc=([0-9+]+)/.match self.submission_url
153
153
  if match
154
- result = match[1].gsub("+", " ")
154
+ result = match[1].tr("+", " ")
155
155
  else
156
156
  raise "can't get toc string from submission url"
157
157
  end
@@ -35,7 +35,7 @@ module DiscId
35
35
  rescue FFI::NotFoundError
36
36
  attach_function :legacy_read, :discid_read, [:pointer, :string], :int
37
37
 
38
- def self.read(handle, device, features)
38
+ def self.read(handle, device, _features)
39
39
  legacy_read(handle, device)
40
40
  end
41
41
  end
@@ -73,7 +73,7 @@ module DiscId
73
73
  begin
74
74
  attach_function :get_mcn, :discid_get_mcn, [:pointer], :string
75
75
  rescue FFI::NotFoundError
76
- def self.get_mcn(handle)
76
+ def self.get_mcn(_handle)
77
77
  return nil
78
78
  end
79
79
  end
@@ -81,7 +81,7 @@ module DiscId
81
81
  begin
82
82
  attach_function :get_track_isrc, :discid_get_track_isrc, [:pointer, :int], :string
83
83
  rescue FFI::NotFoundError
84
- def self.get_track_isrc(handle, track)
84
+ def self.get_track_isrc(_handle, _track)
85
85
  return nil
86
86
  end
87
87
  end
@@ -109,17 +109,24 @@ module DiscId
109
109
  end
110
110
 
111
111
  def self.features_to_int(features)
112
- feature_flag = 0
112
+ feature_flags = 0
113
113
  features.each do |feature|
114
114
  if feature.respond_to? :to_sym
115
115
  feature = feature.to_sym
116
- feature_flag |= self::Features[feature] if
117
- self::Features.symbols.include?(feature) and
118
- self.has_feature(feature)
116
+ feature_flags = self.add_feature_to_flags(feature_flags, feature)
119
117
  end
120
118
  end
121
119
 
122
- return feature_flag
120
+ return feature_flags
121
+ end
122
+
123
+ private
124
+
125
+ def self.add_feature_to_flags(flags, feature)
126
+ flags |= self::Features[feature] if
127
+ self::Features.symbols.include?(feature) and
128
+ self.has_feature(feature)
129
+ return flags
123
130
  end
124
131
  end
125
132
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
  module DiscId
18
18
  # The version of ruby-discid.
19
- VERSION = "1.3.1"
19
+ VERSION = "1.3.2"
20
20
  end
@@ -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
@@ -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
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.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Wolfer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -133,6 +133,7 @@ files:
133
133
  - test/helper.rb
134
134
  - test/test_disc.rb
135
135
  - test/test_discid.rb
136
+ - test/test_lib.rb
136
137
  - test/test_track.rb
137
138
  homepage: https://github.com/phw/ruby-discid
138
139
  licenses:
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
158
  - libdiscid >= 0.1.0
158
159
  rubyforge_project:
159
- rubygems_version: 2.4.8
160
+ rubygems_version: 2.7.3
160
161
  signing_key:
161
162
  specification_version: 4
162
163
  summary: Ruby bindings for libdiscid
@@ -164,4 +165,5 @@ test_files:
164
165
  - test/helper.rb
165
166
  - test/test_disc.rb
166
167
  - test/test_discid.rb
168
+ - test/test_lib.rb
167
169
  - test/test_track.rb