id3tag 0.12.1 → 0.14.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
2
  SHA256:
3
- metadata.gz: 19488a0e5c2d7354946f8c02f9190134580fde95820eb2ab3e35b559e4c85819
4
- data.tar.gz: 5b25ad975028445328117b0aaa443e4b781ca86bed14101366baa8fbf57915d0
3
+ metadata.gz: 8ee2f5e34526388ad61267ade1af0773b4bd85c723b252cc7848a4a692d99281
4
+ data.tar.gz: 984577caccfa629dc79ad4b0c49d52a2b7ce08598400084b199e2b4fc1909d8f
5
5
  SHA512:
6
- metadata.gz: 7d717cde84a8bcad1bcfb93c8f024e64fa315933bccd199f68a748c7b54c5ef57f7b184f926da63627eec14af1eeb769380e73dbe5f6cd5cefe657a1ef1782ff
7
- data.tar.gz: 4a80fd637e147b07f2ba2c35f5cbee826c430a778e86d3bec69bdf2e581f87e5c9794ea6542e60697f12826e51060f7f87b11cecb6c3fa507b815a7c85c1d548
6
+ metadata.gz: 22617752ac7e06ae319cf97d034c2d358b926252a76957e87899acdace5d130fd9051f43cf769e59e9a3c9d99c52bb417c475c24bcd1c7506a0196d1768d2fb6
7
+ data.tar.gz: 6eea548143a08b68522d860ed3f0c8da2ed64590dfd87c7a3a4c7b182799542dfc9396eb8c9578b5686659b5bc013f63eb12b04a928ef771dbf892188051e3ff
data/README.md CHANGED
@@ -12,7 +12,7 @@ gem install id3tag
12
12
 
13
13
  Or add the gem to your Gemfile:
14
14
  ```
15
- gem 'id3tag', '~> 0.11.0'
15
+ gem 'id3tag', '~> 0.14.0'
16
16
  ```
17
17
 
18
18
  ## How to use
@@ -67,14 +67,20 @@ ID3Tag.configuration do |c|
67
67
 
68
68
  # This way you can avoid Encoding::InvalidByteSequenceError when tag contains invalid data.
69
69
  # Currently only for String#encode which is used in TextFrames.
70
- # default: {}
70
+ # default: {}
71
71
  c.string_encode_options = { :invalid => :replace, :undef => :replace }
72
-
72
+
73
73
  # You might want to set v2.x tag read limit in bytes to avoid reading too much data into memory
74
74
  # v2 tags will be extracted until end of tag or limit is reached.
75
- # default: 0 (There are no limit)
75
+ # default: 0 (There are no limit)
76
76
  c.v2_tag_read_limit = 1048576 # 1 megabyte
77
-
77
+
78
+ # In some situations, it's not possible to recognize what is the encoding of a
79
+ # text frame. The default behavior is to raise UnsupportedTextEncoding, but
80
+ # it's possible to set a fallback to avoid it.
81
+ # default: nil
82
+ c.source_encoding_fallback = Encoding::UTF_8
83
+
78
84
  end
79
85
 
80
86
  ID3Tag.configuration.v2_tag_read_limit # 1048576
@@ -91,7 +97,7 @@ ID3Tag.local_configuration do
91
97
  ID3Tag.configuration.v2_tag_read_limit # 1024
92
98
  ID3Tag.configuration.v2_tag_read_limit = 9999
93
99
  # ...
94
- ID3Tag.configuration.v2_tag_read_limit # 9999
100
+ ID3Tag.configuration.v2_tag_read_limit # 9999
95
101
  end
96
102
 
97
103
  ID3Tag.configuration.v2_tag_read_limit # 1024
@@ -119,7 +125,7 @@ ID3Tag.configuration.v2_tag_read_limit # 0
119
125
  * 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.
120
126
 
121
127
  ## Code Status
