ehbrs-tools 0.37.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/Gemfile.lock +97 -60
  4. data/exe/ehbrs +1 -1
  5. data/lib/ehbrs/executables.rb +1 -8
  6. data/lib/ehbrs/google/translate/session.rb +1 -1
  7. data/lib/ehbrs/observers/base.rb +2 -3
  8. data/lib/ehbrs/observers/with_persistence.rb +1 -1
  9. data/lib/ehbrs/self/observers/with_persistence.rb +1 -1
  10. data/lib/ehbrs/tools/runner/finances/bb_browser.rb +4 -4
  11. data/lib/ehbrs/tools/runner/fs/used_space.rb +1 -1
  12. data/lib/ehbrs/tools/runner/google/translate.rb +1 -1
  13. data/lib/ehbrs/tools/runner/telegram/send_message.rb +3 -3
  14. data/lib/ehbrs/tools/runner/vg/ips.rb +2 -2
  15. data/lib/ehbrs/tools/runner/vg/ps2/rename.rb +34 -0
  16. data/lib/ehbrs/tools/runner/vg/ps2.rb +19 -0
  17. data/lib/ehbrs/tools/runner/videos/languages/file_runner.rb +2 -1
  18. data/lib/ehbrs/tools/runner/videos/languages.rb +1 -1
  19. data/lib/ehbrs/tools/runner/videos/series/rename.rb +1 -1
  20. data/lib/ehbrs/tools/runner/videos/subtitles/sanitize.rb +38 -0
  21. data/lib/ehbrs/tools/runner/videos/subtitles.rb +20 -0
  22. data/lib/ehbrs/tools/runner/videos/unsupported.rb +1 -1
  23. data/lib/ehbrs/tools/runner/web_utils/videos/upload.rb +1 -1
  24. data/lib/ehbrs/tools/runner_with/filesystem_renamer.rb +103 -0
  25. data/lib/ehbrs/tools/runner_with.rb +11 -0
  26. data/lib/ehbrs/tools/version.rb +1 -1
  27. data/lib/ehbrs/user_dirs.rb +1 -1
  28. data/lib/ehbrs/videos/convert_job.rb +3 -3
  29. data/lib/ehbrs/videos/extract/package_file.rb +1 -1
  30. data/lib/ehbrs/videos/file.rb +2 -2
  31. data/lib/ehbrs/videos/track.rb +3 -2
  32. data/lib/ehbrs/videos/unsupported/check_support.rb +5 -7
  33. data/lib/ehbrs/videos/unsupported/profiles/samsung.rb +1 -0
  34. metadata +20 -71
  35. data/.rspec +0 -1
  36. data/.rubocop.yml +0 -39
  37. data/lib/ehbrs/gems.rb +0 -37
  38. data/spec/code/rubocop_spec.rb +0 -3
  39. data/spec/lib/ehbrs/observers/base_spec.rb +0 -93
  40. data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +0 -62
  41. data/spec/lib/ehbrs/tools/runner/vg/ips_spec.rb +0 -31
  42. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/expected.rom +0 -0
  43. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_0.ips +0 -0
  44. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_1.ips +0 -0
  45. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/source.rom +0 -0
  46. data/spec/lib/ehbrs/tools/runner/videos/probe_spec.rb +0 -19
  47. data/spec/lib/ehbrs/tools/runner/videos/probe_spec_files/fixed.target.yaml +0 -105
  48. data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec.rb +0 -75
  49. data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec_files/dts_audio.probe.yaml +0 -91
  50. data/spec/lib/ehbrs/tools/runner_spec.rb +0 -16
  51. data/spec/spec_helper/videos.rb +0 -30
  52. data/spec/spec_helper/videos_files/stub_source.mp4 +0 -0
  53. data/spec/spec_helper.rb +0 -7
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Ehbrs
6
+ module Tools
7
+ module RunnerWith
8
+ module FilesystemRenamer
9
+ common_concern do
10
+ runner_with :confirmation, :filesystem_traverser
11
+ prepend PrependMethods
12
+ end
13
+
14
+ class RenameFile
15
+ enable_speaker
16
+ common_constructor :runner, :file
17
+ delegate :path, :target_path, :valid?, to: :file
18
+
19
+ CONFIRM_MESSAGE = 'Rename?'
20
+
21
+ def show
22
+ if rename?
23
+ puts [target_path_to_s, '<='.green, path_to_s].join(' ')
24
+ else
25
+ puts path_to_s
26
+ end
27
+ end
28
+
29
+ def rename
30
+ return unless rename?
31
+
32
+ show
33
+ do_rename if runner.confirm?(CONFIRM_MESSAGE)
34
+ end
35
+
36
+ # @return [Boolean]
37
+ def rename?
38
+ path.to_pathname != target_path.to_pathname
39
+ end
40
+
41
+ private
42
+
43
+ def do_rename
44
+ ::FileUtils.mv(path, target_path)
45
+ end
46
+
47
+ # @return [String]
48
+ def path_to_s
49
+ path.basename.to_path.light_black
50
+ end
51
+
52
+ # @return [String]
53
+ def target_path_to_s
54
+ target_path.relative_path_from(path.dirname).to_path
55
+ end
56
+ end
57
+
58
+ module PrependMethods
59
+ # @param path [Pathname]
60
+ # @return [void]
61
+ def traverser_check_file(path)
62
+ file = RenameFile.new(self, file_class.new(path))
63
+ files << file if file.valid?
64
+ end
65
+ end
66
+
67
+ FILE_WRAPPER_CLASS_BASENAME = 'FileWrapper'
68
+
69
+ # @return [Class]
70
+ def file_class
71
+ self.class.const_get(FILE_WRAPPER_CLASS_BASENAME)
72
+ end
73
+
74
+ # @return [void]
75
+ def run_filesystem_renamer
76
+ self.files = []
77
+ run_filesystem_traverser
78
+ show_files
79
+ rename_files
80
+ success 'Done'
81
+ end
82
+
83
+ # @return [void]
84
+ def show_files
85
+ infov 'Files found', files.count
86
+ files.each(&:show)
87
+ end
88
+
89
+ # @return [void]
90
+ def rename_files
91
+ return if parsed.no? || files.none?(&:rename?)
92
+
93
+ infom 'Renaming files...'
94
+ files.each(&:rename)
95
+ end
96
+
97
+ private
98
+
99
+ attr_accessor :files
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Ehbrs
6
+ module Tools
7
+ module RunnerWith
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.37.0'
5
+ VERSION = '0.39.0'
6
6
  end
