eac_tools 0.63.0 → 0.65.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +32 -32
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +2 -2
  5. data/sub/avm/lib/avm/data/package.rb +1 -1
  6. data/sub/avm/lib/avm/data/unit.rb +25 -54
  7. data/sub/avm/lib/avm/data/unit_with_commands.rb +52 -0
  8. data/sub/avm/lib/avm/instances/base/subcommand_parent.rb +25 -0
  9. data/sub/avm/lib/avm/instances/data/files_unit.rb +1 -4
  10. data/sub/avm/lib/avm/instances/data/unit.rb +14 -2
  11. data/sub/avm/lib/avm/instances/entry_keys.rb +1 -0
  12. data/sub/avm/lib/avm/version.rb +1 -1
  13. data/sub/avm-eac_postgresql_base0/avm-eac_postgresql_base0.gemspec +2 -2
  14. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb +5 -8
  15. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +0 -4
  16. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance_with.rb +5 -0
  17. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +1 -1
  18. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +3 -3
  19. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base.rb +2 -10
  20. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/data/load.rb +3 -1
  21. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  22. data/sub/avm-tools/avm-tools.gemspec +11 -11
  23. data/sub/{avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners → avm-tools/lib/avm/tools/runner/instance}/data/dump.rb +11 -6
  24. data/sub/avm-tools/lib/avm/tools/runner/instance/data/load.rb +58 -0
  25. data/sub/{avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners → avm-tools/lib/avm/tools/runner/instance}/data/unit/clear.rb +4 -3
  26. data/sub/avm-tools/lib/avm/tools/runner/instance/data/unit/dump.rb +41 -0
  27. data/sub/{avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners → avm-tools/lib/avm/tools/runner/instance}/data/unit/load.rb +10 -4
  28. data/sub/{avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners → avm-tools/lib/avm/tools/runner/instance}/data/unit.rb +6 -5
  29. data/sub/{avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners → avm-tools/lib/avm/tools/runner/instance}/data.rb +4 -3
  30. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  31. data/sub/eac_cli/eac_cli.gemspec +1 -1
  32. data/sub/eac_cli/lib/eac_cli/definition/base_option.rb +3 -1
  33. data/sub/eac_cli/lib/eac_cli/definition/default_value.rb +17 -0
  34. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +8 -26
  35. data/sub/eac_cli/lib/eac_cli/runner_with/help/layout.rb +40 -0
  36. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +12 -0
  37. data/sub/eac_cli/lib/eac_cli/runner_with/input.rb +1 -1
  38. data/sub/eac_cli/lib/eac_cli/runner_with/output.rb +1 -1
  39. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -4
  40. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  41. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +21 -0
  42. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +0 -1
  43. data/sub/eac_ruby_utils/lib/eac_ruby_utils/{abstract_methods.rb → acts_as_abstract.rb} +30 -9
  44. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +2 -2
  45. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +3 -3
  46. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_abstract.rb +14 -0
  47. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +5 -1
  48. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +2 -2
  49. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  50. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{abstract_methods_spec.rb → acts_as_abstract_spec.rb} +2 -2
  51. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +1 -1
  52. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/acts_as_abstract_spec.rb +14 -0
  53. metadata +34 -29
  54. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/subcommand_parent.rb +0 -26
  55. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/data/unit/dump.rb +0 -25
  56. data/sub/eac_cli/lib/eac_cli/runner_with/help/list_section.rb +0 -22
  57. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/list_section_spec.rb +0 -21
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/runner'
4
+ require 'eac_cli/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
10
+ class Data
11
+ class Load
12
+ runner_with :help do
13
+ desc 'Load utility for EacRailsBase instance.'
14
+ arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
15
+ pos_arg :dump_path, optional: true
16
+ end
17
+
18
+ def run
19
+ return fatal_error("Dump \"#{dump_path}\" does not exist") unless
20
+ ::File.exist?(dump_path)
21
+
22
+ load_dump
23
+ success("Dump loaded from \"#{dump_path}\"")
24
+ end
25
+
26
+ def dump_path_uncached
27
+ return parsed.dump_path.to_s if parsed.dump_path.present?
28
+ return source_instance_dump_path if parsed.source_instance.present?
29
+
30
+ raise "Dump path unknown (Options: #{parsed})"
31
+ end
32
+
33
+ def source_instance_dump_path
34
+ runner_context.call(:instance).class.by_id(parsed.source_instance).run_subcommand(
35
+ ::Avm::Tools::Runner::Instance::Data::Dump, []
36
+ )
37
+ end
38
+
39
+ def load_dump
40
+ info "Loading dump \"#{dump_path}\"..."
41
+ package_load.run
42
+ end
43
+
44
+ def dump_instance_method
45
+ :dump_database
46
+ end
47
+
48
+ private
49
+
50
+ def package_load_uncached
51
+ runner_context.call(:instance).data_package.load(dump_path)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/runner'
3
4
  require 'eac_cli/core_ext'
