id3tag 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -2
- data/lib/id3tag.rb +10 -7
- data/lib/id3tag/configuration.rb +39 -4
- data/lib/id3tag/configuration_struct.rb +11 -0
- data/lib/id3tag/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 622d36527a37667a879b10d57e1375687d961461c51fe9bdd57637f8911b797d
|
4
|
+
data.tar.gz: 0a10600c4a862998e60334795481c839814637a2d34a32e387245d7c5648cddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 681cea3d65d268544530e47096994732ebcc533a476e7bc843f50d6ad18eb7f77e4b7a81cc012a36f49cd063176a2a2cd37f77193c32eeb4e69e03fa8b511749
|
7
|
+
data.tar.gz: a7aea6358d52bca1d416cafeafdca93a797df5f91273528961a22b0658b46e6f9c0684806dbdbc22757961ab3012fe8bf7731bdab804e57bd2a2a3521fc0b09d
|
data/README.md
CHANGED
@@ -60,9 +60,9 @@ You can inspect tag by calling `frame_ids` to see available frame ids or `frames
|
|
60
60
|
|
61
61
|
## Configuration
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
|
65
64
|
```ruby
|
65
|
+
# Configuration could be set using a block syntax.
|
66
66
|
ID3Tag.configuration do |c|
|
67
67
|
|
68
68
|
# This way you can avoid Encoding::InvalidByteSequenceError when tag contains invalid data.
|
@@ -76,6 +76,29 @@ ID3Tag.configuration do |c|
|
|
76
76
|
c.v2_tag_read_limit = 1048576 # 1 megabyte
|
77
77
|
|
78
78
|
end
|
79
|
+
|
80
|
+
ID3Tag.configuration.v2_tag_read_limit # 1048576
|
81
|
+
|
82
|
+
ID3Tag.configuration.v2_tag_read_limit = 1024
|
83
|
+
|
84
|
+
ID3Tag.configuration.v2_tag_read_limit # 1024
|
85
|
+
|
86
|
+
|
87
|
+
# In case you would like to set configuration temporally you could use `local_configuration` method.
|
88
|
+
# Within this block you can read and modify configuration and it wont affect global or layers above.
|
89
|
+
|
90
|
+
ID3Tag.local_configuration do
|
91
|
+
ID3Tag.configuration.v2_tag_read_limit # 1024
|
92
|
+
ID3Tag.configuration.v2_tag_read_limit = 9999
|
93
|
+
# ...
|
94
|
+
ID3Tag.configuration.v2_tag_read_limit # 9999
|
95
|
+
end
|
96
|
+
|
97
|
+
ID3Tag.configuration.v2_tag_read_limit # 1024
|
98
|
+
|
99
|
+
ID3Tag.reset_configuration # Resets global configuration to defaults
|
100
|
+
|
101
|
+
ID3Tag.configuration.v2_tag_read_limit # 0
|
79
102
|
```
|
80
103
|
|
81
104
|
|
data/lib/id3tag.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "stringio"
|
2
|
+
require "singleton"
|
3
|
+
require "id3tag/configuration_struct"
|
2
4
|
require "id3tag/configuration"
|
3
5
|
require "id3tag/synchsafe_integer"
|
4
6
|
require "id3tag/audio_file"
|
@@ -42,15 +44,16 @@ module ID3Tag
|
|
42
44
|
end
|
43
45
|
|
44
46
|
class << self
|
45
|
-
def configuration
|
46
|
-
|
47
|
-
yield @configuration if block_given?
|
48
|
-
@configuration
|
47
|
+
def configuration(&blk)
|
48
|
+
ID3Tag::Configuration.configuration(&blk)
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
51
|
+
def local_configuration(&blk)
|
52
|
+
ID3Tag::Configuration.local_configuration(&blk)
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset_configuration
|
56
|
+
ID3Tag::Configuration.reset
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
data/lib/id3tag/configuration.rb
CHANGED
@@ -1,11 +1,46 @@
|
|
1
1
|
module ID3Tag
|
2
2
|
class Configuration
|
3
|
+
ResetError = Class.new(StandardError)
|
4
|
+
include Singleton
|
5
|
+
StackItem = Struct.new(:configuration)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def local_configuration(&blk)
|
9
|
+
instance.send(:local_configuration, &blk)
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
value = instance.instance_variable_get(:@stack).last&.configuration || instance.instance_variable_get(:@global_configuration)
|
14
|
+
yield value if block_given?
|
15
|
+
value
|
16
|
+
end
|
17
|
+
|
18
|
+
def reset
|
19
|
+
instance.send(:reset)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def local_configuration
|
24
|
+
stack_item = StackItem.new((@stack.last&.configuration || @global_configuration).dup)
|
25
|
+
stack_backup = @stack.dup
|
26
|
+
@stack << stack_item
|
27
|
+
begin
|
28
|
+
yield stack_item.configuration
|
29
|
+
ensure
|
30
|
+
@stack.replace stack_backup
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
3
36
|
def initialize
|
4
|
-
@
|
5
|
-
|
37
|
+
@stack = []
|
38
|
+
reset
|
6
39
|
end
|
7
40
|
|
8
|
-
|
9
|
-
|
41
|
+
def reset
|
42
|
+
raise ResetError, "Configuration cannot be reset within local_configuration block" if @stack.size > 0
|
43
|
+
@global_configuration = ConfigurationStruct.new
|
44
|
+
end
|
10
45
|
end
|
11
46
|
end
|
data/lib/id3tag/version.rb
CHANGED
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krists Ozols
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/id3tag.rb
|
123
123
|
- lib/id3tag/audio_file.rb
|
124
124
|
- lib/id3tag/configuration.rb
|
125
|
+
- lib/id3tag/configuration_struct.rb
|
125
126
|
- lib/id3tag/encoding_util.rb
|
126
127
|
- lib/id3tag/frame_id_advisor.rb
|
127
128
|
- lib/id3tag/frames/util/genre_names.rb
|