ehbrs-tools 0.16.5 → 0.21.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/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +31 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/music.rb +9 -0
- data/lib/ehbrs/music/album.rb +42 -0
- data/lib/ehbrs/observers/base.rb +1 -1
- data/lib/ehbrs/observers/with_persistence.rb +1 -1
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +50 -0
- data/lib/ehbrs/runner/fs/used_space.rb +1 -1
- data/lib/ehbrs/runner/music.rb +16 -0
- data/lib/ehbrs/runner/music/selected.rb +63 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/runner/videos/probe.rb +2 -2
- data/lib/ehbrs/runner/videos/unsupported.rb +1 -1
- data/lib/ehbrs/runner/web_utils/videos/upload.rb +1 -1
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/convert_job.rb +1 -1
- data/lib/ehbrs/videos/series/rename/line_result.rb +1 -1
- data/lib/ehbrs/videos/unsupported/check_support.rb +3 -2
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +1 -1
- data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
- data/lib/ehbrs/videos/unsupported/search.rb +1 -1
- data/lib/ehbrs/videos/unsupported/track.rb +1 -1
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/base.rb +8 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/chrome.rb +10 -5
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox.rb +25 -11
- data/vendor/aranha-selenium/lib/aranha/selenium/version.rb +1 -1
- data/vendor/eac_cli/eac_cli.gemspec +5 -2
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
- data/vendor/eac_cli/lib/eac_cli/default_runner.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +4 -7
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -10
- data/vendor/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb +47 -0
- data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +2 -2
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +12 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -2
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +3 -3
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +7 -2
- data/vendor/eac_cli/lib/eac_cli/docopt_runner.rb +43 -0
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_class_methods.rb +16 -0
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_doc.rb +23 -0
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_settings.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_subcommands.rb +152 -0
- data/vendor/eac_cli/lib/eac_cli/old_configs.rb +36 -0
- data/vendor/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +80 -0
- data/vendor/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb +16 -0
- data/vendor/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +44 -0
- data/vendor/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +25 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +47 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +3 -17
- data/vendor/eac_cli/lib/eac_cli/patches/module.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/module/speaker.rb +10 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +3 -2
- data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -48
- data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +38 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -3
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands/definition_concern.rb +10 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/speaker.rb +131 -0
- data/vendor/eac_cli/lib/eac_cli/speaker/_class_methods.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/speaker/_constants.rb +12 -0
- data/vendor/eac_cli/lib/eac_cli/speaker/list.rb +61 -0
- data/vendor/eac_cli/lib/eac_cli/speaker/node.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +4 -0
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +1 -1
- data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/console → eac_cli/spec/lib/eac_cli}/docopt_runner_spec.rb +5 -5
- data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/console/configs_spec.rb → eac_cli/spec/lib/eac_cli/old_configs_spec.rb} +2 -2
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +44 -5
- data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/console → eac_cli/spec/lib/eac_cli}/speaker_spec.rb +2 -2
- data/vendor/eac_cli/spec/lib/module/speaker_spec.rb +13 -0
- data/vendor/eac_cli/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_cli/spec/spec_helper.rb +3 -0
- data/vendor/eac_docker/eac_docker.gemspec +3 -2
- data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +1 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +2 -1
- data/vendor/eac_docker/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_docker/spec/spec_helper.rb +3 -0
- data/vendor/eac_ruby_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +52 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +36 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +36 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +42 -0
- data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +3 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +103 -0
- data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +2 -3
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +10 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb +6 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +13 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +48 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +0 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb +1 -4
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +18 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +9 -0
- data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -5
- data/vendor/eac_ruby_utils/spec/spec_helper.rb +3 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +1 -1
- metadata +134 -62
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb +0 -74
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +0 -43
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +0 -47
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console.rb +0 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +0 -38
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +0 -81
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +0 -18
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +0 -46
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +0 -27
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +0 -45
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +0 -18
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_doc.rb +0 -25
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_settings.rb +0 -19
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +0 -145
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker.rb +0 -133
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/_class_methods.rb +0 -39
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/_constants.rb +0 -14
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/list.rb +0 -63
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/node.rb +0 -26
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/console_speaker.rb +0 -10
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +0 -16
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +0 -56
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +0 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +0 -67
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +0 -39
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates.rb +0 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +0 -110
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +0 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/searcher.rb +0 -55
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +0 -7
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +0 -25
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +0 -23
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +0 -25
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +0 -25
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +0 -29
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +0 -46
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/console_speaker_spec.rb +0 -13
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec.rb +0 -23
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +0 -88
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +0 -35
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec_files/expected_content +0 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec_files/source.template +0 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec.rb +0 -30
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path1/subdir1/file1.template +0 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path1/subdir1/file2 +0 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path2/subdir1/file3.template +0 -1
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_dependency 'activesupport', '>= 4.0'
|
19
19
|
s.add_dependency 'addressable', '~> 2.6'
|
20
|
-
s.add_dependency '
|
21
|
-
s.add_dependency 'docopt', '~> 0.6.1'
|
20
|
+
s.add_dependency 'filesize'
|
22
21
|
s.add_dependency 'net-ssh', '~> 4.2'
|
23
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
22
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
|
24
23
|
end
|
@@ -17,15 +17,25 @@ module EacRubyUtils
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
setup = self
|
21
20
|
a_module.extend(::ActiveSupport::Concern)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
include_or_prepend(:included, :include)
|
22
|
+
include_or_prepend(:prepended, :prepend)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def include_or_prepend(module_method, class_setup_method)
|
28
|
+
setup = self
|
29
|
+
a_module.send(module_method, *a_module_method_args(module_method)) do
|
30
|
+
::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
|
27
31
|
end
|
28
32
|
end
|
33
|
+
|
34
|
+
def a_module_method_args(module_method)
|
35
|
+
method_arity = a_module.method(module_method).arity
|
36
|
+
method_arity = -method_arity - 1 if method_arity.negative?
|
37
|
+
method_arity.times.map { |_n| a_module }
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'active_support/callbacks'
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_initialize'
|
5
6
|
require 'ostruct'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
@@ -76,111 +77,13 @@ module EacRubyUtils
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def setup_class_initialize(klass)
|
79
|
-
common_constructor = self
|
80
80
|
klass.include(::ActiveSupport::Callbacks)
|
81
81
|
klass.define_callbacks :initialize
|
82
|
-
|
83
|
-
Initialize.new(common_constructor, args, self).run
|
84
|
-
super(*SuperArgs.new(common_constructor, args, self).result)
|
85
|
-
end
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
86
83
|
end
|
87
84
|
|
88
85
|
def super_args
|
89
86
|
options[:super_args]
|
90
87
|
end
|
91
|
-
|
92
|
-
class Initialize
|
93
|
-
attr_reader :common_constructor, :args, :object
|
94
|
-
|
95
|
-
def initialize(common_constructor, args, object)
|
96
|
-
@common_constructor = common_constructor
|
97
|
-
@args = args
|
98
|
-
@object = object
|
99
|
-
end
|
100
|
-
|
101
|
-
def run
|
102
|
-
validate_args_count
|
103
|
-
object.run_callbacks :initialize do
|
104
|
-
object_attributes_set
|
105
|
-
object_after_callback
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def arg_value(arg_name)
|
112
|
-
arg_index = common_constructor.args.index(arg_name)
|
113
|
-
if arg_index < args.count
|
114
|
-
args[arg_index]
|
115
|
-
else
|
116
|
-
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def object_after_callback
|
121
|
-
return unless common_constructor.after_set_block
|
122
|
-
|
123
|
-
object.instance_eval(&common_constructor.after_set_block)
|
124
|
-
end
|
125
|
-
|
126
|
-
def object_attributes_set
|
127
|
-
common_constructor.args.each do |arg_name|
|
128
|
-
object.send("#{arg_name}=", arg_value(arg_name))
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def validate_args_count
|
133
|
-
return if common_constructor.args_count.include?(args.count)
|
134
|
-
|
135
|
-
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
136
|
-
" (given #{args.count}, expected #{common_constructor.args_count})"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class SuperArgs
|
141
|
-
attr_reader :common_constructor, :args, :object
|
142
|
-
|
143
|
-
def initialize(common_constructor, args, object)
|
144
|
-
@common_constructor = common_constructor
|
145
|
-
@args = args
|
146
|
-
@object = object
|
147
|
-
end
|
148
|
-
|
149
|
-
def auto_result
|
150
|
-
r = []
|
151
|
-
sub_args.each do |name, value|
|
152
|
-
i = super_arg_index(name)
|
153
|
-
r[i] = value if i
|
154
|
-
end
|
155
|
-
r
|
156
|
-
end
|
157
|
-
|
158
|
-
def result
|
159
|
-
result_from_options || auto_result
|
160
|
-
end
|
161
|
-
|
162
|
-
def result_from_options
|
163
|
-
return unless common_constructor.super_args
|
164
|
-
|
165
|
-
object.instance_exec(&common_constructor.super_args)
|
166
|
-
end
|
167
|
-
|
168
|
-
def sub_args
|
169
|
-
common_constructor.args.each_with_index.map do |name, index|
|
170
|
-
[name, args[index]]
|
171
|
-
end.to_h
|
172
|
-
end
|
173
|
-
|
174
|
-
def super_arg_index(name)
|
175
|
-
super_method.parameters.each_with_index do |arg, index|
|
176
|
-
return index if arg[1] == name
|
177
|
-
end
|
178
|
-
nil
|
179
|
-
end
|
180
|
-
|
181
|
-
def super_method
|
182
|
-
object.class.superclass ? object.class.superclass.instance_method(:initialize) : nil
|
183
|
-
end
|
184
|
-
end
|
185
88
|
end
|
186
89
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassInitialize
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
class_initialize = self
|
18
|
+
klass.send(:define_method, :initialize) do |*args|
|
19
|
+
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
20
|
+
class_initialize.common_constructor, args, self
|
21
|
+
).run
|
22
|
+
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
23
|
+
class_initialize, args, self
|
24
|
+
).result)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class CommonConstructor
|
5
|
+
class InstanceInitialize
|
6
|
+
attr_reader :common_constructor, :args, :object
|
7
|
+
|
8
|
+
def initialize(common_constructor, args, object)
|
9
|
+
@common_constructor = common_constructor
|
10
|
+
@args = args
|
11
|
+
@object = object
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
validate_args_count
|
16
|
+
object.run_callbacks :initialize do
|
17
|
+
object_attributes_set
|
18
|
+
object_after_callback
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def arg_value(arg_name)
|
25
|
+
arg_index = common_constructor.args.index(arg_name)
|
26
|
+
if arg_index < args.count
|
27
|
+
args[arg_index]
|
28
|
+
else
|
29
|
+
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def object_after_callback
|
34
|
+
return unless common_constructor.after_set_block
|
35
|
+
|
36
|
+
object.instance_eval(&common_constructor.after_set_block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def object_attributes_set
|
40
|
+
common_constructor.args.each do |arg_name|
|
41
|
+
object.send("#{arg_name}=", arg_value(arg_name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_args_count
|
46
|
+
return if common_constructor.args_count.include?(args.count)
|
47
|
+
|
48
|
+
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
49
|
+
" (given #{args.count}, expected #{common_constructor.args_count})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConstructor
|
7
|
+
class SuperArgs
|
8
|
+
attr_reader :class_initialize, :args, :object
|
9
|
+
delegate :common_constructor, to: :class_initialize
|
10
|
+
|
11
|
+
def initialize(class_initialize, args, object)
|
12
|
+
@class_initialize = class_initialize
|
13
|
+
@args = args
|
14
|
+
@object = object
|
15
|
+
end
|
16
|
+
|
17
|
+
def auto_result
|
18
|
+
r = []
|
19
|
+
sub_args.each do |name, value|
|
20
|
+
i = super_arg_index(name)
|
21
|
+
r[i] = value if i
|
22
|
+
end
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def result
|
27
|
+
result_from_options || auto_result
|
28
|
+
end
|
29
|
+
|
30
|
+
def result_from_options
|
31
|
+
return unless common_constructor.super_args
|
32
|
+
|
33
|
+
object.instance_exec(&common_constructor.super_args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sub_args
|
37
|
+
common_constructor.args.each_with_index.map do |name, index|
|
38
|
+
[name, args[index]]
|
39
|
+
end.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
def super_arg_index(name)
|
43
|
+
super_method.parameters.each_with_index do |arg, index|
|
44
|
+
return index if arg[1] == name
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def super_method
|
50
|
+
class_initialize.klass.superclass&.instance_method(:initialize)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -10,7 +10,6 @@ module EacRubyUtils
|
|
10
10
|
module Envs
|
11
11
|
class Command
|
12
12
|
require_sub __FILE__, include_modules: true
|
13
|
-
enable_console_speaker
|
14
13
|
|
15
14
|
def initialize(env, command, extra_options = {})
|
16
15
|
@env = env
|
@@ -61,17 +60,17 @@ module EacRubyUtils
|
|
61
60
|
|
62
61
|
def execute(options = {})
|
63
62
|
c = command(options)
|
64
|
-
|
63
|
+
debug_print("BEFORE: #{c}")
|
65
64
|
t1 = Time.now
|
66
65
|
r = ::EacRubyUtils::Envs::Process.new(c).to_h
|
67
66
|
i = Time.now - t1
|
68
|
-
|
67
|
+
debug_print("AFTER [#{i}]: #{c}")
|
69
68
|
r
|
70
69
|
end
|
71
70
|
|
72
71
|
def spawn(options = {})
|
73
72
|
c = command(options)
|
74
|
-
|
73
|
+
debug_print("SPAWN: #{c}")
|
75
74
|
::EacRubyUtils::Envs::Spawn.new(c)
|
76
75
|
end
|
77
76
|
|
@@ -83,7 +82,7 @@ module EacRubyUtils
|
|
83
82
|
|
84
83
|
def system(options = {})
|
85
84
|
c = command(options)
|
86
|
-
|
85
|
+
debug_print(c)
|
87
86
|
Kernel.system(c)
|
88
87
|
end
|
89
88
|
|
@@ -109,6 +108,12 @@ module EacRubyUtils
|
|
109
108
|
ENV['DEBUG'].to_s.strip != ''
|
110
109
|
end
|
111
110
|
|
111
|
+
# Print a message if debugging is enabled.
|
112
|
+
def debug_print(message)
|
113
|
+
message = message.to_s
|
114
|
+
puts message.if_respond(:light_red, message) if debug?
|
115
|
+
end
|
116
|
+
|
112
117
|
def append_command_options(command, options)
|
113
118
|
command = options[:input].command + ' | ' + command if options[:input]
|
114
119
|
if options[:input_file]
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/filters'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
require 'filesize'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Fs
|
9
|
+
class Logs
|
10
|
+
TRUNCATE_DEFAULT_LENGTH = 1000
|
11
|
+
TRUNCATE_APPEND_TEXT = '(...) '
|
12
|
+
|
13
|
+
def [](label)
|
14
|
+
log_set.fetch(sanitize_label(label))
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(label)
|
18
|
+
log_set[sanitize_label(label)] = ::EacRubyUtils::Fs::Temp.file
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_all
|
24
|
+
log_set.each_key { |label| remove(label) }
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove(label)
|
30
|
+
log_set.fetch(sanitize_label(label)).remove
|
31
|
+
log_set.delete(sanitize_label(label))
|
32
|
+
end
|
33
|
+
|
34
|
+
def truncate(label, length = TRUNCATE_DEFAULT_LENGTH)
|
35
|
+
content = self[label].read.strip
|
36
|
+
return content if content.length <= TRUNCATE_DEFAULT_LENGTH
|
37
|
+
|
38
|
+
TRUNCATE_APPEND_TEXT + content[content.length - length + TRUNCATE_APPEND_TEXT.length,
|
39
|
+
length - TRUNCATE_APPEND_TEXT.length]
|
40
|
+
end
|
41
|
+
|
42
|
+
def truncate_all(length = TRUNCATE_DEFAULT_LENGTH)
|
43
|
+
s = "Files: #{log_set.length}\n"
|
44
|
+
log_set.each do |label, path|
|
45
|
+
x = truncate(label, length)
|
46
|
+
y = [label, path, ::Filesize.from("#{path.size} B").pretty].join(' / ')
|
47
|
+
s += x.blank? ? ">>> #{y} (Blank) <<<" : ">>> #{y}\n#{x}\n<<< #{y}\n"
|
48
|
+
end
|
49
|
+
s
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def sanitize_label(label)
|
55
|
+
label.to_sym
|
56
|
+
end
|
57
|
+
|
58
|
+
def log_set
|
59
|
+
@log_set ||= {}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,14 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/inflector'
|
4
|
+
|
3
5
|
module EacRubyUtils
|
4
6
|
class Inflector
|
5
7
|
class << self
|
6
8
|
VARIABLE_NAME_PATTERN = /[_a-z][_a-z0-9]*/i.freeze
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
# Convert a string to a variable format: first character as a lowercase letter or underscore
|
11
|
+
# and other as a lowercase letter, underscore or numbers.
|
12
|
+
# @param string [String] The source string.
|
13
|
+
# @param validate [Boolean] Affect the outcome when the result builded is not in a valid
|
14
|
+
# variable format. If `true`, it raises a {ArgumentError}. If `false`, return `nil`.
|
15
|
+
# @return [String, nil]
|
16
|
+
# @raise [ArgumentError]
|
17
|
+
def variableize(string, validate = true)
|
18
|
+
r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_')
|
19
|
+
.gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase
|
10
20
|
m = VARIABLE_NAME_PATTERN.match(r)
|
11
21
|
return r if m
|
22
|
+
return nil unless validate
|
12
23
|
|
13
24
|
raise ::ArgumentError, "Invalid variable name \"#{r}\" was generated " \
|
14
25
|
"from string \"#{string}\""
|