4
5
 
5
6
  module Avm
6
- module EacWebappBase0
7
- module Instances
8
- module Runners
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
9
10
  class Data
10
11
  class Unit
11
12
  class Clear
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/runner'
4
+ require 'eac_cli/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
10
+ class Data
11
+ class Unit
12
+ class Dump
13
+ runner_with :help do
14
+ pos_arg :dump_path, optional: true
15
+ end
16
+
17
+ def run
18
+ runner_context.call(:data_unit).dump(dump_path)
19
+ end
20
+
21
+ # @return [String]
22
+ def help_extra_text
23
+ "Default dump path: \"#{default_dump_path}\""
24
+ end
25
+
26
+ # @return [Pathname]
27
+ def dump_path
28
+ (parsed.dump_path || default_dump_path).to_pathname
29
+ end
30
+
31
+ # @return [String]
32
+ def default_dump_path
33
+ runner_context.call(:data_unit).data_default_dump_path
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/runner'
3
4
  require 'eac_cli/core_ext'
4
5
 
5
6
  module Avm
6
- module EacWebappBase0
7
- module Instances
8
- module Runners
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
9
10
  class Data
10
11
  class Unit
11
12
  class Load
@@ -14,7 +15,12 @@ module Avm
14
15
  end
15
16
 
16
17
  def run
17
- nyi
18
+ runner_context.call(:data_unit).load(dump_path)
19
+ end
20
+
21
+ # @return [Pathname]
22
+ def dump_path
23
+ parsed.dump_path.to_pathname
18
24
  end
19
25
  end
20
26
  end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/runner'
3
4
  require 'eac_cli/core_ext'
4
5
 
5
6
  module Avm
6
- module EacWebappBase0
7
- module Instances
8
- module Runners
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
9
10
  class Data
10
11
  class Unit
11
12
  require_sub __FILE__
@@ -29,9 +30,9 @@ module Avm
29
30
  data_package.unit(parsed.identifier)
30
31
  end
31
32
 
32
- # @return [Hash<String, Enumerable<String>]
33
+ # @return [String]
33
34
  def help_extra_text
34
- super.merge('Available units' => available_units_ids)
35
+ help_join_sections(super, list_section('Available units', available_units_ids))
35
36
  end
36
37
  end
37
38
  end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/runner'
3
4
  require 'eac_cli/core_ext'
4
5
 
5
6
  module Avm
6
- module EacWebappBase0
7
- module Instances
8
- module Runners
7
+ module Tools
8
+ class Runner
9
+ class Instance < ::Avm::Instances::Runner
9
10
  class Data
10
11
  require_sub __FILE__
11
12
  runner_with :help, :subcommands do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.145.1'
5
+ VERSION = '0.147.0'
6
6
  end
7
7
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
16
16
  s.add_dependency 'eac_config', '~> 0.12'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.113'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.114'
18
18
 
19
19
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
20
20
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/definition/default_value'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module EacCli
6
7
  class Definition
7
8
  class BaseOption
8
9
  require_sub __FILE__
10
+ include ::EacCli::Definition::DefaultValue
9
11
 
10
12
  class << self
11
13
  def from_args(args)
@@ -17,7 +19,7 @@ module EacCli
17
19
  DEFAULT_REQUIRED = false
18
20
 
19
21
  enable_listable
20
- enable_abstract_methods :build_value, :default_value
22
+ enable_abstract_methods :build_value
21
23
  lists.add_symbol :option, :default, :optional, :usage, :repeat, :required
22
24
  common_constructor :short, :long, :description, :options, default: [{}] do
