ehbrs-tools 0.6.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/lib/ehbrs/executables.rb +7 -1
- data/lib/ehbrs/fs.rb +9 -0
- data/lib/ehbrs/fs/compressed_package.rb +48 -0
- data/lib/ehbrs/gems.rb +37 -0
- data/lib/ehbrs/google.rb +9 -0
- data/lib/ehbrs/google/translate.rb +11 -0
- data/lib/ehbrs/google/translate/session.rb +61 -0
- data/lib/ehbrs/observers.rb +11 -0
- data/lib/ehbrs/observers/base.rb +64 -0
- data/lib/ehbrs/observers/with_persistence.rb +34 -0
- data/lib/ehbrs/runner/fs.rb +19 -0
- data/lib/ehbrs/runner/fs/used_space.rb +161 -0
- data/lib/ehbrs/runner/google.rb +19 -0
- data/lib/ehbrs/runner/google/translate.rb +92 -0
- data/lib/ehbrs/runner/self.rb +19 -0
- data/lib/ehbrs/runner/self/test.rb +30 -0
- data/lib/ehbrs/runner/videos/extract.rb +71 -0
- data/lib/ehbrs/runner/videos/series.rb +21 -0
- data/lib/ehbrs/runner/videos/series/rename.rb +75 -0
- data/lib/ehbrs/self.rb +9 -0
- data/lib/ehbrs/self/observers/used_space.rb +22 -0
- data/lib/ehbrs/self/observers/with_persistence.rb +38 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/user_dirs.rb +34 -0
- data/lib/ehbrs/vg/wii/game_file.rb +13 -0
- data/lib/ehbrs/videos/extract.rb +11 -0
- data/lib/ehbrs/videos/extract/package.rb +75 -0
- data/lib/ehbrs/videos/extract/package_file.rb +54 -0
- data/lib/ehbrs/videos/series.rb +11 -0
- data/lib/ehbrs/videos/series/rename.rb +13 -0
- data/lib/ehbrs/videos/series/rename/directory_group.rb +28 -0
- data/lib/ehbrs/videos/series/rename/file.rb +114 -0
- data/lib/ehbrs/videos/series/rename/file/basename_parser.rb +44 -0
- data/lib/ehbrs/videos/series/rename/file/options.rb +30 -0
- data/lib/ehbrs/videos/series/rename/line_result.rb +26 -0
- data/lib/ehbrs/videos/series/rename/line_result_group.rb +39 -0
- data/lib/ehbrs/videos/series/rename/results_builder.rb +32 -0
- data/lib/ehbrs/videos/series/rename/season_group.rb +39 -0
- data/vendor/aranha-selenium/Gemfile +5 -0
- data/vendor/aranha-selenium/aranha-selenium.gemspec +19 -0
- data/vendor/aranha-selenium/lib/aranha/selenium.rb +8 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb +47 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/base.rb +76 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/chrome.rb +28 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox.rb +54 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox_auto_download_mime_types +685 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/session.rb +78 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/version.rb +7 -0
- data/vendor/aranha-selenium/spec/rubocop_check_spec.rb +7 -0
- data/vendor/aranha-selenium/spec/spec_helper.rb +100 -0
- data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +68 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb +4 -12
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb +27 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb +34 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +10 -12
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb +45 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +5 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +25 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +1 -3
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +45 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +85 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +42 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +1 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/docopt_runner_spec.rb +5 -5
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/speaker_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +4 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/temp_spec.rb +12 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/{temp.rb → temp_spec.rb} +22 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +32 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb +39 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +4 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +19 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_module_a.rb +6 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_not_module.rb +6 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +75 -0
- data/vendor/eac_ruby_utils/spec/locales/pt-BR.yml +17 -0
- metadata +105 -3
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
9
|
+
class Google < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
require_sub __FILE__
|
11
|
+
include ::EacCli::DefaultRunner
|
12
|
+
|
13
|
+
runner_definition do
|
14
|
+
desc 'Utilidades Google.'
|
15
|
+
subcommands
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
require 'ehbrs/google/translate/session'
|
7
|
+
|
8
|
+
module Ehbrs
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Google < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class Translate < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
include ::EacCli::DefaultRunner
|
13
|
+
|
14
|
+
runner_definition do
|
15
|
+
desc 'Traduz um documento com Google Translate.'
|
16
|
+
arg_opt '-o', '--output-file', 'Salva saída em <output-file>.'
|
17
|
+
bool_opt '-w', '--overwrite', 'Permite sobreescrever arquivo de saída.'
|
18
|
+
pos_arg 'source-file'
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
start_banner
|
23
|
+
validate
|
24
|
+
if output_to_stdout?
|
25
|
+
out(translated_content)
|
26
|
+
else
|
27
|
+
::File.write(output_file, translated_content)
|
28
|
+
end
|
29
|
+
success 'Concluído'
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_banner
|
33
|
+
infov 'Source file', source_file
|
34
|
+
infov 'Target file', output_file
|
35
|
+
end
|
36
|
+
|
37
|
+
def translated_content_uncached
|
38
|
+
session.translate(source_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_file
|
42
|
+
options.fetch('<source-file>')
|
43
|
+
end
|
44
|
+
|
45
|
+
def output_file
|
46
|
+
options.fetch('--output-file') || default_output_file
|
47
|
+
end
|
48
|
+
|
49
|
+
def default_output_file
|
50
|
+
::File.join(
|
51
|
+
::File.dirname(source_file),
|
52
|
+
::File.basename(source_file, '.*') + '_translated.html'
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def session_uncached
|
57
|
+
::Ehbrs::Google::Translate::Session.new
|
58
|
+
end
|
59
|
+
|
60
|
+
def validate
|
61
|
+
validate_source_file
|
62
|
+
validate_output_file
|
63
|
+
validate_output_content
|
64
|
+
end
|
65
|
+
|
66
|
+
def validate_source_file
|
67
|
+
return if ::File.exist?(source_file)
|
68
|
+
|
69
|
+
fatal_error "Source file \"#{source_file}\" does not exist"
|
70
|
+
end
|
71
|
+
|
72
|
+
def validate_output_file
|
73
|
+
return if output_to_stdout?
|
74
|
+
return unless ::File.exist?(output_file)
|
75
|
+
return if options.fetch('--overwrite')
|
76
|
+
|
77
|
+
fatal_error "Output file \"#{output_file}\" already exists"
|
78
|
+
end
|
79
|
+
|
80
|
+
def validate_output_content
|
81
|
+
return if translated_content.present?
|
82
|
+
|
83
|
+
fatal_error 'Output content is empty'
|
84
|
+
end
|
85
|
+
|
86
|
+
def output_to_stdout?
|
87
|
+
output_file == '-'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
9
|
+
class Self < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
require_sub __FILE__
|
11
|
+
include ::EacCli::DefaultRunner
|
12
|
+
|
13
|
+
runner_definition do
|
14
|
+
desc 'Self utilities'
|
15
|
+
subcommands
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'ehbrs/gems'
|
5
|
+
require 'eac_ruby_gems_utils/tests/multiple'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
8
|
+
|
9
|
+
module Ehbrs
|
10
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class Self < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Test < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
require_sub __FILE__
|
14
|
+
include ::EacCli::DefaultRunner
|
15
|
+
|
16
|
+
runner_definition do
|
17
|
+
desc 'Test core and local gems.'
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
fatal_error 'Some test did not pass' unless tests.ok?
|
22
|
+
end
|
23
|
+
|
24
|
+
def tests_uncached
|
25
|
+
::EacRubyGemsUtils::Tests::Multiple.new(::Ehbrs::Gems.all)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
require 'ehbrs/videos/extract/package'
|
7
|
+
|
8
|
+
module Ehbrs
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Videos < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class Extract < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
include ::EacCli::DefaultRunner
|
13
|
+
require_sub __FILE__
|
14
|
+
|
15
|
+
DEFAULT_QUALITIES = %w[1080 720 web webrip hdtv].freeze
|
16
|
+
|
17
|
+
runner_definition do
|
18
|
+
desc 'Extrai arquivos de seriados.'
|
19
|
+
arg_opt '-d', '--dir', 'Extraí para diretório.'
|
20
|
+
bool_opt '-D', '--delete', 'Remove o pacote após o processamento.'
|
21
|
+
arg_opt '-q', '--qualities', 'Lista de qualidades.'
|
22
|
+
pos_arg 'packages', repeat: true
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
start_banner
|
27
|
+
packages.each do |package|
|
28
|
+
infov 'Package', package
|
29
|
+
package.run(options.fetch('--delete'))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def packages_uncached
|
36
|
+
options.fetch('<packages>').map do |p|
|
37
|
+
::Ehbrs::Videos::Extract::Package.new(p, target_dir, qualities)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def qualities_uncached
|
42
|
+
(options.fetch('--qualities').to_s.split(',') + DEFAULT_QUALITIES).uniq
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_banner
|
46
|
+
infov 'Packages', packages.count
|
47
|
+
infov 'Qualities', qualities
|
48
|
+
infov 'Target directory', target_dir
|
49
|
+
end
|
50
|
+
|
51
|
+
def target_dir_uncached
|
52
|
+
options.fetch('--dir').if_present(&:to_pathname) || default_target_dir
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_target_dir
|
56
|
+
r = options.fetch('<packages>').first.to_pathname.basename('.*')
|
57
|
+
return r unless r.exist?
|
58
|
+
|
59
|
+
r = r.basename_sub { |b| "#{b}_extract" }
|
60
|
+
index = 0
|
61
|
+
loop do
|
62
|
+
return r unless r.exist?
|
63
|
+
|
64
|
+
index += 1
|
65
|
+
r = r.basename_sub { |b| "#{b}_#{index}" }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Ehbrs
|
8
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
9
|
+
class Videos < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Series < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
include ::EacCli::DefaultRunner
|
12
|
+
require_sub __FILE__
|
13
|
+
|
14
|
+
runner_definition do
|
15
|
+
desc 'Ferramentas para seriados.'
|
16
|
+
subcommands
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/default_runner'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
require 'ehbrs/videos/series/rename/file'
|
7
|
+
require 'ehbrs/videos/series/rename/file/options'
|
8
|
+
require 'ehbrs/videos/series/rename/results_builder'
|
9
|
+
|
10
|
+
module Ehbrs
|
11
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Videos < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
class Series < ::EacRubyUtils::Console::DocoptRunner
|
14
|
+
class Rename < ::EacRubyUtils::Console::DocoptRunner
|
15
|
+
include ::EacCli::DefaultRunner
|
16
|
+
include ::EacRubyUtils::Fs::Traversable
|
17
|
+
|
18
|
+
runner_definition do
|
19
|
+
desc 'Renomeia arquivos de séries.'
|
20
|
+
bool_opt '-r', '--recursive', 'Recursivo.'
|
21
|
+
bool_opt '-c', '--confirm', 'Confirmação a renomeação.'
|
22
|
+
arg_opt '-k', '--kernel', 'Determina o kernel para os nomes dos arquivos.'
|
23
|
+
arg_opt '-E', '--extension', 'Substitui a extensão dos arquivos.'
|
24
|
+
arg_opt '-e', '--episode-increment', 'Aumenta o número do episódio.'
|
25
|
+
pos_arg 'paths', repeat: true, optional: true
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
banner
|
30
|
+
show_results
|
31
|
+
rename_files
|
32
|
+
end
|
33
|
+
|
34
|
+
def banner
|
35
|
+
infov 'Paths', paths.count
|
36
|
+
infov 'Files found', files.count
|
37
|
+
end
|
38
|
+
|
39
|
+
def files_uncached
|
40
|
+
@files = []
|
41
|
+
paths.each { |path| traverser_check_path(path) }
|
42
|
+
@files
|
43
|
+
end
|
44
|
+
|
45
|
+
def paths
|
46
|
+
options.fetch('<paths>').if_present(['.'])
|
47
|
+
end
|
48
|
+
|
49
|
+
def traverser_recursive
|
50
|
+
options.fetch('--recursive')
|
51
|
+
end
|
52
|
+
|
53
|
+
def traverser_check_file(path)
|
54
|
+
@files << ::Ehbrs::Videos::Series::Rename::File.new(path, series_file_options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def series_file_options_uncached
|
58
|
+
::Ehbrs::Videos::Series::Rename::File::Options.new(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def show_results
|
62
|
+
::Ehbrs::Videos::Series::Rename::ResultsBuilder.new(files).show(0)
|
63
|
+
end
|
64
|
+
|
65
|
+
def rename_files
|
66
|
+
return unless series_file_options.confirm
|
67
|
+
|
68
|
+
infom 'Renaming files...'
|
69
|
+
files.each(&:rename)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/ehbrs/self.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ehbrs/self/observers/with_persistence'
|
4
|
+
|
5
|
+
module Ehbrs
|
6
|
+
module Self
|
7
|
+
module Observers
|
8
|
+
class UsedSpace < ::Ehbrs::Self::Observers::WithPersistence
|
9
|
+
def path
|
10
|
+
label
|
11
|
+
end
|
12
|
+
|
13
|
+
def calculate_value
|
14
|
+
env = ::EacRubyUtils::Envs.local
|
15
|
+
env.command('du', '-sb', path.to_s).pipe(
|
16
|
+
env.command('cut', '-f', '-1')
|
17
|
+
).execute!.strip.to_i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ehbrs/observers/with_persistence'
|
4
|
+
require 'ehbrs/user_dirs'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module Self
|
8
|
+
module Observers
|
9
|
+
class WithPersistence
|
10
|
+
enable_simple_cache
|
11
|
+
common_constructor :label
|
12
|
+
|
13
|
+
def check_current_value
|
14
|
+
observer.check(current_value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def changing_value?
|
18
|
+
observer.changing_value?(current_value)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def current_value_uncached
|
24
|
+
calculate_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def observer_uncached
|
28
|
+
::Ehbrs::Observers::WithPersistence.new(persistence_path, blank_value: :raise)
|
29
|
+
end
|
30
|
+
|
31
|
+
def persistence_path_uncached
|
32
|
+
::Ehbrs::UserDirs.data.child('observers', label.to_s.parameterize)
|
33
|
+
.content_path.to_pathname
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/ehbrs/tools/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/filesystem_cache'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
|
6
|
+
module Ehbrs
|
7
|
+
module UserDirs
|
8
|
+
class << self
|
9
|
+
include ::EacRubyUtils::SimpleCache
|
10
|
+
|
11
|
+
def application_id
|
12
|
+
'ehbrs-tools'
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def user_home_dir_uncached
|
18
|
+
::EacRubyUtils::FilesystemCache.new(ENV['HOME'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def cache_uncached
|
22
|
+
user_home_dir.child('.cache', application_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def config_uncached
|
26
|
+
user_home_dir.child('.config', application_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def data_uncached
|
30
|
+
user_home_dir.child('.local', 'share', application_id)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|