mp3file 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 +5 -5
- data/.travis.yml +4 -5
- data/lib/mp3file/mp3_header.rb +4 -0
- data/lib/mp3file/version.rb +1 -1
- data/mp3file.gemspec +2 -2
- data/spec/mp3file/id3v1_tag_spec.rb +100 -22
- data/spec/mp3file/id3v2/bit_padded_int_spec.rb +22 -22
- data/spec/mp3file/id3v2/frame_header_spec.rb +180 -36
- data/spec/mp3file/id3v2/header_spec.rb +221 -53
- data/spec/mp3file/id3v2/tag_spec.rb +40 -8
- data/spec/mp3file/id3v2/version_spec.rb +103 -23
- data/spec/mp3file/mp3_file_spec.rb +549 -106
- data/spec/mp3file/mp3_header_spec.rb +60 -43
- data/spec/mp3file/xing_header_spec.rb +121 -26
- metadata +7 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02d2af45ba050fcd79a6ad1cf2a9293e881be810be1a2c89471d152aea8a1e4d
|
4
|
+
data.tar.gz: c4f1d11342e60b7c1ff8cc1a55a2f95f3e635c1f8898c0959e4a6d827e85140b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46ac99a44bc6e04762683c2ee0f4f7b18f96d170a5e6cb7f1230d85041298e5de57997e101fe7a73bd020500e8c61292b3c391fba60ddeb59b82600d1a976c8b
|
7
|
+
data.tar.gz: e1de3df56fd73be4c2598827cf1669d00c9317c1f748a945cc87d26a6598c244506b694b1256207919853d343c50833ed4a941d7b7d955430015bef23b581620
|
data/.travis.yml
CHANGED
data/lib/mp3file/mp3_header.rb
CHANGED
data/lib/mp3file/version.rb
CHANGED
data/mp3file.gemspec
CHANGED
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.rubyforge_project = "mp3file"
|
17
17
|
|
18
|
-
s.add_development_dependency('rspec', '~>
|
18
|
+
s.add_development_dependency('rspec', '~> 3.0')
|
19
19
|
s.add_development_dependency('rake')
|
20
20
|
s.add_development_dependency('pry')
|
21
21
|
|
22
|
-
s.add_dependency('bindata', '~> 2.
|
22
|
+
s.add_dependency('bindata', '~> 2.4.0')
|
23
23
|
|
24
24
|
s.files = `git ls-files`.split("\n")
|
25
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -5,8 +5,8 @@ include CommonHelpers
|
|
5
5
|
|
6
6
|
describe Mp3file::ID3v1Tag do
|
7
7
|
it "rejects an ID3v1 tag if it doesn't begin with TAG" do
|
8
|
-
|
9
|
-
|
8
|
+
expect { Mp3file::ID3v1Tag.parse(StringIO.new("\x00" * 128)) }.
|
9
|
+
to(raise_error(Mp3file::InvalidID3v1TagError))
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "When created with a properly-formatted ID3v1 tag" do
|
@@ -20,13 +20,40 @@ describe Mp3file::ID3v1Tag do
|
|
20
20
|
Mp3file::ID3v1Tag.parse(StringIO.new('TAG' + title + artist + album + year + comment + genre))
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
describe '#title' do
|
24
|
+
subject { super().title }
|
25
|
+
it { is_expected.to eq('Big Dipper') }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#artist' do
|
29
|
+
subject { super().artist }
|
30
|
+
it { is_expected.to eq('Cracker') }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#album' do
|
34
|
+
subject { super().album }
|
35
|
+
it { is_expected.to eq('The Golden Age') }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#year' do
|
39
|
+
subject { super().year }
|
40
|
+
it { is_expected.to eq('1996') }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#comment' do
|
44
|
+
subject { super().comment }
|
45
|
+
it { is_expected.to eq('This is a comment') }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#track' do
|
49
|
+
subject { super().track }
|
50
|
+
it { is_expected.to eq(nil) }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#genre' do
|
54
|
+
subject { super().genre }
|
55
|
+
it { is_expected.to eq('Rock') }
|
56
|
+
end
|
30
57
|
end
|
31
58
|
|
32
59
|
describe "When created with a properly-formatted ID3v1.1 tag" do
|
@@ -41,22 +68,73 @@ describe Mp3file::ID3v1Tag do
|
|
41
68
|
Mp3file::ID3v1Tag.parse(StringIO.new('TAG' + title + artist + album + year + comment + tracknum + genre))
|
42
69
|
end
|
43
70
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
71
|
+
describe '#title' do
|
72
|
+
subject { super().title }
|
73
|
+
it { is_expected.to eq('Big Dipper') }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#artist' do
|
77
|
+
subject { super().artist }
|
78
|
+
it { is_expected.to eq('Cracker') }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#album' do
|
82
|
+
subject { super().album }
|
83
|
+
it { is_expected.to eq('The Golden Age') }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#year' do
|
87
|
+
subject { super().year }
|
88
|
+
it { is_expected.to eq('1996') }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#comment' do
|
92
|
+
subject { super().comment }
|
93
|
+
it { is_expected.to eq('This is a comment') }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#track' do
|
97
|
+
subject { super().track }
|
98
|
+
it { is_expected.to eq(3) }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#genre' do
|
102
|
+
subject { super().genre }
|
103
|
+
it { is_expected.to eq('Rock') }
|
104
|
+
end
|
51
105
|
end
|
52
106
|
|
53
107
|
describe "When created with a blank ID3v1 tag" do
|
54
108
|
subject { Mp3file::ID3v1Tag.parse(StringIO.new("TAG" + ("\x00" * 125))) }
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
109
|
+
|
110
|
+
describe '#title' do
|
111
|
+
subject { super().title }
|
112
|
+
it { is_expected.to eq("") }
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#artist' do
|
116
|
+
subject { super().artist }
|
117
|
+
it { is_expected.to eq("") }
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#album' do
|
121
|
+
subject { super().album }
|
122
|
+
it { is_expected.to eq("") }
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#comment' do
|
126
|
+
subject { super().comment }
|
127
|
+
it { is_expected.to eq("") }
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#track' do
|
131
|
+
subject { super().track }
|
132
|
+
it { is_expected.to eq(nil) }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#genre' do
|
136
|
+
subject { super().genre }
|
137
|
+
it { is_expected.to eq('Blues') }
|
138
|
+
end
|
61
139
|
end
|
62
140
|
end
|
@@ -3,55 +3,55 @@ require File.dirname(__FILE__) + '/../../../lib/mp3file'
|
|
3
3
|
describe Mp3file::ID3v2::BitPaddedInt do
|
4
4
|
describe ".unpad_number" do
|
5
5
|
it "returns 0 when unpadding 0" do
|
6
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0).
|
6
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0)).to eq(0)
|
7
7
|
end
|
8
8
|
|
9
9
|
context "without specifying bits" do
|
10
10
|
it "returns the least significant 7 bits of each byte in a 4-byte number" do
|
11
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0xFF_FF_FF_FF).
|
12
|
-
|
13
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0b0101_0101_0101_0101_0101_0101_0101_0101).
|
14
|
-
|
15
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0b1010_1010_1010_1010_1010_1010_1010_1010).
|
16
|
-
|
11
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0xFF_FF_FF_FF)).
|
12
|
+
to eq(0x0F_FF_FF_FF)
|
13
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0b0101_0101_0101_0101_0101_0101_0101_0101)).
|
14
|
+
to eq(0b0000_1010_1011_0101_0110_1010_1101_0101)
|
15
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0b1010_1010_1010_1010_1010_1010_1010_1010)).
|
16
|
+
to eq(0b0000_0101_0100_1010_1001_0101_0010_1010)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context "specifying bits as n" do
|
21
21
|
it "returns the least significant n bits from each byte of a 4-byte number" do
|
22
22
|
1.upto(7) do |n|
|
23
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0xFF_FF_FF_FF, n).
|
24
|
-
|
23
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0xFF_FF_FF_FF, n)).
|
24
|
+
to eq(16**n - 1)
|
25
25
|
end
|
26
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0b0101_0101_0101_0101_0101_0101_0101_0101, 5).
|
27
|
-
|
28
|
-
Mp3file::ID3v2::BitPaddedInt.unpad_number(0b1010_1010_1010_1010_1010_1010_1010_1010, 3).
|
29
|
-
|
26
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0b0101_0101_0101_0101_0101_0101_0101_0101, 5)).
|
27
|
+
to eq(0b1010_1101_0110_1011_0101)
|
28
|
+
expect(Mp3file::ID3v2::BitPaddedInt.unpad_number(0b1010_1010_1010_1010_1010_1010_1010_1010, 3)).
|
29
|
+
to eq(0b1001_001_0010)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe ".pad_number" do
|
35
35
|
it "returns 0 when padding 0" do
|
36
|
-
Mp3file::ID3v2::BitPaddedInt.pad_number(0).
|
36
|
+
expect(Mp3file::ID3v2::BitPaddedInt.pad_number(0)).to eq(0)
|
37
37
|
end
|
38
38
|
|
39
39
|
context "without specifying bits" do
|
40
40
|
it "keeps the least significant 28 bits of a 4-byte number and pads each byte with a 0" do
|
41
|
-
Mp3file::ID3v2::BitPaddedInt.pad_number(0xFF_FF_FF_FF).
|
42
|
-
|
43
|
-
Mp3file::ID3v2::BitPaddedInt.pad_number(0b0101_0101_0101_0101_0101_0101_0101_0101).
|
44
|
-
|
45
|
-
Mp3file::ID3v2::BitPaddedInt.pad_number(0b1010_1010_1010_1010_1010_1010_1010_1010).
|
46
|
-
|
41
|
+
expect(Mp3file::ID3v2::BitPaddedInt.pad_number(0xFF_FF_FF_FF)).
|
42
|
+
to eq(0x7F_7F_7F_7F)
|
43
|
+
expect(Mp3file::ID3v2::BitPaddedInt.pad_number(0b0101_0101_0101_0101_0101_0101_0101_0101)).
|
44
|
+
to eq(0b0010_1010_0101_0101_0010_1010_0101_0101)
|
45
|
+
expect(Mp3file::ID3v2::BitPaddedInt.pad_number(0b1010_1010_1010_1010_1010_1010_1010_1010)).
|
46
|
+
to eq(0b0101_0101_0010_1010_0101_0101_0010_1010)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context "specifying bits as n" do
|
51
51
|
it "keeps the bottom n*4 bits and pads each byte with 0s" do
|
52
52
|
1.upto(7) do |n|
|
53
|
-
Mp3file::ID3v2::BitPaddedInt.pad_number(0xFF_FF_FF_FF, n).
|
54
|
-
|
53
|
+
expect(Mp3file::ID3v2::BitPaddedInt.pad_number(0xFF_FF_FF_FF, n)).
|
54
|
+
to eq((2**n - 1)*(256**3 + 256**2 + 256**1 + 1))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -9,18 +9,66 @@ describe Mp3file::ID3v2::FrameHeader do
|
|
9
9
|
|
10
10
|
describe("A 15-byte long TT2 frame header.") do
|
11
11
|
subject { Mp3file::ID3v2::FrameHeader.new(StringIO.new("TT2\x00\x00\x0f"), tag) }
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
|
13
|
+
describe '#frame_id' do
|
14
|
+
subject { super().frame_id }
|
15
|
+
it { is_expected.to eq('TT2') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#size' do
|
19
|
+
subject { super().size }
|
20
|
+
it { is_expected.to eq(21) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#frame_size' do
|
24
|
+
subject { super().frame_size }
|
25
|
+
it { is_expected.to eq(15) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#preserve_on_altered_tag' do
|
29
|
+
subject { super().preserve_on_altered_tag }
|
30
|
+
it { is_expected.to eq(false) }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#preserve_on_altered_file' do
|
34
|
+
subject { super().preserve_on_altered_file }
|
35
|
+
it { is_expected.to eq(false) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#read_only' do
|
39
|
+
subject { super().read_only }
|
40
|
+
it { is_expected.to eq(false) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#compressed' do
|
44
|
+
subject { super().compressed }
|
45
|
+
it { is_expected.to eq(false) }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#encrypted' do
|
49
|
+
subject { super().encrypted }
|
50
|
+
it { is_expected.to eq(false) }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#encryption_type' do
|
54
|
+
subject { super().encryption_type }
|
55
|
+
it { is_expected.to be_nil }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#group' do
|
59
|
+
subject { super().group }
|
60
|
+
it { is_expected.to be_nil }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#unsynchronized' do
|
64
|
+
subject { super().unsynchronized }
|
65
|
+
it { is_expected.to eq(false) }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#data_length' do
|
69
|
+
subject { super().data_length }
|
70
|
+
it { is_expected.to eq(0) }
|
71
|
+
end
|
24
72
|
end
|
25
73
|
end
|
26
74
|
|
@@ -37,34 +85,130 @@ describe Mp3file::ID3v2::FrameHeader do
|
|
37
85
|
|
38
86
|
describe("A 9-byte TIT2 frame header.") do
|
39
87
|
subject { Mp3file::ID3v2::FrameHeader.new(StringIO.new("TIT2\x00\x00\x00\x09\x00\x00"), tag) }
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
88
|
+
|
89
|
+
describe '#frame_id' do
|
90
|
+
subject { super().frame_id }
|
91
|
+
it { is_expected.to eq('TIT2') }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#size' do
|
95
|
+
subject { super().size }
|
96
|
+
it { is_expected.to eq(19) }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#frame_size' do
|
100
|
+
subject { super().frame_size }
|
101
|
+
it { is_expected.to eq(9) }
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#preserve_on_altered_tag' do
|
105
|
+
subject { super().preserve_on_altered_tag }
|
106
|
+
it { is_expected.to eq(false) }
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#preserve_on_altered_file' do
|
110
|
+
subject { super().preserve_on_altered_file }
|
111
|
+
it { is_expected.to eq(false) }
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#read_only' do
|
115
|
+
subject { super().read_only }
|
116
|
+
it { is_expected.to eq(false) }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#compressed' do
|
120
|
+
subject { super().compressed }
|
121
|
+
it { is_expected.to eq(false) }
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#encrypted' do
|
125
|
+
subject { super().encrypted }
|
126
|
+
it { is_expected.to eq(false) }
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#encryption_type' do
|
130
|
+
subject { super().encryption_type }
|
131
|
+
it { is_expected.to be_nil }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#group' do
|
135
|
+
subject { super().group }
|
136
|
+
it { is_expected.to be_nil }
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#unsynchronized' do
|
140
|
+
subject { super().unsynchronized }
|
141
|
+
it { is_expected.to eq(false) }
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#data_length' do
|
145
|
+
subject { super().data_length }
|
146
|
+
it { is_expected.to eq(0) }
|
147
|
+
end
|
52
148
|
end
|
53
149
|
|
54
150
|
describe("A TIT2 header with all of its flags set") do
|
55
151
|
subject { Mp3file::ID3v2::FrameHeader.new(StringIO.new("TIT2\x00\x00\x00\x09\x00\x00"), tag) }
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
152
|
+
|
153
|
+
describe '#frame_id' do
|
154
|
+
subject { super().frame_id }
|
155
|
+
it { is_expected.to eq('TIT2') }
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#size' do
|
159
|
+
subject { super().size }
|
160
|
+
it { is_expected.to eq(19) }
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#frame_size' do
|
164
|
+
subject { super().frame_size }
|
165
|
+
it { is_expected.to eq(9) }
|
166
|
+
end
|
167
|
+
|
168
|
+
describe '#preserve_on_altered_tag' do
|
169
|
+
subject { super().preserve_on_altered_tag }
|
170
|
+
it { is_expected.to eq(false) }
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#preserve_on_altered_file' do
|
174
|
+
subject { super().preserve_on_altered_file }
|
175
|
+
it { is_expected.to eq(false) }
|
176
|
+
end
|
177
|
+
|
178
|
+
describe '#read_only' do
|
179
|
+
subject { super().read_only }
|
180
|
+
it { is_expected.to eq(false) }
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#compressed' do
|
184
|
+
subject { super().compressed }
|
185
|
+
it { is_expected.to eq(false) }
|
186
|
+
end
|
187
|
+
|
188
|
+
describe '#encrypted' do
|
189
|
+
subject { super().encrypted }
|
190
|
+
it { is_expected.to eq(false) }
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '#encryption_type' do
|
194
|
+
subject { super().encryption_type }
|
195
|
+
it { is_expected.to be_nil }
|
196
|
+
end
|
197
|
+
|
198
|
+
describe '#group' do
|
199
|
+
subject { super().group }
|
200
|
+
it { is_expected.to be_nil }
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#unsynchronized' do
|
204
|
+
subject { super().unsynchronized }
|
205
|
+
it { is_expected.to eq(false) }
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '#data_length' do
|
209
|
+
subject { super().data_length }
|
210
|
+
it { is_expected.to eq(0) }
|
211
|
+
end
|
68
212
|
end
|
69
213
|
end
|
70
214
|
|