23
25
  raise 'Nor short neither long selector was set' if short.blank? && long.blank?
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Definition
7
+ module DefaultValue
8
+ def default_value
9
+ default_value? ? options[OPTION_DEFAULT] : default_default_value
10
+ end
11
+
12
+ def default_value?
13
+ options.key?(OPTION_DEFAULT)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,18 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/runner_with/help/list_section'
3
+ require 'eac_cli/runner_with/help/layout'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module EacCli
7
7
  module RunnerWith
8
8
  module Help
9
9
  class Builder
10
+ include ::EacCli::RunnerWith::Help::Layout
10
11
  require_sub __FILE__, require_dependency: true
11
12
  common_constructor :runner
12
13
 
13
- OPTION_DESC_SEP = ::EacCli::RunnerWith::Help::ListSection::IDENTATION * 2
14
- SECTION_SEPARATOR = "\n"
15
-
16
14
  class << self
17
15
  def option_long(option)
18
16
  b = option.long
@@ -35,7 +33,7 @@ module EacCli
35
33
  end
36
34
 
37
35
  def word_separator
38
- ::EacCli::RunnerWith::Help::ListSection::WORD_SEPARATOR
36
+ WORD_SEPARATOR
39
37
  end
40
38
  end
41
39
 
@@ -45,36 +43,22 @@ module EacCli
45
43
  runner.class.runner_definition
46
44
  end
47
45
 
48
- # @return [String, nil]
49
- def extra_section
50
- ess = extra_sections
51
- return nil if ess.none?
52
-
53
- ess.join(SECTION_SEPARATOR)
54
- end
55
-
56
46
  # @return [Enumerable<String>]
57
47
  def extra_sections
58
48
  runner.if_respond(:help_extra_text, []) do |v|
59
- if v.is_a?(::Hash)
60
- v.map do |title, lines|
61
- ::EacCli::RunnerWith::Help::ListSection.new(title, lines)
62
- end
63
- else
64
- [v.to_s]
65
- end
49
+ [v.to_s]
66
50
  end
67
51
  end
68
52
 
69
53
  def option_definition(option)
70
54
  [self.class.option_usage_full(option), option.description,
71
55
  option.default_value? ? "[Default: \"#{option.default_value}\"]" : nil]
72
- .reject(&:blank?).join(OPTION_DESC_SEP)
56
+ .reject(&:blank?).join(OPTION_DESCRIPTION_SEPARATOR)
73
57
  end
74
58
 
75
59
  # @return [String]
76
60
  def options_section