122
- [![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)
128
+ [![Code Climate](https://codeclimate.com/github/krists/id3tag.svg)](https://codeclimate.com/github/krists/id3tag) [![Build Status](https://travis-ci.org/krists/id3tag.svg?branch=master)](https://travis-ci.org/krists/id3tag) [![Coverage Status](https://coveralls.io/repos/krists/id3tag/badge.svg?branch=master)](https://coveralls.io/r/krists/id3tag) [![Gem Version](https://badge.fury.io/rb/id3tag.svg)](http://badge.fury.io/rb/id3tag)
123
129
  ## Copyright
124
130
 
125
131
  Copyright (c) 2018 Krists Ozols. See LICENSE.txt for
@@ -20,14 +20,14 @@ module ID3Tag
20
20
  end
21
21
 
22
22
  def v2_tag_present?
23
- @file.rewind
23
+ @file.seek(0)
24
24
  @file.read(3) == IDV2_TAG_IDENTIFIER
25
25
  end
26
26
 
27
27
  def v1_tag_body
28
28
  if v1_tag_present?
29
29
  @file.seek(-v1_tag_size, IO::SEEK_END)
30
- @file.read
30
+ @file.read(v1_tag_size)
31
31
  else
32
32
  nil
33
33
  end
@@ -45,6 +45,7 @@ module ID3Tag
45
45
  if v2_tag_size > 0
46
46
  @file.seek(v2_tag_frame_and_padding_position)
47
47
  bytes_to_read = v2_tag_frame_and_padding_size
48
+ return BLANK_STRING if bytes_to_read < 0
48
49
  limit = ID3Tag.configuration.v2_tag_read_limit
49
50
  if (limit > 0) && (bytes_to_read > limit)
50
51
  bytes_to_read = limit
@@ -111,7 +112,7 @@ module ID3Tag
111
112
  end
112
113
 
113
114
  def get_v2_tag_header
114
- @file.rewind
115
+ @file.seek(0)
115
116
  ID3v2TagHeader.new(@file.read(ID3V2_TAG_HEADER_SIZE))
116
117
  end
117
118
  end
@@ -3,9 +3,11 @@ module ID3Tag
3
3
  def initialize
4
4
  @string_encode_options = {}
5
5
  @v2_tag_read_limit = 0
6
+ @source_encoding_fallback = nil
6
7
  end
7
8
 
8
9
  attr_accessor :string_encode_options
9
10
  attr_accessor :v2_tag_read_limit
11
+ attr_accessor :source_encoding_fallback
10
12
  end
11
13
  end
@@ -27,7 +27,7 @@ module ID3Tag
27
27
  end
28
28
 
29
29
  def self.encode(text, source_encoding)
30
- text.encode(DESTINATION_ENCODING, source_encoding, ID3Tag.configuration.string_encode_options)
30
+ text.encode(DESTINATION_ENCODING, source_encoding, **ID3Tag.configuration.string_encode_options)
31
31
  end
32
32
  end
33
33
  end
@@ -20,6 +20,7 @@ module ID3Tag
20
20
  :comments => :COM,
21
21
  :genre => :TCO,
22
22
  :track_nr => :TRK,
23
+ :disc_nr => :TPA,
23
24
  :unsychronized_transcription => :ULT,
24
25
  :image => :PIC
25
26
  },
@@ -31,6 +32,7 @@ module ID3Tag
31
32
  :comments => :COMM,
32
33
  :genre => :TCON,
33
34
  :track_nr => :TRCK,
35
+ :disc_nr => :TPOS,
34
36
  :unsychronized_transcription => :USLT,
35
37
  :image => :APIC
36
38
  },
@@ -42,6 +44,7 @@ module ID3Tag
42
44
  :comments => :COMM,
43
45
  :genre => :TCON,
44
46
  :track_nr => :TRCK,
47
+ :disc_nr => :TPOS,
45
48
  :unsychronized_transcription => :USLT,
46
49
  :image => :APIC
47
50
  }
@@ -15,7 +15,7 @@ module ID3Tag
15
15
  end
16
16
 
17
17
  def content
18
- @content.encode(destination_encoding, source_encoding)
18
+ EncodingUtil.encode(@content, source_encoding)
19
19
  end
