ehbrs-tools 0.5.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/executables.rb +7 -1
  3. data/lib/ehbrs/fs.rb +9 -0
  4. data/lib/ehbrs/fs/compressed_package.rb +48 -0
  5. data/lib/ehbrs/gems.rb +37 -0
  6. data/lib/ehbrs/observers.rb +11 -0
  7. data/lib/ehbrs/observers/base.rb +64 -0
  8. data/lib/ehbrs/observers/with_persistence.rb +34 -0
  9. data/lib/ehbrs/runner/fs.rb +19 -0
  10. data/lib/ehbrs/runner/fs/used_space.rb +161 -0
  11. data/lib/ehbrs/runner/self.rb +19 -0
  12. data/lib/ehbrs/runner/self/test.rb +30 -0
  13. data/lib/ehbrs/runner/vg/ips.rb +67 -18
  14. data/lib/ehbrs/runner/videos/extract.rb +71 -0
  15. data/lib/ehbrs/runner/videos/series.rb +21 -0
  16. data/lib/ehbrs/runner/videos/series/rename.rb +75 -0
  17. data/lib/ehbrs/self.rb +9 -0
  18. data/lib/ehbrs/self/observers/used_space.rb +22 -0
  19. data/lib/ehbrs/self/observers/with_persistence.rb +38 -0
  20. data/lib/ehbrs/tools/version.rb +1 -1
  21. data/lib/ehbrs/user_dirs.rb +34 -0
  22. data/lib/ehbrs/vg/wii/game_file.rb +13 -0
  23. data/lib/ehbrs/videos/extract.rb +11 -0
  24. data/lib/ehbrs/videos/extract/package.rb +75 -0
  25. data/lib/ehbrs/videos/extract/package_file.rb +54 -0
  26. data/lib/ehbrs/videos/series.rb +11 -0
  27. data/lib/ehbrs/videos/series/rename.rb +13 -0
  28. data/lib/ehbrs/videos/series/rename/directory_group.rb +28 -0
  29. data/lib/ehbrs/videos/series/rename/file.rb +114 -0
  30. data/lib/ehbrs/videos/series/rename/file/basename_parser.rb +44 -0
  31. data/lib/ehbrs/videos/series/rename/file/options.rb +30 -0
  32. data/lib/ehbrs/videos/series/rename/line_result.rb +26 -0
  33. data/lib/ehbrs/videos/series/rename/line_result_group.rb +39 -0
  34. data/lib/ehbrs/videos/series/rename/results_builder.rb +32 -0
  35. data/lib/ehbrs/videos/series/rename/season_group.rb +39 -0
  36. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +8 -2
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +2 -2
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb +52 -0
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb +16 -0
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb +34 -0
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/on_clean_ruby_environment.rb +5 -16
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb +4 -0
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb +45 -0
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb +15 -0
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb +4 -0
  48. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb +16 -0
  49. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb +4 -0
  50. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +5 -0
  51. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +25 -0
  52. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb +9 -0
  53. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +31 -0
  54. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +26 -0
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  56. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
  57. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/temp_spec.rb +12 -0
  58. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +52 -0
  59. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb +39 -0
  60. metadata +85 -2
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+
5
+ module EacRubyUtils
6
+ module Ruby
7
+ ::EacRubyUtils.require_sub(__FILE__)
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs/command'
4
+ require 'eac_ruby_utils/ruby/on_clean_environment'
5
+
6
+ module EacRubyUtils
7
+ module Ruby
8
+ # A [EacRubyUtils::Envs::Command] which runs in a clean Ruby environment.
9
+ class Command < ::EacRubyUtils::Envs::Command
10
+ def initialize(bundle_args, extra_options = {})
11
+ super(::EacRubyUtils::Envs.local, bundle_args, extra_options)
12
+ end
13
+
14
+ %w[system execute].each do |method_prefix|
15
+ [method_prefix, "#{method_prefix}!"].each do |method_name|
16
+ define_method method_name do |*args, &block|
17
+ ::EacRubyUtils::Ruby.on_clean_environment do
18
+ super(*args, &block)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def duplicate(command, extra_options)
27
+ self.class.new(gem, command, extra_options)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Ruby
5
+ class << self
6
+ # Executes a block in an environment when the variables BUNDLE* and RUBY* are removed.
7
+ def on_clean_environment
8
+ on_clean_envvars('BUNDLE', 'RUBY') { yield }
9
+ end
10
+
11
+ private
12
+
13
+ def on_clean_envvars(*start_with_vars)
14
+ old_values = envvars_starting_with(start_with_vars)
15
+ old_values.keys.each { |k| ENV.delete(k) }
16
+ yield
17
+ ensure
18
+ old_values&.each { |k, v| ENV[k] = v }
19
+ end
20
+
21
+ def envvars_starting_with(start_with_vars)
22
+ ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.28.0'
4
+ VERSION = '0.33.0'
5
5
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/extname'
4
+
5
+ RSpec.describe ::EacRubyUtils::Fs do
6
+ describe '#extname' do
7
+ {
8
+ 'After.Life.S01E01.WEBRip.x264-ION10.mp4' => '.mp4',
9
+ 's01e01.en.srt' => '.en.srt',
10
+ 's01e01.srt' => '.srt',
11
+ '/path/to/file.tar.gz' => '.tar.gz'
12
+ }.each do |source, expected|
13
+ context "when source is \"#{source}\"" do
14
+ it { expect(described_class.extname(source)).to eq(expected) }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/temp/directory'
4
+
5
+ RSpec.describe ::EacRubyUtils::Fs::Temp::Directory do
6
+ describe '#remove!' do
7
+ let(:instance) { described_class.new }
8
+
9
+ it { expect(instance).to be_directory }
10
+ it { expect { instance.remove! }.to_not raise_error }
11
+ end
12
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/temp'
4
+
5
+ RSpec.describe ::EacRubyUtils::Fs::Temp do
6
+ describe '#on_file' do
7
+ it do
8
+ temp_path = nil
9
+ described_class.on_file do |path|
10
+ temp_path = path
11
+ expect(temp_path).not_to exist
12
+ temp_path.write('StubText')
13
+ expect(temp_path).to exist
14
+ end
15
+ expect(temp_path).not_to exist
16
+ end
17
+
18
+ it 'not fail if already removed' do
19
+ temp_path = nil
20
+ described_class.on_file do |path|
21
+ temp_path = path
22
+ expect(temp_path).not_to exist
23
+ temp_path.write('StubText')
24
+ expect(temp_path).to exist
25
+ temp_path.unlink
26
+ end
27
+ expect(temp_path).not_to exist
28
+ end
29
+ end
30
+
31
+ describe '#on_directory' do
32
+ it do
33
+ temp_path = nil
34
+ described_class.on_directory do |path|
35
+ temp_path = path
36
+ expect(temp_path).to be_directory
37
+ end
38
+ expect(temp_path).not_to exist
39
+ end
40
+
41
+ it 'not fail if already removed' do
42
+ temp_path = nil
43
+ described_class.on_directory do |path|
44
+ temp_path = path
45
+ expect(temp_path).to be_directory
46
+ temp_path.rmtree
47
+ expect(temp_path).not_to exist
48
+ end
49
+ expect(temp_path).not_to exist
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/enumerable/boolean_combinations'
4
+
5
+ RSpec.describe ::Enumerable do
6
+ let(:empty_instance) { [].to_enum }
7
+ let(:a_instance) { [:a].to_enum }
8
+ let(:ab_instance) { %i[a b].to_enum }
9
+
10
+ describe '#bool_hash_combs' do
11
+ it do
12
+ expect(empty_instance.bool_hash_combs).to eq([])
13
+ end
14
+
15
+ it do
16
+ expect(a_instance.bool_hash_combs).to eq([{ a: false }, { a: true }])
17
+ end
18
+
19
+ it do
20
+ expect(ab_instance.bool_hash_combs)
21
+ .to eq([{ a: false, b: false }, { a: false, b: true }, { a: true, b: false },
22
+ { a: true, b: true }])
23
+ end
24
+ end
25
+
26
+ describe '#bool_array_combs' do
27
+ it do
28
+ expect(empty_instance.bool_array_combs).to eq([])
29
+ end
30
+
31
+ it do
32
+ expect(a_instance.bool_array_combs).to eq([[], [:a]])
33
+ end
34
+
35
+ it do
36
+ expect(ab_instance.bool_array_combs).to eq([[], [:a], [:b], %i[a b]])
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-26 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: avm-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.44'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.44.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.44'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.44.2
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: eac_ruby_utils
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +44,20 @@ dependencies:
24
44
  - - "~>"