77
- ::EacCli::RunnerWith::Help::ListSection.new(
61
+ list_section(
78
62
  'Options',
79
63
  definition.alternatives.flat_map(&:options).map { |option| option_definition(option) }
80
64
  )
@@ -82,16 +66,14 @@ module EacCli
82
66
 
83
67
  # @return [String]
84
68
  def usage_section
85
- ::EacCli::RunnerWith::Help::ListSection.new(
69
+ list_section(
86
70
  'Usage',
87
71
  definition.alternatives.map { |alternative| self.alternative(alternative) }
88
72
  )
89
73
  end
90
74
 
91
75
  def to_s
92
- r = ["#{definition.description}\n", usage_section, options_section]
93
- .map { |s| "#{s}#{SECTION_SEPARATOR}" }.join
94
- extra_section.if_present(r) { |v| r + v }
76
+ join_sections(definition.description, usage_section, options_section, *extra_sections)
95
77
  end
96
78
  end
97
79
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module RunnerWith
7
+ module Help
8
+ module Layout
9
+ common_concern do
10
+ include InstanceClassMethods
11
+ extend InstanceClassMethods
12
+ end
13
+
14
+ module InstanceClassMethods
15
+ WORD_SEPARATOR = ' '
16
+ IDENTATION = WORD_SEPARATOR * 2
17
+ OPTION_DESCRIPTION_SEPARATOR = IDENTATION * 2
18
+ LINE_BREAK = "\n"
19
+ SECTION_SEPARATOR = LINE_BREAK * 2
20
+
21
+ # @param title String
22
+ # @param items [Enumerable<String>]
23
+ # @return [String]
24
+ def list_section(title, items)
25
+ (["#{title}:"] + items.map { |line| "#{IDENTATION}#{line}" })
26
+ .map { |line| "#{line}\n" }.join
27
+ end
28
+
29
+ # @param sections [Enumerable<String>]
30
+ # @return [String]
31
+ def join_sections(*sections)
32
+ sections.map { |s| s.to_s.strip }.join(SECTION_SEPARATOR) + LINE_BREAK
33
+ end
34
+ end
35
+
36
+ extend InstanceClassMethods
37
+ end
38
+ end
39
+ end
40
+ end
@@ -20,6 +20,18 @@ module EacCli
20
20
  end
21
21
  end
22
22
 
23
+ # @param items [Enumerable<String>]
24
+ # @return [String]
25
+ def help_list_section(title, items)
26
+ ::EacCli::RunnerWith::Help::Layout.list_section(title, items)
27
+ end
28
+
29
+ # @param items [Enumerable<String>]
30
+ # @return [String]
31
+ def help_join_sections(*sections)
32
+ ::EacCli::RunnerWith::Help::Layout.join_sections(*sections)
33
+ end
34
+
23
35
  def help_run
24
36
  return unless show_help?
25
37
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
5
+ require 'eac_ruby_utils/acts_as_abstract'
6
6
 
7
7
  module EacCli
8
8
  module RunnerWith
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
5
+ require 'eac_ruby_utils/acts_as_abstract'
6
6
 
7
7
  module EacCli
8
8
  module RunnerWith
@@ -53,10 +53,7 @@ module EacCli
53
53
 
54
54
  # @return [Hash<String, Enumerable<String>]
55
55
  def help_extra_text
56
- {
57
- 'Subcommands' =>
58
- available_subcommands.keys.sort
59
- }
56
+ help_list_section('Subcommands', available_subcommands.keys.sort)
60
57
  end
61
58
 
62
59
  def method_missing(method_name, *arguments, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.32.0'
4
+ VERSION = '0.33.0'
5
5
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/help/layout'
4
+
5
+ ::RSpec.describe ::EacCli::RunnerWith::Help::Layout do
6
+ describe '#list_section' do
7
+ {
8
+ ['Options', ['Option A', 'Option B']] => <<~TEXT
9
+ Options:
10
+ Option A
11
+ Option B
12
+ TEXT
13
+ }.each do |source, expected|
14
+ context "when source is #{source}" do
15
+ it do
16
+ expect(described_class.list_section(*source)).to eq(expected)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -36,7 +36,6 @@ RSpec.describe ::EacCli::RunnerWith::Help do
36
36
 
37
37
  Options:
38
38
  -h --help Show help.
39
-
40
39
  OUTPUT
41
40
  end
42
41
  let(:expected_output) do
@@ -8,10 +8,10 @@ module EacRubyUtils
8
8
  #
9
9
  # Usage:
10
10
  #
11
- # require 'eac_ruby_utils/abstract_methods'
11
+ # require 'eac_ruby_utils/acts_as_abstract'
12
12
  #
13
13
  # class BaseClass
14
- # include EacRubyUtils::AbstractMethods
14
+ # include EacRubyUtils::ActsAsAbstract
15
15
  #
16
16
  # abstract_methods :mymethod
17
17
  # end
@@ -25,23 +25,44 @@ module EacRubyUtils
25
25
  # end
26
26
  #
27
27
  # SubClass.new.mymethod # return "Implemented"
28
- module AbstractMethods
28
+ module ActsAsAbstract
29
29
  common_concern
30
30
 
31
31
  class << self
32
32
  def abstract?(a_class)
33
- a_class.self_included_modules.include?(::EacRubyUtils::AbstractMethods)
33
+ a_class.self_included_modules.include?(::EacRubyUtils::ActsAsAbstract)
34
34
  end
35
35
  end
36
36
 
37
37
  module ClassMethods
38
+ # @param name [Symbol]
39
+ # @param arguments [Enumerable<Symbol>]
40
+ # @return [void]
41
+ def abstract_method(name, *arguments)
42
+ define_method name.to_sym do |*_the_args|
43
+ raise_abstract_method(name.to_sym, arguments)
44
+ end
45
+ end
46
+
47
+ # @param methods_names [Enumerable<Object>] Each item can be a symbolizable or a hash.
48
+ # @return [void]
38
49
  def abstract_methods(*methods_names)
39
50
  methods_names.each do |method_name|
40
- define_method method_name do
41
- raise_abstract_method(method_name)
51
+ if method_name.is_a?(::Hash)
52
+ abstract_methods_from_hash(method_name)
53
+ else
54
+ abstract_method(method_name)
42
55
  end
43
56
  end
44
57
  end
58
+
59
+ private
60
+
61
+ # @param hash [Hash]
62
+ # @return [void]
63
+ def abstract_methods_from_hash(hash)
64
+ hash.each { |name, arguments| abstract_method(name, *arguments) }
65
+ end
45
66
  end
46
67
 
47
68
  module InstanceMethods
@@ -59,9 +80,9 @@ module EacRubyUtils
59
80
  self.class.abstract_methods.include?(method_name.to_sym)
60
81
  end
61
82
 
62
- def raise_abstract_method(method_name)
63
- raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\"" \
64
- " (Class: #{self.class})"
83
+ def raise_abstract_method(method_name, arguments = [])
84
+ raise ::NoMethodError, "Abstract method #{method_name}(#{arguments.join(', ')}) hit in " \
85
+ "#{self}\" (Class: #{self.class})"
65
86
  end
66
87
  end
67
88
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/abstract_methods'
3
+ require 'eac_ruby_utils/acts_as_abstract'
4
4
 
5
5
  class Class
6
6
  def abstract?
7
- ::EacRubyUtils::AbstractMethods.abstract?(self)
7
+ ::EacRubyUtils::ActsAsAbstract.abstract?(self)
8
8
  end
9
9
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/abstract_methods'
3
+ require 'eac_ruby_utils/patches/module/acts_as_abstract'
4
4
 
5
5
  class Module
6
+ # @deprecated Use {#acts_as_abstract} instead.
6
7
  def enable_abstract_methods(*methods)
7
- include ::EacRubyUtils::AbstractMethods
8
- abstract_methods(*methods)
8
+ acts_as_abstract(*methods)
9
9
  end
10
10
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/acts_as_abstract'
4
+
5
+ class Module
6
+ # Include [EacRubyUtils::ActsAsAbstract] and perform EacRubyUtils::ActsAsAbstract.abstract_methods
7
+ # on parameter +methods+.
8
+ # @param methods [Array<Symbol>]
9
+ # @return [void]
10
+ def acts_as_abstract(*methods)
11
+ include ::EacRubyUtils::ActsAsAbstract
12
+ abstract_methods(*methods)
13
+ end
14
+ end
@@ -3,7 +3,11 @@
3
3
  require 'pathname'
4
4
 
5
5
  class Pathname
6
+ # @param suffix [String]
7
+ # @return [Pathname]
6
8
  def basename_sub(suffix = '')
7
- parent.join(yield(basename(suffix)))
9
+ new_basename = basename(suffix)
10
+ new_basename = yield(new_basename) if block_given?
11
+ parent.join(new_basename)
8
12
  end
9
13
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/abstract_methods'
3
+ require 'eac_ruby_utils/acts_as_abstract'
4
4
 
5
5
  module EacRubyUtils
6
6
  module Speaker
7
7
  module Receiver
8
8
  extend ::ActiveSupport::Concern
9
- extend ::EacRubyUtils::AbstractMethods
9
+ extend ::EacRubyUtils::ActsAsAbstract
10
10
 
11
11
  module ClassMethods
12
12
  def on(*args, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.113.0'
4
+ VERSION = '0.115.0'
5
5
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/abstract_methods'
3
+ require 'eac_ruby_utils/acts_as_abstract'
4
4
 
5
- RSpec.describe(::EacRubyUtils::AbstractMethods) do
5
+ RSpec.describe(::EacRubyUtils::ActsAsAbstract) do
6
6
  let(:base_class) do
7
7
  the_module = described_class
8
8
  ::Class.new do
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/patches/class/abstract'
5
5
  RSpec.describe ::Class do
6
6
  let(:abstract_class) do
7
7
  described_class.new do
8
- enable_abstract_methods
8
+ acts_as_abstract
9
9
  end
10
10
  end
11
11
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/acts_as_abstract'
4
+ require 'eac_ruby_utils/patches/module/acts_as_abstract'
5
+
6
+ ::RSpec.describe ::Class do
7
+ let(:stub_class) do
8
+ described_class.new { acts_as_abstract }
9
+ end
10
+
11
+ describe '#acts_as_abstract' do
12
+ it { expect(stub_class.included_modules).to include(::EacRubyUtils::ActsAsAbstract) }
13
+ end
14
+ end