id3tag 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -5
  3. data/lib/id3tag.rb +11 -4
  4. data/lib/id3tag/audio_file.rb +7 -1
  5. data/lib/id3tag/configuration.rb +2 -0
  6. data/lib/id3tag/id3_v2_frame_parser.rb +12 -8
  7. data/lib/id3tag/version.rb +1 -1
  8. metadata +7 -96
  9. data/.document +0 -5
  10. data/.gitignore +0 -8
  11. data/.rspec +0 -1
  12. data/.travis.yml +0 -15
  13. data/Gemfile +0 -4
  14. data/Rakefile +0 -24
  15. data/id3tag.gemspec +0 -28
  16. data/spec/features/can_read_non_audio_files_spec.rb +0 -17
  17. data/spec/features/can_read_tag_v1_spec.rb +0 -15
  18. data/spec/fixtures/id3v1_and_v2.mp3 +0 -0
  19. data/spec/fixtures/id3v1_with_track_nr.mp3 +0 -0
  20. data/spec/fixtures/id3v1_without_track_nr.mp3 +0 -0
  21. data/spec/fixtures/id3v2.mp3 +0 -0
  22. data/spec/fixtures/pov_20131018-2100a.mp3.v1_tag_body +0 -0
  23. data/spec/fixtures/pov_20131018-2100a.mp3.v2_3_tag_body +0 -0
  24. data/spec/fixtures/signals_1.mp3.v2_3_tag_body +0 -0
  25. data/spec/id3tag_extract_tags +0 -18
  26. data/spec/lib/id3tag/audio_file_spec.rb +0 -131
  27. data/spec/lib/id3tag/frames/util/genre_name_by_id_finder_spec.rb +0 -18
  28. data/spec/lib/id3tag/frames/v1/comments_frame_spec.rb +0 -39
  29. data/spec/lib/id3tag/frames/v1/genre_frame_spec.rb +0 -20
  30. data/spec/lib/id3tag/frames/v1/text_frame_spec.rb +0 -14
  31. data/spec/lib/id3tag/frames/v1/track_nr_frame_spec.rb +0 -19
  32. data/spec/lib/id3tag/frames/v2/basic_frame_spec.rb +0 -140
  33. data/spec/lib/id3tag/frames/v2/comments_frame_spec.rb +0 -45
  34. data/spec/lib/id3tag/frames/v2/frame_fabricator_spec.rb +0 -70
  35. data/spec/lib/id3tag/frames/v2/frame_flags_spec.rb +0 -588
  36. data/spec/lib/id3tag/frames/v2/genre_frame/genre_parser_24_spec.rb +0 -26
  37. data/spec/lib/id3tag/frames/v2/genre_frame/genre_parser_pre_24_spec.rb +0 -48
  38. data/spec/lib/id3tag/frames/v2/genre_frame/genre_parser_spec.rb +0 -13
  39. data/spec/lib/id3tag/frames/v2/genre_frame_spec.rb +0 -61
  40. data/spec/lib/id3tag/frames/v2/picture_frame_spec.rb +0 -127
  41. data/spec/lib/id3tag/frames/v2/text_frame_spec.rb +0 -89
  42. data/spec/lib/id3tag/frames/v2/unique_file_id_frame_spec.rb +0 -31
  43. data/spec/lib/id3tag/frames/v2/user_text_frame_spec.rb +0 -34
  44. data/spec/lib/id3tag/id3_v1_frame_parser_spec.rb +0 -71
  45. data/spec/lib/id3tag/id3_v2_frame_parser_spec.rb +0 -32
  46. data/spec/lib/id3tag/id3_v2_tag_header_spec.rb +0 -149
  47. data/spec/lib/id3tag/id3tag_spec.rb +0 -17
  48. data/spec/lib/id3tag/io_util_spec.rb +0 -30
  49. data/spec/lib/id3tag/number_util_spec.rb +0 -32
  50. data/spec/lib/id3tag/string_util_spec.rb +0 -81
  51. data/spec/lib/id3tag/synchsafe_integer_spec.rb +0 -14
  52. data/spec/lib/id3tag/tag_spec.rb +0 -352
  53. data/spec/spec_helper.rb +0 -23
  54. data/spec/support/mp3_fixtures.rb +0 -4
  55. data/standard_documents/id3v2-00.txt +0 -1657
  56. data/standard_documents/id3v2.3.0.txt +0 -2022
  57. data/standard_documents/id3v2.4.0-frames.txt +0 -1732
  58. data/standard_documents/id3v2.4.0-structure.txt +0 -732