20
20
  end
21
21
  end
@@ -9,15 +9,11 @@ module ID3Tag
9
9
  end
10
10
 
11
11
  def content
12
- @content.encode(destination_encoding, source_encoding)
12
+ EncodingUtil.encode(@content, source_encoding)
13
13
  end
14
14
 
15
15
  private
16
16
 
17
- def destination_encoding
18
- Encoding::UTF_8
19
- end
20
-
21
17
  def source_encoding
22
18
  Encoding::ISO8859_1
23
19
  end
@@ -32,7 +32,7 @@ module ID3Tag
32
32
  end
33
33
 
34
34
  def encoded_content
35
- content_without_encoding_byte_and_language.encode(destination_encoding, source_encoding)
35
+ EncodingUtil.encode(content_without_encoding_byte_and_language, source_encoding)
36
36
  end
37
37
 
38
38
  def content_without_encoding_byte_and_language
@@ -21,15 +21,13 @@ module ID3Tag
21
21
  private
22
22
 
23
23
  def encoded_content
24
- content_without_encoding_byte.encode(destination_encoding, source_encoding, ID3Tag.configuration.string_encode_options)
24
+ EncodingUtil.encode(content_without_encoding_byte, source_encoding)
25
25
  end
26
26
 
27
27
  def source_encoding
28
- ENCODING_MAP.fetch(get_encoding_byte) { raise UnsupportedTextEncoding }.to_s
29
- end
30
-
31
- def destination_encoding
32
- Encoding::UTF_8.to_s
28
+ ENCODING_MAP.fetch(get_encoding_byte) do
29
+ ID3Tag.configuration.source_encoding_fallback || raise(UnsupportedTextEncoding)
30
+ end.to_s
33
31
  end
34
32
 
35
33
  def get_encoding_byte
@@ -60,7 +60,7 @@ module ID3Tag
60
60
  end
61
61
 
62
62
  def rewind_input
63
- @input.rewind
63
+ @input.seek(0)
64
64
  end
65
65
 
66
66
  def padding_or_eof_reached?
data/lib/id3tag/tag.rb CHANGED
@@ -38,7 +38,7 @@ module ID3Tag
38
38
 
39
39
  def first_frame_by_id(*ids)
40
40
  first_existing_id = ids.find { |id| frame_ids.include?(id) }
41
- first_existing_id && get_frame(first_existing_id)
41
+ first_existing_id && get_frames(first_existing_id).first
42
42
  end
43
43
 
44
44
  def all_frames_by_id(*ids)
@@ -1,3 +1,3 @@
1
1
  module ID3Tag
2
- VERSION = "0.12.1"
2
+ VERSION = "0.14.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: id3tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krists Ozols
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,84 +30,84 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 12.1.0
33
+ version: 13.0.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 12.1.0
40
+ version: 13.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 5.1.0
47
+ version: 6.3.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 5.1.0
54
+ version: 6.3.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.6.0
61
+ version: 3.10.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.6.0
68
+ version: 3.10.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.14.1
75
+ version: 0.16.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.14.1
82
+ version: 0.16.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.21
89
+ version: 0.8.23
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.8.21
96
+ version: 0.8.23
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.11.1
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.11.1
110
+ version: '0'
111
111
  description: Native Ruby ID3 tag reader that aims for 100% coverage of ID3v2.x and
112
112
  ID3v1.x standards
113
113
  email: krists.ozols@gmail.com
@@ -160,7 +160,7 @@ homepage: https://github.com/krists/id3tag
160
160
  licenses:
161
161
  - MIT
162
162
  metadata: {}
163
- post_install_message:
163
+ post_install_message:
164
164
  rdoc_options: []
165
165
  require_paths:
166
166
  - lib
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.7.3
180
- signing_key:
178
+ rubygems_version: 3.3.3
179
+ signing_key:
181
180
  specification_version: 4
182
181
  summary: Native Ruby ID3 tag reader that aims for 100% coverage of ID3v2.x and ID3v1.x
183
182
  standards