avm-tools 0.116.1 → 0.117.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/launcher/instances/settings.rb +7 -3
- data/lib/avm/projects/stereotypes.rb +2 -2
- data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +1 -3
- data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser.rb +1 -1
- data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock/git.rb +1 -1
- data/lib/avm/tools/runner/app_src/test.rb +2 -2
- data/lib/avm/tools/runner/app_src/version_bump.rb +4 -9
- data/lib/avm/tools/runner/git/deploy.rb +4 -4
- data/lib/avm/tools/runner/git/dirty_files.rb +1 -1
- data/lib/avm/tools/runner/git/revisions_test.rb +1 -1
- data/lib/avm/tools/runner/ruby/rubocop.rb +2 -2
- data/lib/avm/tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +3 -3
- data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +2 -2
- data/sub/avm/lib/avm/registry/base.rb +2 -2
- data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
- data/sub/avm/lib/avm/scms/base.rb +13 -0
- data/sub/avm/lib/avm/sources/base/configuration.rb +2 -1
- data/sub/avm/lib/avm/sources/base/parent.rb +31 -0
- data/sub/avm/lib/avm/sources/base.rb +4 -6
- data/sub/avm/lib/avm/sources/configuration/{_locale.rb → locale.rb} +5 -3
- data/sub/avm/lib/avm/sources/configuration/rubocop.rb +26 -0
- data/sub/avm/lib/avm/sources/configuration/tests.rb +29 -0
- data/sub/avm/lib/avm/sources/configuration.rb +5 -1
- data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +1 -1
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base/version_bump.rb +35 -0
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +4 -1
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
- data/sub/avm-eac_generic_base0/locale/en.yaml +6 -0
- data/sub/avm-eac_generic_base0/locale/pt-BR.yaml +6 -0
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +1 -1
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb +17 -2
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile.template +2 -8
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile_apache_setup +8 -0
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/start.sh.template +1 -1
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb +56 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb +19 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb +34 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb +11 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +31 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +17 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +41 -0
- data/{lib/avm/ruby → sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1}/rubocop.rb +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +23 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +11 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-files/avm-files.gemspec +1 -1
- data/sub/avm-files/lib/avm/files/appendable.rb +1 -1
- data/sub/avm-files/lib/avm/files/formatter/formats/ruby.rb +2 -2
- data/sub/avm-files/lib/avm/files/version.rb +1 -1
- data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +1 -3
- data/sub/avm-git/lib/avm/git/version.rb +1 -1
- data/sub/eac_cli/eac_cli.gemspec +2 -2
- data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb +9 -22
- data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +50 -0
- data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +0 -9
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +4 -4
- data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +23 -17
- data/sub/eac_config/eac_config.gemspec +1 -1
- data/sub/eac_config/lib/eac_config/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/paths_hash/node.rb +1 -1
- data/sub/eac_config/lib/eac_config/version.rb +1 -1
- data/sub/eac_fs/eac_fs.gemspec +1 -1
- data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
- data/sub/eac_git/eac_git.gemspec +1 -1
- data/sub/eac_git/lib/eac_git/local/remote.rb +2 -2
- data/sub/eac_git/lib/eac_git/local.rb +1 -1
- data/sub/eac_git/lib/eac_git/version.rb +1 -1
- data/sub/eac_rest/eac_rest.gemspec +1 -1
- data/sub/eac_rest/lib/eac_rest/api.rb +14 -3
- data/sub/eac_rest/lib/eac_rest/request.rb +22 -1
- data/sub/eac_rest/lib/eac_rest/response.rb +41 -1
- data/sub/eac_rest/lib/eac_rest/version.rb +1 -1
- data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +2 -2
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +1 -1
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +2 -2
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -2
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +16 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +12 -2
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +2 -25
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +6 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +86 -33
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/{temp_spec.rb → directory_spec.rb} +0 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +4 -4
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +169 -106
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +52 -17
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +3 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +21 -18
- data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +3 -0
- data/sub/eac_templates/eac_templates.gemspec +1 -1
- data/sub/eac_templates/lib/eac_templates/directory.rb +1 -1
- data/sub/eac_templates/lib/eac_templates/version.rb +1 -1
- metadata +45 -18
- data/lib/avm/projects/stereotypes/rails_application/update.rb +0 -14
- data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +0 -60
- data/lib/avm/ruby/rubocop/_configured.rb +0 -29
- data/lib/avm/ruby/rubocop/_envvar.rb +0 -15
- data/lib/avm/ruby/rubocop/_gemfile.rb +0 -39
- data/sub/avm/lib/avm/sources/configuration/_rubocop.rb +0 -24
- data/sub/avm/lib/avm/sources/configuration/_tests.rb +0 -27
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb +0 -7
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches.rb +0 -4
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'i18n'
|
4
|
+
require 'eac_ruby_utils/patches/class/common_constructor'
|
5
|
+
require 'eac_ruby_utils/patches/object/to_pathname'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Locales
|
9
|
+
class FromGem
|
10
|
+
class << self
|
11
|
+
def include_all(i18n_obj = nil)
|
12
|
+
::Gem::Specification.each { |gemspec| new(gemspec, i18n_obj).include }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
LOCALES_DIR_SUBPATH = 'locale'
|
17
|
+
LOCALES_FILES_GLOB_PATTERNS = %w[*.yaml *.yml].freeze
|
18
|
+
|
19
|
+
common_constructor :gemspec, :i18n_obj, default: [nil] do
|
20
|
+
self.i18n_obj ||= ::I18n
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Boolean]
|
24
|
+
delegate :exist?, to: :path
|
25
|
+
|
26
|
+
# @return [Pathname, nil]
|
27
|
+
def include
|
28
|
+
return nil unless exist?
|
29
|
+
|
30
|
+
::I18n.load_path += paths_to_load.map(&:to_path)
|
31
|
+
path
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Pathname]
|
35
|
+
def path
|
36
|
+
gemspec.gem_dir.to_pathname.join(LOCALES_DIR_SUBPATH)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Pathname]
|
40
|
+
def paths_to_load
|
41
|
+
return [] unless exist?
|
42
|
+
|
43
|
+
LOCALES_FILES_GLOB_PATTERNS.inject([]) { |a, e| a + path.glob(e) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'eac_ruby_utils/common_constructor'
|
5
|
+
require 'i18n'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Locales
|
9
|
+
class ModuleI18nTranslate
|
10
|
+
TRANSLATE_LOCALE_KEY = :__locale
|
11
|
+
|
12
|
+
common_constructor :the_module, :entry_suffix, :values, default: [{}]
|
13
|
+
|
14
|
+
def ancestor_i18n_translate(ancestor)
|
15
|
+
t = self.class.new(ancestor, entry_suffix, values)
|
16
|
+
t.exists? ? t.i18n_translate : nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def ancestors_i18n_translate
|
20
|
+
the_module.ancestors.lazy.map { |v| ancestor_i18n_translate(v) }.find(&:present?)
|
21
|
+
end
|
22
|
+
|
23
|
+
def exists?
|
24
|
+
::I18n.exists?(i18n_key)
|
25
|
+
end
|
26
|
+
|
27
|
+
def i18n_key
|
28
|
+
"#{module_entry_prefix}.#{entry_suffix}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def i18n_options
|
32
|
+
values.except(TRANSLATE_LOCALE_KEY)
|
33
|
+
end
|
34
|
+
|
35
|
+
def i18n_translate
|
36
|
+
::I18n.translate(i18n_key, i18n_options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def locale
|
40
|
+
values[TRANSLATE_LOCALE_KEY]
|
41
|
+
end
|
42
|
+
|
43
|
+
def module_entry_prefix
|
44
|
+
the_module.name.underscore.gsub('/', '.')
|
45
|
+
end
|
46
|
+
|
47
|
+
def on_locale(&block)
|
48
|
+
if locale.present?
|
49
|
+
on_present_locale(&block)
|
50
|
+
else
|
51
|
+
block.call
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def result
|
56
|
+
on_locale do
|
57
|
+
ancestors_i18n_translate || i18n_translate
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def on_present_locale(&block)
|
64
|
+
old_locale = ::I18n.locale
|
65
|
+
begin
|
66
|
+
::I18n.locale = locale
|
67
|
+
block.call
|
68
|
+
ensure
|
69
|
+
::I18n.locale = old_locale
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/introspection'
|
4
|
+
require 'eac_ruby_utils/patches/class/common_constructor'
|
5
|
+
require 'eac_ruby_utils/patches/module/common_concern'
|
6
|
+
require 'eac_ruby_utils/patches/string/inflector'
|
7
|
+
|
8
|
+
module EacRubyUtils
|
9
|
+
module MethodClass
|
10
|
+
common_concern do
|
11
|
+
::EacRubyUtils::MethodClass::Setup.new(self)
|
12
|
+
end
|
13
|
+
|
14
|
+
class Setup
|
15
|
+
common_constructor :method_class do
|
16
|
+
perform
|
17
|
+
end
|
18
|
+
|
19
|
+
def perform
|
20
|
+
the_setup = self
|
21
|
+
sender_module.define_method(method_name) do |*args, &block|
|
22
|
+
the_setup.method_class.new(self, *args, &block).result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_name
|
27
|
+
method_class.name.demodulize.underscore.variableize
|
28
|
+
end
|
29
|
+
|
30
|
+
def sender_module
|
31
|
+
method_class.module_parent
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,32 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'i18n'
|
3
|
+
require 'eac_ruby_utils/locales/module_i18n_translate'
|
5
4
|
|
6
5
|
class Module
|
7
|
-
TRANSLATE_LOCALE_KEY = :__locale
|
8
|
-
|
9
6
|
def i18n_translate(entry_suffix, values = {})
|
10
|
-
|
11
|
-
::I18n.translate(i18n_translate_entry_full(entry_suffix), values)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def i18n_translate_entry_full(entry_suffix)
|
16
|
-
"#{i18n_translate_entry_self_prefix}.#{entry_suffix}"
|
17
|
-
end
|
18
|
-
|
19
|
-
def i18n_translate_entry_self_prefix
|
20
|
-
name.underscore.gsub('/', '.')
|
21
|
-
end
|
22
|
-
|
23
|
-
def on_i18n_locale(locale)
|
24
|
-
old_locale = ::I18n.locale
|
25
|
-
begin
|
26
|
-
::I18n.locale = locale
|
27
|
-
yield
|
28
|
-
ensure
|
29
|
-
::I18n.locale = old_locale
|
30
|
-
end
|
7
|
+
::EacRubyUtils::Locales::ModuleI18nTranslate.new(self, entry_suffix, values).result
|
31
8
|
end
|
32
9
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/inflector'
|
4
|
+
require 'active_support/dependencies'
|
4
5
|
require 'eac_ruby_utils/listable'
|
5
6
|
|
6
7
|
module EacRubyUtils
|
@@ -11,6 +12,14 @@ module EacRubyUtils
|
|
11
12
|
end
|
12
13
|
|
13
14
|
class RequireSub
|
15
|
+
INCLUDE_MODULES_MAP = {
|
16
|
+
nil => nil,
|
17
|
+
false => nil,
|
18
|
+
true => :include,
|
19
|
+
include: :include,
|
20
|
+
prepend: :prepend
|
21
|
+
}.freeze
|
22
|
+
|
14
23
|
include ::EacRubyUtils::Listable
|
15
24
|
lists.add_symbol :option, :base, :include_modules, :require_dependency
|
16
25
|
|
@@ -26,56 +35,100 @@ module EacRubyUtils
|
|
26
35
|
include_modules
|
27
36
|
end
|
28
37
|
|
29
|
-
|
38
|
+
def base
|
39
|
+
options[OPTION_BASE] || raise('Option :base not setted')
|
40
|
+
end
|
30
41
|
|
31
|
-
def
|
32
|
-
|
42
|
+
def base?
|
43
|
+
options[OPTION_BASE] ? true : false
|
44
|
+
end
|
33
45
|
|
34
|
-
|
35
|
-
|
46
|
+
def include_modules
|
47
|
+
sub_files.each(&:include_module)
|
36
48
|
end
|
37
49
|
|
38
|
-
def
|
39
|
-
return
|
50
|
+
def include_or_prepend_method
|
51
|
+
return INCLUDE_MODULES_MAP.fetch(options[OPTION_INCLUDE_MODULES]) if
|
52
|
+
INCLUDE_MODULES_MAP.key?(options[OPTION_INCLUDE_MODULES])
|
40
53
|
|
41
|
-
|
42
|
-
|
54
|
+
raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
|
55
|
+
" \"#{options[OPTION_INCLUDE_MODULES]}\""
|
56
|
+
end
|
43
57
|
|
44
|
-
|
45
|
-
|
58
|
+
def require_sub_files
|
59
|
+
sub_files.each(&:require_file)
|
46
60
|
end
|
47
61
|
|
48
|
-
def
|
49
|
-
|
62
|
+
def sub_files
|
63
|
+
@sub_files ||= Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort
|
64
|
+
.map { |path| SubFile.new(self, path) }
|
65
|
+
end
|
50
66
|
|
51
|
-
|
52
|
-
|
53
|
-
next unless constant.is_a?(::Module) && !constant.is_a?(::Class)
|
67
|
+
class SubFile
|
68
|
+
attr_reader :owner, :path
|
54
69
|
|
55
|
-
|
70
|
+
def initialize(owner, path)
|
71
|
+
@owner = owner
|
72
|
+
@path = path
|
56
73
|
end
|
57
|
-
end
|
58
74
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
75
|
+
def base_constant
|
76
|
+
return nil unless owner.base?
|
62
77
|
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
owner.base.const_get(constant_name)
|
79
|
+
rescue ::NameError
|
80
|
+
nil
|
81
|
+
end
|
66
82
|
|
67
|
-
|
68
|
-
|
69
|
-
|
83
|
+
def constant_name
|
84
|
+
::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
|
85
|
+
end
|
70
86
|
|
71
|
-
|
72
|
-
|
73
|
-
|
87
|
+
def include_module
|
88
|
+
return unless module?
|
89
|
+
|
90
|
+
owner.include_or_prepend_method.if_present do |v|
|
91
|
+
owner.base.send(v, base_constant)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def include_or_prepend_method
|
96
|
+
return :include if owner.options[OPTION_INCLUDE_MODULES]
|
97
|
+
return :prepend if owner.options[OPTION_PREPEND_MODULES]
|
98
|
+
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
|
102
|
+
def module?
|
103
|
+
base_constant.is_a?(::Module) && !base_constant.is_a?(::Class)
|
104
|
+
end
|
105
|
+
|
106
|
+
def require_file
|
107
|
+
active_support_require || autoload_require || kernel_require
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def active_support_require
|
113
|
+
return false unless owner.options[OPTION_REQUIRE_DEPENDENCY]
|
114
|
+
|
115
|
+
::Kernel.require_dependency(path)
|
116
|
+
true
|
74
117
|
end
|
75
|
-
end
|
76
118
|
|
77
|
-
|
78
|
-
|
119
|
+
def autoload_require
|
120
|
+
return false unless owner.base?
|
121
|
+
|
122
|
+
basename = ::File.basename(path, '.*')
|
123
|
+
return false if basename.start_with?('_')
|
124
|
+
|
125
|
+
owner.base.autoload ::ActiveSupport::Inflector.camelize(basename), path
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def kernel_require
|
130
|
+
::Kernel.require(path)
|
131
|
+
end
|
79
132
|
end
|
80
133
|
end
|
81
134
|
end
|
@@ -12,7 +12,7 @@ module EacRubyUtils
|
|
12
12
|
|
13
13
|
def on_clean_envvars(*start_with_vars)
|
14
14
|
old_values = envvars_starting_with(start_with_vars)
|
15
|
-
old_values.
|
15
|
+
old_values.each_key { |k| ENV.delete(k) }
|
16
16
|
yield
|
17
17
|
ensure
|
18
18
|
old_values&.each { |k, v| ENV[k] = v }
|
File without changes
|
@@ -4,7 +4,7 @@ require 'eac_ruby_utils/fs/temp'
|
|
4
4
|
|
5
5
|
RSpec.describe ::EacRubyUtils::Fs::Temp do
|
6
6
|
describe '#on_file' do
|
7
|
-
it do
|
7
|
+
it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
8
8
|
temp_path = nil
|
9
9
|
described_class.on_file do |path|
|
10
10
|
temp_path = path
|
@@ -15,7 +15,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
15
15
|
expect(temp_path).not_to exist
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'not fail if already removed' do
|
18
|
+
it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
19
19
|
temp_path = nil
|
20
20
|
described_class.on_file do |path|
|
21
21
|
temp_path = path
|
@@ -29,7 +29,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#on_directory' do
|
32
|
-
it do
|
32
|
+
it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
33
33
|
temp_path = nil
|
34
34
|
described_class.on_directory do |path|
|
35
35
|
temp_path = path
|
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
38
38
|
expect(temp_path).not_to exist
|
39
39
|
end
|
40
40
|
|
41
|
-
it 'not fail if already removed' do
|
41
|
+
it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
42
42
|
temp_path = nil
|
43
43
|
described_class.on_directory do |path|
|
44
44
|
temp_path = path
|