7
7
  end
@@ -15,7 +15,7 @@ module Ehbrs
15
15
  private
16
16
 
17
17
  def user_home_dir_uncached
18
- ::EacFs::StorageTree.new(ENV['HOME'])
18
+ ::EacFs::StorageTree.new(Dir.home)
19
19
  end
20
20
 
21
21
  def cache_uncached
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs/executables'
4
+ require 'ehbrs_ruby_utils/executables'
5
5
  require 'fileutils'
6
6
 
7
7
  module Ehbrs
@@ -46,7 +46,7 @@ module Ehbrs
46
46
 
47
47
  def convert
48
48
  infov 'Convert args', command_args.shelljoin
49
- ::Ehbrs::Executables.ffmpeg.command.append(command_args).system!
49
+ ::EhbrsRubyUtils::Executables.ffmpeg.command.append(command_args).system!
50
50
  end
51
51
 
52
52
  def format_by_args_uncached
@@ -76,7 +76,7 @@ module Ehbrs
76
76
  end
77
77
 
78
78
  def converting
79
- target + '.converting'
79
+ "#{target}.converting"
80
80
  end
81
81
 
82
82
  def converted
@@ -19,7 +19,7 @@ module Ehbrs
19
19
 
20
20
  def match_quality?(quality)
21
21
  path.basename_sub { |b| b.to_s.downcase }.basename