@@ -1,18 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
4
- require "id3tag"
5
-
6
- ARGV.each do |file|
7
- audio_file = ID3Tag.read(File.open(file, "r")).send(:audio_file)
8
- if audio_file.v1_tag_present?
9
- handle = File.open(file + ".v1_tag_body", "w")
10
- handle.write(audio_file.v1_tag_body)
11
- handle.close
12
- end
13
- if audio_file.v2_tag_present?
14
- handle = File.open(file + ".v2_#{audio_file.v2_tag_major_version_number}_tag_body", "w")
15
- handle.write(audio_file.v2_tag_body)
16
- handle.close
17
- end
18
- end
@@ -1,131 +0,0 @@
1
- require "spec_helper"
2
- describe ID3Tag::AudioFile do
3
- let(:mp3_with_v1_tag) { mp3_fixture('id3v1_without_track_nr.mp3') }
4
- let(:mp3_with_v2_tag) { mp3_fixture('id3v2.mp3') }
5
- let(:mp3_with_v1_and_v2_tags) { mp3_fixture('id3v1_and_v2.mp3') }
6
- let(:broken_mp3) do
7
- file = Tempfile.new("broken_mp3")
8
- file.write("just something..but not enough")
9
- file
10
- end
11
-
12
- describe "Tag presence checking methods" do
13
- context "reading file only with ID3v1 tag" do
14
- subject { described_class.new(mp3_with_v1_tag) }
15
-
16
- describe '#v1_tag_present?' do
17
- subject { super().v1_tag_present? }
18
- it { is_expected.to eq(true) }
19
- end
20
-
21
- describe '#v1_tag_size' do
22
- subject { super().v1_tag_size }
23
- it { is_expected.to eq(125) }
24
- end
25
-
26
-
27
- describe '#v2_tag_present?' do
28
- subject { super().v2_tag_present? }
29
- it { is_expected.to eq(false) }
30
- end
31
-
32
- describe '#v2_tag_size' do
33
- subject { super().v2_tag_size }
34
- it { is_expected.to eq(0) }
35
- end
36
- end
37
-
38
- context "reading file only with ID3v2 tag" do
39
- subject { described_class.new(mp3_with_v2_tag) }
40
-
41
- describe '#v1_tag_present?' do
42
- subject { super().v1_tag_present? }
43
- it { is_expected.to eq(false) }
44
- end
45
-
46
- describe '#v1_tag_size' do
47
- subject { super().v1_tag_size }
48
- it { is_expected.to eq(0) }
49
- end
50
-
51
- describe '#v2_tag_present?' do
52
- subject { super().v2_tag_present? }
53
- it { is_expected.to eq(true) }
54
- end
55
-
56
- describe '#v2_tag_size' do
57
- subject { super().v2_tag_size }
58
- it { is_expected.to eq(246) }
59
- end
60
- end
61
-
62
- context "reading file with ID3v1 and ID3v2 tags" do
63
- subject { described_class.new(mp3_with_v1_and_v2_tags) }
64
-
65
- describe '#v1_tag_present?' do
66
- subject { super().v1_tag_present? }
67
- it { is_expected.to eq(true) }
68
- end
69
-
70
- describe '#v2_tag_present?' do
71
- subject { super().v2_tag_present? }
72
- it { is_expected.to eq(true) }
73
- end
74
- end
75
- end
76
-
77
- describe "#v1_tag_body" do
78
- context "when reading file with alteast 125 bytes" do
79
- subject { described_class.new(mp3_with_v1_tag) }
80
- it "should return last 125 bytes of audio file" do
81
- expect(subject.v1_tag_body).to eq(File.read(mp3_with_v1_tag, 125, 579))
82
- end
83
- end
84
- context "when reading file with size less ID3v1 tag" do
85
- subject { described_class.new(broken_mp3) }
86
- it "should return as much bytes as possible" do
87
- expect(subject.v1_tag_body).to eq(nil)
88
- end
89
- end
90
- end
91
-
92
- describe "#v2_tag_body" do
93
- context "when extended header is not present" do
94
- subject { described_class.new(StringIO.new("ID3\u0003\u0000\u0000\u0000\u0000\u0000\u0003ABC")) }
95
- it "should return frame and padding bytes" do
96
- expect(subject.v2_tag_body).to eq("ABC")
97
- end
98
- end
99
- context "when extended header is present" do
100
- subject { described_class.new(StringIO.new("ID3\u0003\u0000\u0040\u0000\u0000\u0000\u0011" + "\u0000\u0000\u0000\u000A" + ("\u0000" * 10) + "ABC")) }
101
- it "should return frame and padding bytes" do
102
- expect(subject.v2_tag_body).to eq("ABC")
103
- end
104
- context "when tag verison is v.2.4 and extended header size is calculated differently" do
105
- subject { described_class.new(StringIO.new("ID3\u0004\u0000\u0040\u0000\u0000\u0000\u0011" + "\u0000\u0000\u0000\u000A" + ("\u0000" * 6) + "ABC")) }
106
- it "should return frame and padding bytes" do
107
- expect(subject.v2_tag_body).to eq("ABC")
108
- end
109
- end
110
- end
111
- end
112
-
113
- context "when reading file with v2.3.0 tag" do
114
- subject { described_class.new(StringIO.new("ID3\u0003\u0000")) }
115
-
116
- describe '#v2_tag_version' do
117
- subject { super().v2_tag_version }
118
- it { is_expected.to eq '3.0' }
119
- end
120
-
121
- describe '#v2_tag_major_version_number' do
122
- subject { super().v2_tag_major_version_number }
123
- it { is_expected.to eq 3 }
124
- end
125
-
126
- describe '#v2_tag_minor_version_number' do
127
- subject { super().v2_tag_minor_version_number }
128
- it { is_expected.to eq 0 }
129
- end
130
- end
131
- end
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ID3Tag::Frames::Util::GenreNames do
4
-
5
- describe 'self#find_by_id' do
6
- subject { described_class.find_by_id(id) }
7
-
8
- context "when calling with id 0 what represents Blues" do
9
- let(:id) { 0 }
10
- it { is_expected.to eq('Blues') }
11
- end
12
-
13
- context "when calling with id 17 what represents Rock" do
14
- let(:id) { 17 }
15
- it { is_expected.to eq('Rock') }
16
- end
17
- end
18
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- describe ID3Tag::Frames::V1::CommentsFrame do
3
- describe '#id' do
4
- subject { described_class.new('comments', nil).id }
5
- it { is_expected.to eq('comments') }
6
- end
7
-
8
- describe '#content' do
9
- context 'when comment is present' do
10
- subject { described_class.new('comments', 'some comment about the song').content }
11
- it { is_expected.to eq('some comment about the song') }
12
- end
13
-
14
- context 'when comment is not present' do
15
- subject { described_class.new('comments', '').content }
16
- it { is_expected.to eq('') }
17
- end
18
- end
19
-
20
- describe "#text" do
21
- subject { described_class.new('comments', 'some comment about the song') }
22
- it "should be the same as #content" do
23
- allow(subject).to receive(:content) { "ZXC" }
24
- expect(subject.text).to eq(subject.content)
25
- end
26
- end
27
-
28
- describe '#language' do
29
- it 'should be unknown' do
30
- expect(described_class.new('comments', '').language).to eq('unknown')
31
- end
32
- end
33
-
34
- describe '#desciption' do
35
- it 'should be unknown' do
36
- expect(described_class.new('comments', '').desciption).to eq('unknown')
37
- end
38
- end
39
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- describe ID3Tag::Frames::V1::GenreFrame do
3
- describe '#id' do
4
- subject { described_class.new('genre', nil).id }
5
- it { is_expected.to eq('genre') }
6
- end
7
-
8
- describe '#content' do
9
- context 'when genre is blues' do
10
- subject { described_class.new('genre', [0].pack('c')).content }
11
- it { is_expected.to eq('Blues') }
12
- end
13
-
14
- context 'when genre is metal' do
15
- subject { described_class.new('genre', [9].pack('c')).content }
16
- it { is_expected.to eq('Metal') }
17
- end
18
- end
19
- end
20
-
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- describe ID3Tag::Frames::V1::TextFrame do
3
- describe '#id' do
4
- subject { described_class.new('album', nil).id }
5
- it { is_expected.to eq('album') }
6
- end
7
-
8
- describe '#content' do
9
- context 'when containing track artist' do
10
- subject { described_class.new('artist', 'some fancy artist').content }
11
- it { is_expected.to eq('some fancy artist') }
12
- end
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
- describe ID3Tag::Frames::V1::TrackNrFrame do
3
- describe '#id' do
4
- subject { described_class.new('track_nr', nil).id }
5
- it { is_expected.to eq('track_nr') }
6
- end
7
-
8
- describe '#content' do
9
- context 'when nr is 3' do
10
- subject { described_class.new('track_nr', [3].pack('c')).content }
11
- it { is_expected.to eq('3') }
12
- end
13
-
14
- context 'when nr is 11' do
15
- subject { described_class.new('track_nr', [11].pack('c')).content }
16
- it { is_expected.to eq('11') }
17
- end
18
- end
19
- end
@@ -1,140 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ID3Tag::Frames::V2::BasicFrame do
4
- let(:id) { 'foo' }
5
- let(:raw_content) { 'bar' }
6
- let(:flags) { nil }
7
- let(:major_version_number) { 4 }
8
- let(:frame) { described_class.new(id, raw_content, flags, major_version_number) }
9
-
10
- describe '#id' do
11
- subject { frame.id }
12
- it { is_expected.to eq(:foo) }
13
- end
14
-
15
- describe '#content' do
16
- subject { frame.content }
17
- it { is_expected.to eq('bar') }
18
- context "when frame contains unsynchronised content" do
19
- subject { frame }
20
- let(:flags) { [0b00000000, 0b00000010].pack("C2") }
21
- let(:raw_content) { "\xFF\x00\xEE\xEE" }
22
-
23
- describe '#content' do
24
- subject { super().content }
25
- it { is_expected.to eq("\xFF\xEE\xEE") }
26
- end
27
- end
28
- end
29
-
30
- describe '#final_size' do
31
- subject { frame }
32
- context "when all frags nulled" do
33
- let(:raw_content) { 'foo' }
34
- let(:flags) { nil }
35
-
36
- describe '#final_size' do
37
- subject { super().final_size }
38
- it { is_expected.to eq 3 }
39
- end
40
- end
41
- context "when frame is compressed and data length is set" do
42
- let(:flags) { [0b00000000, 0b00001001].pack("C2") }
43
- let(:raw_content) { [55].pack("N") + 'foo' }
44
-
45
- describe '#final_size' do
46
- subject { super().final_size }
47
- it { is_expected.to eq 55 }
48
- end
49
-
50
- describe '#content' do
51
- subject { super().content }
52
- it { is_expected.to eq "foo" }
53
- end
54
- end
55
- end
56
-
57
- describe '#group_id' do
58
- subject { frame }
59
- context "when all frags nulled" do
60
- let(:raw_content) { 'foo' }
61
- let(:flags) { nil }
62
-
63
- describe '#group_id' do
64
- subject { super().group_id }
65
- it { is_expected.to eq nil }
66
- end
67
- end
68
- context "when frame is compressed and data length is set" do
69
- let(:flags) { [0b00000000, 0b01000000].pack("C2") }
70
- let(:raw_content) { [33].pack("C") + 'foo' }
71
-
72
- describe '#content' do
73
- subject { super().content }
74
- it { is_expected.to eq "foo" }
75
- end
76
-
77
- describe '#group_id' do
78
- subject { super().group_id }
79
- it { is_expected.to eq 33 }
80
- end
81
- end
82
- end
83
-
84
- describe '#encryption_id' do
85
- subject { frame }
86
- context "when all frags nulled" do
87
- let(:raw_content) { 'foo' }
88
- let(:flags) { nil }
89
-
90
- describe '#encryption_id' do
91
- subject { super().encryption_id }
92
- it { is_expected.to eq nil }
93
- end
94
- end
95
- context "when frame is compressed and data length is set" do
96
- let(:flags) { [0b00000000, 0b00000100].pack("C2") }
97
- let(:raw_content) { [1].pack("C") + 'foo' }
98
-
99
- describe '#content' do
100
- subject { super().content }
101
- it { is_expected.to eq "foo" }
102
- end
103
-
104
- describe '#encryption_id' do
105
- subject { super().encryption_id }
106
- it { is_expected.to eq 1 }
107
- end
108
- end
109
- end
110
-
111
- describe "frame future query methods" do
112
- subject { frame }
113
- describe "#read_only?" do
114
- it "should delegate to FrameFlags class" do
115
- expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:read_only?)
116
- subject.read_only?
117
- end
118
- end
119
-
120
- describe "#preserve_on_tag_alteration?" do
121
- it "should delegate to FrameFlags class" do
122
- expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:preserve_on_tag_alteration?)
123
- subject.preserve_on_tag_alteration?
124
- end
125
- end
126
-
127
- describe "#preserve_on_file_alteration?" do
128
- it "should delegate to FrameFlags class" do
129
- expect_any_instance_of(ID3Tag::Frames::V2::FrameFlags).to receive(:preserve_on_file_alteration?)
130
- subject.preserve_on_file_alteration?
131
- end
132
- end
133
- end
134
-
135
- describe '#inspect' do
136
- it 'should be pretty inspectable' do
137
- expect(frame.inspect).to eq('<ID3Tag::Frames::V2::BasicFrame foo>')
138
- end
139
- end
140
- end
@@ -1,45 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe ID3Tag::Frames::V2::CommentsFrame do
5
- let(:id) { "COMM" }
6
- let(:raw_content) do
7
- text.encode(target_encoding).prepend(separator).prepend(short_desc).prepend(lang).prepend(encoding)
8
- end
9
- let(:separator) { "\x00".force_encoding(target_encoding) }
10
- let(:short_desc) { 'bob once said'.force_encoding(target_encoding) }
11
- let(:lang) { 'lav'.force_encoding(target_encoding) }
12
- let(:encoding) { encoding_byte.force_encoding(target_encoding) }
13
- let(:flags) { nil }
14
- let(:major_version_number) { 4 }
15
- let(:target_encoding) { Encoding::UTF_8 }
16
- let(:encoding_byte) { "\x03" }
17
- let(:text) { "Glāzšķūņrūķīši" }
18
- let(:frame) { described_class.new(id, raw_content, flags, major_version_number) }
19
-
20
- describe '#id' do
21
- subject { frame.id }
22
- it { is_expected.to eq(:COMM) }
23
- end
24
-
25
- describe '#content' do
26
- subject { frame.content }
27
- it { is_expected.to eq('Glāzšķūņrūķīši') }
28
- end
29
-
30
- describe '#language' do
31
- subject { frame.language }
32
- it { is_expected.to eq('lav') }
33
- end
34
-
35
- describe '#description' do
36
- subject { frame.description }
37
- it { is_expected.to eq('bob once said') }
38
- end
39
-
40
- describe '#inspect' do
41
- it 'should be pretty inspectable' do
42
- expect(frame.inspect).to eq('<ID3Tag::Frames::V2::CommentsFrame COMM: Glāzšķūņrūķīši>')
43
- end
44
- end
45
- end