eac_tools 0.10.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/Gemfile.lock +12 -13
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/lib/avm/application_stereotypes/base.rb +11 -1
- data/sub/avm/lib/avm/applications/base/stereotype.rb +31 -0
- data/sub/avm/lib/avm/applications/base.rb +17 -0
- data/sub/avm/lib/avm/registry/application_stereotypes/build_available.rb +9 -6
- data/sub/avm/lib/avm/registry/application_stereotypes/stereotype_builder.rb +8 -5
- data/sub/avm/lib/avm/registry/application_stereotypes.rb +26 -10
- data/sub/avm/lib/avm/registry/instances.rb +1 -1
- data/sub/avm/lib/avm/registry/source_generators.rb +16 -0
- data/sub/avm/lib/avm/registry.rb +2 -1
- data/sub/avm/lib/avm/scms/base.rb +2 -0
- data/sub/avm/lib/avm/source_generators/base.rb +29 -0
- data/sub/avm/lib/avm/source_generators.rb +9 -0
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm/lib/avm/with_application_stereotype.rb +11 -1
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/source_generators/base.rb +13 -0
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/Gemfile +11 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/Rakefile +8 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/assets/config/manifest.js +3 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/assets/javascripts/application.js +1 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/assets/stylesheets/application.scss +1 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/controllers/application_controller.rb +4 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/controllers/welcome_controller.rb +5 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/app/views/welcome/index.html.erb +1 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/bin/bundle +5 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/bin/rails +11 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/bin/rake +11 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/bin/yarn +11 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/application.rb +11 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/boot.rb +5 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/cable.yml +8 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/credentials.yml.enc +1 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/environment.rb +7 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/puma.rb +39 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/routes.rb +5 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config/spring.rb +8 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/config.ru +7 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/db/schema.rb +1 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/lib/ability.rb +20 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/lib/ability_mapping.rb +10 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/public/favicon.ico +0 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/spec/ruby_style_spec.rb +3 -0
- data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/spec/spec_helper.rb +8 -0
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base.rb +14 -0
- data/sub/{avm-tools/lib/avm/tools/runner/eac_redmine_base0 → avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners}/docker.rb +3 -3
- data/sub/{avm-tools/lib/avm/tools/runner/eac_redmine_base0 → avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners}/project_rename.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners.rb +13 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/runners/base.rb +25 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb +1 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-tools/README.textile +0 -11
- data/sub/avm-tools/avm-tools.gemspec +1 -3
- data/sub/avm-tools/lib/avm/tools/runner/instance/info.rb +1 -0
- data/sub/avm-tools/lib/avm/tools/runner/instance.rb +6 -1
- data/sub/avm-tools/lib/avm/tools/runner/source_generate.rb +45 -0
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/base.rb +67 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/sub_file.rb +68 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +2 -125
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{require_sub_spec → require_sub/base_spec}/stubbed_module_a.rb +0 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{require_sub_spec → require_sub/base_spec}/stubbed_not_module.rb +0 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{require_sub_spec.rb → require_sub/base_spec.rb} +1 -1
- metadata +57 -16
- data/sub/avm/lib/avm/application_stereotypes/base/by_gem.rb +0 -17
- data/sub/avm/lib/avm/application_stereotypes/base/detection.rb +0 -34
- data/sub/avm-tools/lib/avm/tools/runner/eac_redmine_base0.rb +0 -15
@@ -0,0 +1 @@
|
|
1
|
+
|
data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/lib/ability.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Ability < ::EacRailsBase0::AppBase::Ability
|
4
|
+
def initialize(user)
|
5
|
+
super(user)
|
6
|
+
user ||= ::EacUsersSupport::User.new
|
7
|
+
for_all_permissions(user)
|
8
|
+
logged_permissions(user) unless user.new_record?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def for_all_permissions(_user)
|
14
|
+
can :read, :welcome
|
15
|
+
end
|
16
|
+
|
17
|
+
def logged_permissions(_user)
|
18
|
+
can :manage, :all
|
19
|
+
end
|
20
|
+
end
|
data/sub/avm-eac_rails_base0/template/avm/eac_rails_base0/source_generators/base/public/favicon.ico
ADDED
File without changes
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib,locale,template}/**/*']
|
14
14
|
|
15
|
+
s.add_dependency 'avm', '~> 0.29'
|
15
16
|
s.add_dependency 'avm-eac_generic_base0', '~> 0.4'
|
16
17
|
s.add_dependency 'avm-eac_rails_base1', '~> 0.4', '>= 0.4.1'
|
17
18
|
s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/base'
|
4
|
+
require 'avm/eac_redmine_base0/instances/runners'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module EacRedmineBase0
|
9
|
+
module Instances
|
10
|
+
class Base < ::Avm::Instances::Base
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'avm/docker/runner'
|
4
4
|
|
5
5
|
module Avm
|
6
|
-
module
|
7
|
-
|
8
|
-
|
6
|
+
module EacRedmineBase0
|
7
|
+
module Instances
|
8
|
+
module Runners
|
9
9
|
class Docker < ::Avm::Docker::Runner
|
10
10
|
def use_default_registry?
|
11
11
|
false
|
@@ -4,9 +4,9 @@ require 'eac_cli/core_ext'
|
|
4
4
|
require 'avm/eac_rails_base1/runner/code_runner'
|
5
5
|
|
6
6
|
module Avm
|
7
|
-
module
|
8
|
-
|
9
|
-
|
7
|
+
module EacRedmineBase0
|
8
|
+
module Instances
|
9
|
+
module Runners
|
10
10
|
class ProjectRename
|
11
11
|
runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle do
|
12
12
|
pos_arg :from
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_redmine_base0/instance'
|
4
|
+
require 'avm/eac_redmine_base0/deploy'
|
5
|
+
require 'avm/eac_redmine_base0/apache_host'
|
6
|
+
require 'avm/eac_rails_base1/runner'
|
7
|
+
require 'eac_ruby_utils/core_ext'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module EacRedmineBase0
|
11
|
+
module Runners
|
12
|
+
class Base < ::Avm::EacRailsBase1::Runner
|
13
|
+
require_sub __FILE__
|
14
|
+
|
15
|
+
STEREOTYPE_NAME = 'EacRedmineBase0'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def stereotype_name
|
19
|
+
STEREOTYPE_NAME
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/eac_rails_base1/sources/base'
|
3
4
|
require 'avm/eac_redmine_base0/core_update'
|
4
5
|
require 'eac_cli/core_ext'
|
5
|
-
require 'avm/eac_rails_base1/sources/base'
|
6
|
-
require 'avm/eac_redmine_base0/sources/runners'
|
7
|
-
require 'eac_ruby_utils/core_ext'
|
8
6
|
|
9
7
|
module Avm
|
10
8
|
module EacRedmineBase0
|
@@ -26,14 +26,3 @@ h2. Instance's entries suffixes
|
|
26
26
|
| system.username | Name of user that runs instance | @host_id->system.username or self->ssh.username@ |
|
27
27
|
| web.url | Root URL to web interface | @nil@ |
|
28
28
|
| web.hostname | Hostname of web interface | @web.url->hostname@ |
|
29
|
-
|
30
|
-
h2. Instances' types hierarchy
|
31
|
-
|
32
|
-
* base
|
33
|
-
** eac_ruby_base0
|
34
|
-
** eac_ubuntu_base0
|
35
|
-
** eac_webapp_base0
|
36
|
-
*** eac_rails_base1
|
37
|
-
**** eac_rails_base0
|
38
|
-
**** eac_redmine_base0
|
39
|
-
*** eac_wordpress_base0
|
@@ -15,10 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
16
|
|
17
17
|
s.add_dependency 'aranha-parsers', '~> 0.4'
|
18
|
-
s.add_dependency 'avm', '~> 0.
|
18
|
+
s.add_dependency 'avm', '~> 0.30'
|
19
19
|
s.add_dependency 'avm-eac_asciidoctor_base0', '~> 0.3', '>= 0.3.4'
|
20
|
-
s.add_dependency 'avm-eac_rails_base0', '~> 0.3'
|
21
|
-
s.add_dependency 'avm-eac_redmine_base0', '~> 0.5', '>= 0.5.2'
|
22
20
|
s.add_dependency 'avm-eac_ruby_base1', '~> 0.8'
|
23
21
|
s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
|
24
22
|
s.add_dependency 'avm-files', '~> 0.1'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'avm/instances/base'
|
4
|
+
require 'avm/registry'
|
4
5
|
require 'eac_cli/core_ext'
|
5
6
|
|
6
7
|
module Avm
|
@@ -14,10 +15,14 @@ module Avm
|
|
14
15
|
subcommands
|
15
16
|
end
|
16
17
|
|
18
|
+
def extra_available_subcommands
|
19
|
+
instance.if_present({}, &:extra_available_subcommands)
|
20
|
+
end
|
21
|
+
|
17
22
|
private
|
18
23
|
|
19
24
|
def instance_uncached
|
20
|
-
::Avm::
|
25
|
+
::Avm::Registry.instances.detect(parsed.instance_id)
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/runners/base'
|
4
|
+
require 'eac_cli/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Tools
|
8
|
+
class Runner
|
9
|
+
class SourceGenerate
|
10
|
+
runner_with :help do
|
11
|
+
pos_arg :stereotype_name
|
12
|
+
pos_arg :target_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
start_banner
|
17
|
+
generate
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate
|
21
|
+
infom 'Generating...'
|
22
|
+
generator.perform
|
23
|
+
success "Source generated in \"#{generator.target_path}\""
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_banner
|
27
|
+
infov 'Stereotype', stereotype_name
|
28
|
+
infov 'Target path', target_path
|
29
|
+
infov 'Generator', generator.class
|
30
|
+
end
|
31
|
+
|
32
|
+
def generator_uncached
|
33
|
+
::Avm::Registry.source_generators.detect_optional(stereotype_name, target_path) ||
|
34
|
+
fatal_error("No generator found for stereotype \"#{stereotype_name}\"")
|
35
|
+
end
|
36
|
+
|
37
|
+
delegate :stereotype_name, to: :parsed
|
38
|
+
|
39
|
+
def target_path
|
40
|
+
parsed.target_path.to_pathname
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/listable'
|
4
|
+
require 'eac_ruby_utils/require_sub/sub_file'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module RequireSub
|
8
|
+
class Base
|
9
|
+
INCLUDE_MODULES_MAP = {
|
10
|
+
nil => nil,
|
11
|
+
false => nil,
|
12
|
+
true => :include,
|
13
|
+
include: :include,
|
14
|
+
prepend: :prepend
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
include ::EacRubyUtils::Listable
|
18
|
+
lists.add_symbol :option, :base, :include_modules, :require_dependency
|
19
|
+
|
20
|
+
attr_reader :file, :options
|
21
|
+
|
22
|
+
def initialize(file, options = {})
|
23
|
+
@file = file
|
24
|
+
@options = self.class.lists.option.hash_keys_validate!(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean]
|
28
|
+
def active_support_require?
|
29
|
+
options[OPTION_REQUIRE_DEPENDENCY] ? true : false
|
30
|
+
end
|
31
|
+
|
32
|
+
def apply
|
33
|
+
require_sub_files
|
34
|
+
include_modules
|
35
|
+
end
|
36
|
+
|
37
|
+
def base
|
38
|
+
options[OPTION_BASE] || raise('Option :base not setted')
|
39
|
+
end
|
40
|
+
|
41
|
+
def base?
|
42
|
+
options[OPTION_BASE] ? true : false
|
43
|
+
end
|
44
|
+
|
45
|
+
def include_modules
|
46
|
+
sub_files.each(&:include_module)
|
47
|
+
end
|
48
|
+
|
49
|
+
def include_or_prepend_method
|
50
|
+
return INCLUDE_MODULES_MAP.fetch(options[OPTION_INCLUDE_MODULES]) if
|
51
|
+
INCLUDE_MODULES_MAP.key?(options[OPTION_INCLUDE_MODULES])
|
52
|
+
|
53
|
+
raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
|
54
|
+
" \"#{options[OPTION_INCLUDE_MODULES]}\""
|
55
|
+
end
|
56
|
+
|
57
|
+
def require_sub_files
|
58
|
+
sub_files.each(&:require_file)
|
59
|
+
end
|
60
|
+
|
61
|
+
def sub_files
|
62
|
+
@sub_files ||= Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort
|
63
|
+
.map { |path| ::EacRubyUtils::RequireSub::SubFile.new(self, path) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/dependencies'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module RequireSub
|
8
|
+
class SubFile
|
9
|
+
attr_reader :owner, :path
|
10
|
+
|
11
|
+
def initialize(owner, path)
|
12
|
+
@owner = owner
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_constant
|
17
|
+
return nil unless owner.base?
|
18
|
+
|
19
|
+
owner.base.const_get(constant_name)
|
20
|
+
rescue ::NameError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def constant_name
|
25
|
+
::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
|
26
|
+
end
|
27
|
+
|
28
|
+
def include_module
|
29
|
+
return unless module?
|
30
|
+
|
31
|
+
owner.include_or_prepend_method.if_present do |v|
|
32
|
+
owner.base.send(v, base_constant)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def module?
|
37
|
+
base_constant.is_a?(::Module) && !base_constant.is_a?(::Class)
|
38
|
+
end
|
39
|
+
|
40
|
+
def require_file
|
41
|
+
active_support_require || autoload_require || kernel_require
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def active_support_require
|
47
|
+
return false unless owner.active_support_require?
|
48
|
+
|
49
|
+
::Kernel.require_dependency(path)
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def autoload_require
|
54
|
+
return false unless owner.base?
|
55
|
+
|
56
|
+
basename = ::File.basename(path, '.*')
|
57
|
+
return false if basename.start_with?('_')
|
58
|
+
|
59
|
+
owner.base.autoload ::ActiveSupport::Inflector.camelize(basename), path
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
63
|
+
def kernel_require
|
64
|
+
::Kernel.require(path)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,134 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'active_support/dependencies'
|
5
|
-
require 'eac_ruby_utils/listable'
|
3
|
+
require 'eac_ruby_utils/require_sub/base'
|
6
4
|
|
7
5
|
module EacRubyUtils
|
8
6
|
class << self
|
9
7
|
def require_sub(file, options = {})
|
10
|
-
::EacRubyUtils::RequireSub.new(file, options).apply
|
11
|
-
end
|
12
|
-
end
|
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
|
-
|
23
|
-
include ::EacRubyUtils::Listable
|
24
|
-
lists.add_symbol :option, :base, :include_modules, :require_dependency
|
25
|
-
|
26
|
-
attr_reader :file, :options
|
27
|
-
|
28
|
-
def initialize(file, options = {})
|
29
|
-
@file = file
|
30
|
-
@options = self.class.lists.option.hash_keys_validate!(options)
|
31
|
-
end
|
32
|
-
|
33
|
-
def apply
|
34
|
-
require_sub_files
|
35
|
-
include_modules
|
36
|
-
end
|
37
|
-
|
38
|
-
def base
|
39
|
-
options[OPTION_BASE] || raise('Option :base not setted')
|
40
|
-
end
|
41
|
-
|
42
|
-
def base?
|
43
|
-
options[OPTION_BASE] ? true : false
|
44
|
-
end
|
45
|
-
|
46
|
-
def include_modules
|
47
|
-
sub_files.each(&:include_module)
|
48
|
-
end
|
49
|
-
|
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])
|
53
|
-
|
54
|
-
raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
|
55
|
-
" \"#{options[OPTION_INCLUDE_MODULES]}\""
|
56
|
-
end
|
57
|
-
|
58
|
-
def require_sub_files
|
59
|
-
sub_files.each(&:require_file)
|
60
|
-
end
|
61
|
-
|
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
|
66
|
-
|
67
|
-
class SubFile
|
68
|
-
attr_reader :owner, :path
|
69
|
-
|
70
|
-
def initialize(owner, path)
|
71
|
-
@owner = owner
|
72
|
-
@path = path
|
73
|
-
end
|
74
|
-
|
75
|
-
def base_constant
|
76
|
-
return nil unless owner.base?
|
77
|
-
|
78
|
-
owner.base.const_get(constant_name)
|
79
|
-
rescue ::NameError
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
def constant_name
|
84
|
-
::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
|
85
|
-
end
|
86
|
-
|
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
|
117
|
-
end
|
118
|
-
|
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
|
8
|
+
::EacRubyUtils::RequireSub::Base.new(file, options).apply
|
132
9
|
end
|
133
10
|
end
|
134
11
|
end
|
File without changes
|
File without changes
|
data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{require_sub_spec.rb → require_sub/base_spec.rb}
RENAMED
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/require_sub'
|
|
5
5
|
class RequireSubStubClass
|
6
6
|
end
|
7
7
|
|
8
|
-
RSpec.describe ::EacRubyUtils::RequireSub do
|
8
|
+
RSpec.describe ::EacRubyUtils::RequireSub::Base do
|
9
9
|
let(:instance) { described_class.new(__FILE__, base: RequireSubStubClass, include_modules: true) }
|
10
10
|
|
11
11
|
before do
|