22
- .fnmatch?("*#{quality.downcase}*".gsub(/\A\*+/, '*').gsub(/\*+\z/, '*'))
22
+ .fnmatch?("*#{quality.downcase}*".gsub(/\A\*+/, '*').gsub(/\*+\z/, '*'))
23
23
  end
24
24
 
25
25
  def move_to_quality_dir
@@ -34,7 +34,7 @@ module Ehbrs
34
34
  end
35
35
 
36
36
  def hmsf_to_seconds(hour, minute, second, float_part)
37
- r = hour.to_f * 3600 + minute.to_f * 60 + second.to_f
37
+ r = (hour.to_f * 3600) + (minute.to_f * 60) + second.to_f
38
38
  r += float_part.to_f / (10**float_part.length) if float_part
39
39
  r
40
40
  end
@@ -53,7 +53,7 @@ module Ehbrs
53
53
  end
54
54
 
55
55
  def duration_uncached
56
- m = /Duration\:\s*(#{TIME_PATTERN})/.match(content)
56
+ m = /Duration:\s*(#{TIME_PATTERN})/.match(content)
57
57
  raise 'Duration pattern not find in content' unless m
58
58
 
59
59
  self.class.time_to_seconds(m[1])
@@ -11,8 +11,9 @@ module Ehbrs
11
11
  end
12
12
 
13
13
  def to_s
14
- "[#{codec_type}(#{index}): #{codec_name}/#{language || '-'}" +
15
- extra.if_present('') { |v| " | #{v}" } + ']'
14
+ "[#{codec_type}(#{index}): #{codec_name}/#{language || '-'}#{extra.if_present('') do |v|
15
+ " | #{v}"
16
+ end}]"
16
17
  end
17
18
  end
18
19
  end
@@ -52,19 +52,17 @@ module Ehbrs
52
52
  end
53
53
 
54
54
  def fixes_uncached
55
- checks.reject(&:passed?).map { |c| c.check.fix }.reject(&:blank?)
55
+ checks.reject(&:passed?).map { |c| c.check.fix }.compact_blank
56
56
  end
57
57
 
58
- def pad_speaker
59
- ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' ')) do
60
- yield
61
- end
58
+ def pad_speaker(&block)
59
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' '), &block)
62
60
  end
63
61
 
64
62
  def new_padded_cli_speaker
65
63
  ::EacCli::Speaker.new(
66
- err_line_prefix(::EacRubyUtils::Speaker.context.optional_current
67
- .if_present('') { |v| v.is_a?(::EacCli::Speaker) ? v.err_line_prefix : '' } + ' ')
64
+ err_line_prefix("#{::EacRubyUtils::Speaker.context.optional_current
65
+ .if_present('') { |v| v.is_a?(::EacCli::Speaker) ? v.err_line_prefix : '' }} ")
68
66
  )
69
67
  end
70
68
  end
@@ -23,6 +23,7 @@ module Ehbrs
23
23
  MPEG4_EXTRA_UNSUPPORTED = %w[dx50 xvid].freeze
24
24
 
25
25
  def initialize
26
+ super()
26
27
  add_check('invalid_extension', '.m4v')
27
28
  end
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.0
4
+ version: 0.39.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: 2023-10-28 00:00:00.000000000 Z
11
+ date: 2023-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-tools
@@ -16,62 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.156'
19
+ version: '0.159'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.156'
26
+ version: '0.159'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_cli
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.38'
33
+ version: '0.40'
34
34
  type: :runtime
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: '0.38'
40
+ version: '0.40'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_utils
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.119'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 0.119.2
47
+ version: '0.120'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '0.119'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 0.119.2
54
+ version: '0.120'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: ehbrs_ruby_utils
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '0.35'
61
+ version: '0.38'
68
62
  type: :runtime
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '0.35'
68
+ version: '0.38'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: filesize
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,20 +80,6 @@ dependencies:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
82
  version: '0.2'
89
- - !ruby/object:Gem::Dependency
90
- name: inifile
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '3.0'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '3.0'
103
83
  - !ruby/object:Gem::Dependency
104
84
  name: os
105
85
  requirement: !ruby/object:Gem::Requirement
