id3tag 0.2.1 → 0.3.0

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
2
  SHA1:
3
- metadata.gz: e6b0b5c61e35171280ba6a4c9141159ba0079e25
4
- data.tar.gz: ad16f770564f70a30b3504fb5945656a2693f37a
3
+ metadata.gz: 3045586a23981f0e85728d27cd804bc238c1d8cb
4
+ data.tar.gz: f150bbc0d6286360265eee5d605d93f187af2ee6
5
5
  SHA512:
6
- metadata.gz: 3580b6133eeef63c3b3b14e5f508df15473756d928aaf595171835750c85616a25fd2251f2ae6e9cffe538d3e99fc198fdb55768788ae7b948f2c66e6b2e3b6f
7
- data.tar.gz: 18a2596b48760925683077237bb01871a82cf4f82ff350fef323e4e8da8eb0e4d129ad05d988abd2d9ca9b413c398adae0ec45dab8d8fb67d4a8325e6c6925b6
6
+ metadata.gz: 12d22e4a838918bcac2262248ce3d84b51be500f92aba2ef6b07b4772079361e32b51a8b7953d19ebeee4c591190f8174488aca6453a0ce5519a1544f257ada0
7
+ data.tar.gz: a6e04f69ed6dc53bfde17187bfedab5ceecc5a876f24fd593190dd64e2bd084708c914dc7684d4e7d675a6da40349d8aa13bd5ad8d9afb2e9a10effac3f24e4c
data/README.md CHANGED
@@ -72,8 +72,7 @@ You can inspect tag by calling `frame_ids` to see available frame ids or `frames
72
72
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
73
73
 
74
74
  ## Code Status
75
- [![Code Climate](https://codeclimate.com/github/krists/id3tag.png)](https://codeclimate.com/github/krists/id3tag) [![Build Status](https://travis-ci.org/krists/id3tag.png?branch=master)](https://travis-ci.org/krists/id3tag) [![Coverage Status](https://coveralls.io/repos/krists/id3tag/badge.png?branch=master)](https://coveralls.io/r/krists/id3tag)
76
-
75
+ [![Code Climate](https://codeclimate.com/github/krists/id3tag.png)](https://codeclimate.com/github/krists/id3tag) [![Build Status](https://travis-ci.org/krists/id3tag.png?branch=master)](https://travis-ci.org/krists/id3tag) [![Coverage Status](https://coveralls.io/repos/krists/id3tag/badge.png?branch=master)](https://coveralls.io/r/krists/id3tag) [![Gem Version](https://badge.fury.io/rb/id3tag.png)](http://badge.fury.io/rb/id3tag)
77
76
  ## Copyright
78
77
 
79
78
  Copyright (c) 2013 Krists Ozols. See LICENSE.txt for
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
data/id3tag.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "id3tag"
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Krists Ozols"]
@@ -82,11 +82,15 @@ module ID3Tag
82
82
  end
83
83
 
84
84
  def inspect
85
- "<#{self.class.name} #{id}: #{inspectable_content}>"
85
+ if inspectable_content
86
+ "<#{self.class.name} #{id}: #{inspectable_content}>"
87
+ else
88
+ "<#{self.class.name} #{id}>"
89
+ end
86
90
  end
87
91
 
88
92
  def inspectable_content
89
- content
93
+ nil
90
94
  end
91
95
 
92
96
  private
@@ -20,10 +20,14 @@ module ID3Tag
20
20
  text
21
21
  end
22
22
 
23
+ def inspectable_content
24
+ content
25
+ end
26
+
23
27
  private
24
28
 
25
29
  def encoded_text_and_content_parts
26
- @encoded_text_and_content_parts ||= encoded_text_and_content.split("\00",2)
30
+ @encoded_text_and_content_parts ||= encoded_text_and_content.split(current_encoding_map[:terminator], 2)
27
31
  end
28
32
 
29
33
  def encoded_text_and_content
@@ -12,6 +12,8 @@ module ID3Tag
12
12
  genres.join(", ")
13
13
  end
14
14
 
15
+ alias inspectable_content content
16
+
15
17
  private
16
18
 
17
19
  def get_genres
@@ -2,22 +2,29 @@ module ID3Tag
2
2
  module Frames
3
3
  module V2
4
4
  class TextFrame < BasicFrame
5
+ NULL_BYTE = "\x00"
5
6
  UnsupportedTextEncoding = Class.new(StandardError)
6
7
  ENCODING_MAP = {
7
- 0b0 => Encoding::ISO8859_1,
8
- 0b1 => Encoding::UTF_16,
9
- 0b10 => Encoding::UTF_16BE,
10
- 0b11 => Encoding::UTF_8
8
+ 0b0 => { :encoding => Encoding::ISO8859_1, :terminator => NULL_BYTE },
9
+ 0b1 => { :encoding => Encoding::UTF_16, :terminator => NULL_BYTE * 2 },
10
+ 0b10 =>{ :encoding => Encoding::UTF_16BE, :terminator => NULL_BYTE * 2 },
11
+ 0b11 =>{ :encoding => Encoding::UTF_8, :terminator => NULL_BYTE }
11
12
  }
12
13
 
13
14
  def content
14
15
  @content ||= content_without_encoding_byte.encode(destination_encoding, source_encoding)
15
16
  end
16
17
 
18
+ alias inspectable_content content
19
+
17
20
  private
18
21
 
19
22
  def source_encoding
20
- ENCODING_MAP[get_encoding_byte] || raise(UnsupportedTextEncoding)
23
+ current_encoding_map[:encoding]
24
+ end
25
+
26
+ def current_encoding_map
27
+ ENCODING_MAP.fetch(get_encoding_byte) { raise UnsupportedTextEncoding }
21
28
  end
22
29
 
23
30
  def destination_encoding
@@ -94,7 +94,7 @@ describe ID3Tag::Frames::V2::BasicFrame do
94
94
 
95
95
  describe '#inspect' do
96
96
  it 'should be pretty inspectable' do
97
- frame.inspect.should eq('<ID3Tag::Frames::V2::BasicFrame foo: bar>')
97
+ frame.inspect.should eq('<ID3Tag::Frames::V2::BasicFrame foo>')
98
98
  end
99
99
  end
100
100
  end
@@ -11,6 +11,15 @@ describe ID3Tag::ID3V2FrameParser do
11
11
  subject.frames
12
12
  end
13
13
  end
14
+ context "parsing v2.2.3 tag" do
15
+ let(:tag_major_version) { 3 }
16
+ let(:frame_bytes) { "TIT2\u0000\u0000\u0000\u0004\u0000\u0000\u0000ABC" + "TIT1\u0000\u0000\u0000\u0004\u0000\u0000\u0000DEF" }
17
+ it "should fabricate frames" do
18
+ ID3Tag::Frames::V2::FrameFabricator.should_receive(:fabricate).with('TIT2', "\u0000ABC", "\u0000\u0000", 3).once
19
+ ID3Tag::Frames::V2::FrameFabricator.should_receive(:fabricate).with('TIT1', "\u0000DEF", "\u0000\u0000", 3).once
20
+ subject.frames
21
+ end
22
+ end
14
23
  context "parsing v2.4.x tag" do
15
24
  let(:tag_major_version) { 4 }
16
25
  let(:frame_bytes) { "TIT2\u0000\u0000\u0000\u0004\u0000\u0000\u0000ABC" + "TIT1\u0000\u0000\u0000\u0004\u0000\u0000\u0000DEF" }
data/tags CHANGED
@@ -124,6 +124,7 @@ content_without_encoding_byte lib/id3tag/frames/v2/text_frame.rb /^ def c
124
124
  convert_32bit_integer_to_string lib/id3tag/number_util.rb /^ def self.convert_32bit_integer_to_string(integer)$/;" F class:ID3Tag.NumberUtil
125
125
  convert_string_to_32bit_integer lib/id3tag/number_util.rb /^ def self.convert_string_to_32bit_integer(string)$/;" F class:ID3Tag.NumberUtil
126
126
  current_additional_info_map lib/id3tag/frames/v2/frame_flags.rb /^ def current_additional_info_map$/;" f class:ID3Tag.Frames.V2.FrameFlags
127
+ current_encoding_map lib/id3tag/frames/v2/text_frame.rb /^ def current_encoding_map$/;" f class:ID3Tag.Frames.V2.TextFrame
127
128
  current_flag_map lib/id3tag/frames/v2/frame_flags.rb /^ def current_flag_map$/;" f class:ID3Tag.Frames.V2.FrameFlags
128
129
  data_length_indicator? lib/id3tag/frames/v2/basic_frame.rb /^ def data_length_indicator?$/;" f class:ID3Tag.Frames.V2.BasicFrame
129
130
  data_length_indicator? lib/id3tag/frames/v2/frame_flags.rb /^ def data_length_indicator?$/;" f class:ID3Tag.Frames.V2.FrameFlags
@@ -207,6 +208,7 @@ input_bytes lib/id3tag/unsynchronization.rb /^ def input_bytes$/;" f class:ID
207
208
  inspect lib/id3tag/frames/v2/basic_frame.rb /^ def inspect$/;" f class:ID3Tag.Frames.V2.BasicFrame
208
209
  inspect lib/id3tag/id3_v2_tag_header.rb /^ def inspect$/;" f class:ID3Tag.ID3v2TagHeader
209
210
  inspectable_content lib/id3tag/frames/v2/basic_frame.rb /^ def inspectable_content$/;" f class:ID3Tag.Frames.V2.BasicFrame
211
+ inspectable_content lib/id3tag/frames/v2/comments_frame.rb /^ def inspectable_content$/;" f class:ID3Tag.Frames.V2.CommentsFrame
210
212
  inspectable_content lib/id3tag/frames/v2/unique_file_id_frame.rb /^ def inspectable_content$/;" f class:ID3Tag.Frames.V2.UniqueFileIdFrame
211
213
  just_genres lib/id3tag/frames/v2/genre_frame/genre_parser_pre_24.rb /^ def just_genres$/;" f class:ID3Tag.Frames.V2.GenreFrame.GenreParserPre24
212
214
  just_requirements lib/id3tag/frames/v2/genre_frame/genre_parser_pre_24.rb /^ def just_requirements$/;" f class:ID3Tag.Frames.V2.GenreFrame.GenreParserPre24
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: id3tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krists Ozols