25
45
  - !ruby/object:Gem::Version
26
46
  version: '0.19'
47
+ - !ruby/object:Gem::Dependency
48
+ name: filesize
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
27
61
  - !ruby/object:Gem::Dependency
28
62
  name: inifile
29
63
  requirement: !ruby/object:Gem::Requirement
@@ -63,14 +97,31 @@ files:
63
97
  - exe/ehbrs
64
98
  - lib/ehbrs.rb
65
99
  - lib/ehbrs/executables.rb
100
+ - lib/ehbrs/fs.rb
101
+ - lib/ehbrs/fs/compressed_package.rb
102
+ - lib/ehbrs/gems.rb
103
+ - lib/ehbrs/observers.rb
104
+ - lib/ehbrs/observers/base.rb
105
+ - lib/ehbrs/observers/with_persistence.rb
66
106
  - lib/ehbrs/runner.rb
107
+ - lib/ehbrs/runner/fs.rb
108
+ - lib/ehbrs/runner/fs/used_space.rb
109
+ - lib/ehbrs/runner/self.rb
110
+ - lib/ehbrs/runner/self/test.rb
67
111
  - lib/ehbrs/runner/vg.rb
68
112
  - lib/ehbrs/runner/vg/ips.rb
69
113
  - lib/ehbrs/runner/vg/wii.rb