@@ -140,14 +120,14 @@ dependencies:
140
120
  requirements:
141
121
  - - "~>"
142
122
  - !ruby/object:Gem::Version
143
- version: 0.5.1
123
+ version: '0.9'
144
124
  type: :development
145
125
  prerelease: false
146
126
  version_requirements: !ruby/object:Gem::Requirement
147
127
  requirements:
148
128
  - - "~>"
149
129
  - !ruby/object:Gem::Version
150
- version: 0.5.1
130
+ version: '0.9'
151
131
  description:
152
132
  email:
153
133
  executables:
@@ -156,14 +136,11 @@ extensions: []
156
136
  extra_rdoc_files: []
157
137
  files:
158
138
  - ".avm.yml"
159
- - ".rspec"
160
- - ".rubocop.yml"
161
139
  - Gemfile
162
140
  - Gemfile.lock
163
141
  - exe/ehbrs
164
142
  - lib/ehbrs.rb
165
143
  - lib/ehbrs/executables.rb
166
- - lib/ehbrs/gems.rb
167
144
  - lib/ehbrs/google.rb
168
145
  - lib/ehbrs/google/translate.rb
169
146
  - lib/ehbrs/google/translate/session.rb
@@ -199,6 +176,8 @@ files:
199
176
  - lib/ehbrs/tools/runner/telegram/send_message.rb
200
177
  - lib/ehbrs/tools/runner/vg.rb
201
178
  - lib/ehbrs/tools/runner/vg/ips.rb
179
+ - lib/ehbrs/tools/runner/vg/ps2.rb
180
+ - lib/ehbrs/tools/runner/vg/ps2/rename.rb
202
181
  - lib/ehbrs/tools/runner/vg/wii.rb
203
182
  - lib/ehbrs/tools/runner/videos.rb
204
183
  - lib/ehbrs/tools/runner/videos/extract.rb
@@ -211,6 +190,8 @@ files:
211
190
  - lib/ehbrs/tools/runner/videos/probe.rb
212
191
  - lib/ehbrs/tools/runner/videos/series.rb
213
192
  - lib/ehbrs/tools/runner/videos/series/rename.rb
193
+ - lib/ehbrs/tools/runner/videos/subtitles.rb
194
+ - lib/ehbrs/tools/runner/videos/subtitles/sanitize.rb
214
195
  - lib/ehbrs/tools/runner/videos/unsupported.rb
215
196
  - lib/ehbrs/tools/runner/web_utils.rb
216
197
  - lib/ehbrs/tools/runner/web_utils/finances.rb
@@ -219,6 +200,8 @@ files:
219
200
  - lib/ehbrs/tools/runner/web_utils/videos.rb
220
201
  - lib/ehbrs/tools/runner/web_utils/videos/download.rb
221
202
  - lib/ehbrs/tools/runner/web_utils/videos/upload.rb
203
+ - lib/ehbrs/tools/runner_with.rb
204
+ - lib/ehbrs/tools/runner_with/filesystem_renamer.rb
222
205
  - lib/ehbrs/tools/version.rb
223
206
  - lib/ehbrs/user_dirs.rb
224
207
  - lib/ehbrs/videos.rb
@@ -251,22 +234,6 @@ files:
251
234
  - lib/ehbrs/videos/unsupported/profiles/samsung.rb
252
235
  - lib/ehbrs/videos/unsupported/search.rb
253
236
  - lib/ehbrs/videos/unsupported/track.rb
254
- - spec/code/rubocop_spec.rb
255
- - spec/lib/ehbrs/observers/base_spec.rb
256
- - spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb
257
- - spec/lib/ehbrs/tools/runner/vg/ips_spec.rb
258
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/expected.rom
259
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_0.ips
260
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_1.ips
261
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/source.rom
262
- - spec/lib/ehbrs/tools/runner/videos/probe_spec.rb
263
- - spec/lib/ehbrs/tools/runner/videos/probe_spec_files/fixed.target.yaml
264
- - spec/lib/ehbrs/tools/runner/videos/unsupported_spec.rb
265
- - spec/lib/ehbrs/tools/runner/videos/unsupported_spec_files/dts_audio.probe.yaml
266
- - spec/lib/ehbrs/tools/runner_spec.rb
267
- - spec/spec_helper.rb
268
- - spec/spec_helper/videos.rb
269
- - spec/spec_helper/videos_files/stub_source.mp4
270
237
  - template/ehbrs/cooking_book/build/base_page/layout.html.erb
271
238
  - template/ehbrs/cooking_book/build/index_page/inner.html.erb
272
239
  - template/ehbrs/cooking_book/build/recipe_page/inner.html.erb
@@ -282,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
249
  requirements:
283
250
  - - ">="
284
251
  - !ruby/object:Gem::Version
285
- version: '0'
252
+ version: 2.7.0
286
253
  required_rubygems_version: !ruby/object:Gem::Requirement
287
254
  requirements:
288
255
  - - ">="
@@ -293,22 +260,4 @@ rubygems_version: 3.1.6
293
260
  signing_key:
294
261
  specification_version: 4
295
262
  summary: Tools for EHB/RS.
296
- test_files:
297
- - spec/spec_helper/videos_files/stub_source.mp4
298
- - spec/spec_helper/videos.rb
299
- - spec/lib/ehbrs/observers/base_spec.rb
300
- - spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb
301
- - spec/lib/ehbrs/tools/runner/videos/unsupported_spec.rb
302
- - spec/lib/ehbrs/tools/runner/videos/probe_spec.rb
303
- - spec/lib/ehbrs/tools/runner/videos/probe_spec_files/fixed.target.yaml
304
- - spec/lib/ehbrs/tools/runner/videos/unsupported_spec_files/dts_audio.probe.yaml
305
- - spec/lib/ehbrs/tools/runner/vg/ips_spec.rb
306
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/expected.rom
307
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/source.rom
308
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_1.ips
309
- - spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_0.ips
310
- - spec/lib/ehbrs/tools/runner_spec.rb
311
- - spec/spec_helper.rb
312
- - spec/code/rubocop_spec.rb
313
- - ".rubocop.yml"
314
- - ".rspec"
263
+ test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --require spec/spec_helper --color --format doc --default-path . --pattern 'spec/**/*_spec.rb'
data/.rubocop.yml DELETED
@@ -1,39 +0,0 @@
1
- require:
2
- - rubocop-rails
3
- - rubocop-rspec
4
-
5
- AllCops:
6
- Exclude:
7
- - sub/**/*
8
-
9
- Layout/LineLength:
10
- Max: 100
11
-
12
- Metrics/BlockLength:
13
- Exclude:
14
- - spec/**/*_spec.rb
15
-
16
- Rails/Output:
17
- Enabled: false
18
-
19
- Rails/TimeZone:
20
- Enabled: false
21
-
22
- RSpec/NestedGroups:
23
- Exclude:
24
- - spec/**/*_spec.rb
25
-
26
- Style/AsciiComments:
27
- Enabled: false
28
-
29
- Style/Documentation:
30
- Enabled: false
31
-
32
- Style/HashEachMethods:
33
- Enabled: true
34
-
35
- Style/HashTransformKeys:
36
- Enabled: true
37
-
38
- Style/HashTransformValues:
39
- Enabled: true
data/lib/ehbrs/gems.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_ruby_base1/sources/base'
4
-
5
- module Ehbrs
6
- module Gems
7
- class << self
8
- enable_simple_cache
9
-
10
- def app_path
11
- ::Pathname.new('../..').expand_path(__dir__)
12
- end
13
-
14
- def vendor_gems_root
15
- app_path.join('vendor')
16
- end
17
-
18
- private
19
-
20
- def app_uncached
21
- ::Avm::EacRubyBase1::Sources::Base.new(app_path)
22
- end
23
-
24
- def all_uncached
25
- vendor_gems + [app]
26
- end
27
-
28
- def vendor_gems_uncached
29
- r = []
30
- vendor_gems_root.each_child.each do |child|
31
- r << ::EacRubyGemsUtils::Gem.new(child) if child.directory?
32
- end
33
- r
34
- end
35
- end
36
- end
37
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/observers/base'
4
-
5
- RSpec.describe ::Ehbrs::Observers::Base do
6
- let(:instance) { described_class.new }
7
- let(:first_value) { 'a value' }
8
- let(:same_value) { first_value.dup }
9
- let(:different_value) { 'another value' }
10
- let(:first_time) { ::Time.required_zone.local(2020, 5, 1, 12, 45, 0) }
11
- let(:second_time) { ::Time.required_zone.local(2020, 5, 1, 12, 45, 0) }
12
-
13
- it { expect(instance.records.count).to be_zero }
14
- it { expect(instance.last_change_time).to be_blank }
15
- it { expect(instance.last_check_time).to be_blank }
16
-
17
- it { expect(instance).to be_changing_value(nil) }
18
- it { expect(instance).to be_changing_value(first_value) }
19
- it { expect(instance).to be_changing_value(same_value) }
20
- it { expect(instance).to be_changing_value(different_value) }
21
-
22
- context 'when firstly checked' do
23
- before { instance.check(first_value, first_time) }
24
-
25
- it { expect(instance.records.count).to eq(1) }
26
- it { expect(instance.last_value).to eq(first_value) }
27
- it { expect(instance).not_to be_changing_value(same_value) }
28
- it { expect(instance).to be_changing_value(different_value) }
29
- it { expect(instance.last_change_time).to eq(first_time) }
30
- it { expect(instance.last_check_time).to eq(first_time) }
31
-
32
- context 'when same first_value is checked' do
33
- before { instance.check(same_value, second_time) }
34
-
35
- it { expect(instance.records.count).to eq(1) }
36
- it { expect(instance.last_value).to eq(same_value) }
37
- it { expect(instance.last_change_time).to eq(first_time) }
38
- it { expect(instance.last_check_time).to eq(second_time) }
39
- end
40
-
41
- context 'when different first_value is checked' do
42
- before { instance.check(different_value, second_time) }
43
-
44
- it { expect(instance.records.count).to eq(2) }
45
- it { expect(instance.last_value).to eq(different_value) }
46
- it { expect(instance.last_change_time).to eq(second_time) }
47
- it { expect(instance.last_check_time).to eq(second_time) }
48
- end
49
-
50
- context 'when checked first_value is blank' do
51
- context 'when blank_value == :add' do
52
- let(:instance) { described_class.new(blank_value: :add) }
53
-
54
- before { instance.check(nil, second_time) }
55
-
56
- it { expect(instance.records.count).to eq(2) }
57
- it { expect(instance.last_value).to eq(nil) }
58
- it { expect(instance.last_change_time).to eq(second_time) }
59
- it { expect(instance.last_check_time).to eq(second_time) }
60
- end
61
-
62
- context 'when blank_value == :ignore' do
63
- let(:instance) { described_class.new(blank_value: :ignore) }
64
-
65
- before { instance.check(nil, second_time) }
66
-
67
- it { expect(instance.records.count).to eq(1) }
68
- it { expect(instance.last_value).to eq(first_value) }
69
- it { expect(instance.last_change_time).to eq(first_time) }
70
- it { expect(instance.last_check_time).to eq(second_time) }
71
- end
72
-
73
- context 'when blank_value == :raise' do
74
- let(:instance) { described_class.new(blank_value: :raise) }
75
-
76
- before do
77
- @exception = nil
78
- begin
79
- instance.check(nil, second_time)
80
- rescue StandardError => e
81
- @exception = e
82
- end
83
- end
84
-
85
- it { expect(@exception).to be_a(::ArgumentError) } # rubocop:disable RSpec/InstanceVariable
86
- it { expect(instance.records.count).to eq(1) }
87
- it { expect(instance.last_value).to eq(first_value) }
88
- it { expect(instance.last_change_time).to eq(first_time) }
89
- it { expect(instance.last_check_time).to eq(second_time) }
90
- end
91
- end
92
- end
93
- end