70
114
  - lib/ehbrs/runner/videos.rb
115
+ - lib/ehbrs/runner/videos/extract.rb
116
+ - lib/ehbrs/runner/videos/series.rb
117
+ - lib/ehbrs/runner/videos/series/rename.rb
71
118
  - lib/ehbrs/runner/videos/unsupported.rb
119
+ - lib/ehbrs/self.rb
120
+ - lib/ehbrs/self/observers/used_space.rb
121
+ - lib/ehbrs/self/observers/with_persistence.rb
72
122
  - lib/ehbrs/tools.rb
73
123
  - lib/ehbrs/tools/version.rb
124
+ - lib/ehbrs/user_dirs.rb
74
125
  - lib/ehbrs/vg.rb
75
126
  - lib/ehbrs/vg/wii.rb
76
127
  - lib/ehbrs/vg/wii/file_move.rb
@@ -82,9 +133,22 @@ files:
82
133
  - lib/ehbrs/vg/wii/wit/path.rb
83
134
  - lib/ehbrs/videos.rb
84
135
  - lib/ehbrs/videos/convert_job.rb
136
+ - lib/ehbrs/videos/extract.rb
137
+ - lib/ehbrs/videos/extract/package.rb
138
+ - lib/ehbrs/videos/extract/package_file.rb
85
139
  - lib/ehbrs/videos/file.rb
86
140
  - lib/ehbrs/videos/profiles/base.rb
87
141
  - lib/ehbrs/videos/profiles/same_quality.rb
142
+ - lib/ehbrs/videos/series.rb
143
+ - lib/ehbrs/videos/series/rename.rb
144
+ - lib/ehbrs/videos/series/rename/directory_group.rb
145
+ - lib/ehbrs/videos/series/rename/file.rb
146
+ - lib/ehbrs/videos/series/rename/file/basename_parser.rb
147
+ - lib/ehbrs/videos/series/rename/file/options.rb
148
+ - lib/ehbrs/videos/series/rename/line_result.rb
149
+ - lib/ehbrs/videos/series/rename/line_result_group.rb
150
+ - lib/ehbrs/videos/series/rename/results_builder.rb
151
+ - lib/ehbrs/videos/series/rename/season_group.rb
88
152
  - lib/ehbrs/videos/track.rb
89
153
  - lib/ehbrs/videos/unsupported/check_result.rb
90
154
  - lib/ehbrs/videos/unsupported/check_set.rb
@@ -157,6 +221,10 @@ files:
157
221
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb
158
222
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb
159
223
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs.rb
224
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb
225
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb
226
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb
227
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
160
228
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
161
229
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb
162
230
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb
@@ -174,6 +242,8 @@ files:
174
242
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches.rb
175
243
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class.rb
176
244
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/common_constructor.rb
245
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb
246
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
177
247
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb
178
248
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb
179
249
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
@@ -187,13 +257,22 @@ files:
187
257
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb
188
258
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb
189
259
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb
260
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
190
261
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname.rb
191
262
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb
263
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb
264
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb
265
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb
266
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
267
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb
192
268
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb
193
269
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb
194
270
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb
195
271
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb
196
272
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/stubbed_ssh.rb
273
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb
274
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb
275
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb
197
276
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb
198
277
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb
199
278
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/templates.rb
@@ -212,8 +291,12 @@ files:
212
291
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb
213
292
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/ssh_env_spec.rb
214
293
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/filesystem_cache_spec.rb
294
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb
295
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/temp_spec.rb
296
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb
215
297
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb
216
298
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
299
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb
217
300
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/options_consumer_spec.rb
218
301
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb
219
302
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/console_speaker_spec.rb