avm-tools 0.116.2 → 0.117.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +0 -2
  3. data/lib/avm/tools/runner/app_src/version_bump.rb +4 -9
  4. data/lib/avm/tools/version.rb +1 -1
  5. data/sub/avm/avm.gemspec +1 -1
  6. data/sub/avm/lib/avm/scms/base.rb +13 -0
  7. data/sub/avm/lib/avm/sources/base/configuration.rb +2 -1
  8. data/sub/avm/lib/avm/sources/base/parent.rb +31 -0
  9. data/sub/avm/lib/avm/sources/base.rb +4 -6
  10. data/sub/avm/lib/avm/sources/configuration/{_locale.rb → locale.rb} +5 -3
  11. data/sub/avm/lib/avm/sources/configuration/rubocop.rb +26 -0
  12. data/sub/avm/lib/avm/sources/configuration/tests.rb +29 -0
  13. data/sub/avm/lib/avm/sources/configuration.rb +5 -1
  14. data/sub/avm/lib/avm/version.rb +1 -1
  15. data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +1 -1
  16. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base/version_bump.rb +35 -0
  17. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +4 -1
  18. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
  19. data/sub/avm-eac_generic_base0/locale/en.yaml +6 -0
  20. data/sub/avm-eac_generic_base0/locale/pt-BR.yaml +6 -0
  21. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +1 -1
  22. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb +56 -0
  23. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb +19 -0
  24. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb +34 -0
  25. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb +11 -0
  26. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +23 -0
  27. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +11 -0
  28. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -1
  29. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  30. data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +1 -3
  31. data/sub/avm-git/lib/avm/git/version.rb +1 -1
  32. data/sub/eac_cli/eac_cli.gemspec +1 -1
  33. data/sub/eac_cli/lib/eac_cli/definition.rb +0 -4
  34. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +1 -1
  35. data/sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb +9 -22
  36. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +50 -0
  37. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +0 -9
  38. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +12 -5
  39. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +15 -6
  40. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +2 -2
  41. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  42. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  43. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +26 -17
  44. data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +4 -1
  45. data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +2 -2
  46. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  47. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -2
  48. data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
  49. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
  50. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
  51. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
  52. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
  53. data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
  54. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +2 -25
  55. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
  56. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +86 -33
  57. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  58. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
  59. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
  60. metadata +31 -12
  61. data/lib/avm/projects/stereotypes/rails_application/update.rb +0 -14
  62. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +0 -60
  63. data/sub/avm/lib/avm/sources/configuration/_rubocop.rb +0 -24
  64. data/sub/avm/lib/avm/sources/configuration/_tests.rb +0 -27
  65. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb +0 -7
  66. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches.rb +0 -4
  67. data/sub/eac_cli/lib/eac_cli/definition/help_formatter.rb +0 -77
@@ -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
- private
38
+ def base
39
+ options[OPTION_BASE] || raise('Option :base not setted')
40
+ end
30
41
 
31
- def active_support_require(path)
32
- return false unless options[OPTION_REQUIRE_DEPENDENCY]
42
+ def base?
43
+ options[OPTION_BASE] ? true : false
44
+ end
33
45
 
34
- ::Kernel.require_dependency(path)
35
- true
46
+ def include_modules
47
+ sub_files.each(&:include_module)
36
48
  end
37
49
 
38
- def autoload_require(path)
39
- return false unless base?
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
- basename = ::File.basename(path, '.*')
42
- return false if basename.start_with?('_')
54
+ raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
55
+ " \"#{options[OPTION_INCLUDE_MODULES]}\""
56
+ end
43
57
 
44
- base.autoload ::ActiveSupport::Inflector.camelize(basename), path
45
- true
58
+ def require_sub_files
59
+ sub_files.each(&:require_file)
46
60
  end
47
61
 
48
- def include_modules
49
- return unless options[OPTION_INCLUDE_MODULES]
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
- base.constants.each do |constant_name|
52
- constant = base.const_get(constant_name)
53
- next unless constant.is_a?(::Module) && !constant.is_a?(::Class)
67
+ class SubFile
68
+ attr_reader :owner, :path
54
69
 
55
- base.include(constant)
70
+ def initialize(owner, path)
71
+ @owner = owner
72
+ @path = path
56
73
  end
57
- end
58
74
 
59
- def base
60
- options[OPTION_BASE] || raise('Option :base not setted')
61
- end
75
+ def base_constant
76
+ return nil unless owner.base?
62
77
 
63
- def base?
64
- options[OPTION_BASE] ? true : false
65
- end
78
+ owner.base.const_get(constant_name)
79
+ rescue ::NameError
80
+ nil
81
+ end
66
82
 
67
- def kernel_require(path)
68
- ::Kernel.require(path)
69
- end
83
+ def constant_name
84
+ ::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
85
+ end
70
86
 
71
- def require_sub_files
72
- Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort.each do |path|
73
- require_sub_file(path)
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
- def require_sub_file(path)
78
- active_support_require(path) || autoload_require(path) || kernel_require(path)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.94.2'
4
+ VERSION = '0.95.1'
5
5
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/method_class'
4
+
5
+ ::RSpec.describe ::EacRubyUtils::MethodClass do
6
+ let(:sender_class) do
7
+ ::Class.new do
8
+ attr_accessor :sender_value
9
+
10
+ def initialize(sender_value)
11
+ self.sender_value = sender_value
12
+ end
13
+ end
14
+ end
15
+
16
+ let(:method_class) do
17
+ the_described_class = described_class
18
+ ::Class.new do
19
+ def self.name
20
+ 'TheSender::PerformX'
21
+ end
22
+
23
+ include the_described_class
24
+ attr_accessor :sender, :method_param
25
+
26
+ def initialize(sender, method_param)
27
+ self.sender = sender
28
+ self.method_param = method_param
29
+ end
30
+
31
+ def result
32
+ "#{sender.sender_value},#{method_param}"
33
+ end
34
+ end
35
+ end
36
+
37
+ let(:sender_instance) { sender_class.new('AAA') }
38
+
39
+ before do
40
+ ::Object.const_set('TheSender', sender_class)
41
+ sender_class.const_set('PerformX', method_class)
42
+ end
43
+
44
+ it { expect(sender_instance).to respond_to(:perform_x) }
45
+ it { expect(sender_instance.perform_x('BBB')).to eq('AAA,BBB') }
46
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/method_class'
4
+ require 'eac_ruby_utils/patches/module/method_class'
5
+
6
+ RSpec.describe ::Class do
7
+ let(:stub_method_class) do
8
+ described_class.new do
9
+ def self.name
10
+ 'StubMethodClass'
11
+ end
12
+
13
+ enable_method_class
14
+ end
15
+ end
16
+
17
+ describe '#enable_simple_cache' do
18
+ it { expect(stub_method_class.included_modules).to include(::EacRubyUtils::MethodClass) }
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.116.2
4
+ version: 0.117.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-06 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -194,14 +194,20 @@ dependencies:
194
194
  requirements:
195
195
  - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: '0.14'
197
+ version: '0.16'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 0.16.4
198
201
  type: :runtime
199
202
  prerelease: false
200
203
  version_requirements: !ruby/object:Gem::Requirement
201
204
  requirements:
202
205
  - - "~>"
203
206
  - !ruby/object:Gem::Version
204
- version: '0.14'
207
+ version: '0.16'
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: 0.16.4
205
211
  - !ruby/object:Gem::Dependency
206
212
  name: eac_ruby_gems_utils
207
213
  requirement: !ruby/object:Gem::Requirement
@@ -354,12 +360,10 @@ files:
354
360
  - lib/avm/projects/stereotypes/git_subtree/warp.rb
355
361
  - lib/avm/projects/stereotypes/rails_application.rb
356
362
  - lib/avm/projects/stereotypes/rails_application/local_project_mixin.rb
357
- - lib/avm/projects/stereotypes/rails_application/update.rb
358
363
  - lib/avm/projects/stereotypes/redmine_plugin.rb
359
364
  - lib/avm/projects/stereotypes/ruby_gem.rb
360
365
  - lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb
361
366
  - lib/avm/projects/stereotypes/ruby_gem/publish.rb
362
- - lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
363
367
  - lib/avm/rails.rb
364
368
  - lib/avm/ruby.rb
365
369
  - lib/avm/ruby/bundler.rb
@@ -459,8 +463,11 @@ files:
459
463
  - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0.rb
460
464
  - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources.rb
461
465
  - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb
466
+ - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base/version_bump.rb
462
467
  - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/tester.rb
463
468
  - sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb
469
+ - sub/avm-eac_generic_base0/locale/en.yaml
470
+ - sub/avm-eac_generic_base0/locale/pt-BR.yaml
464
471
  - sub/avm-eac_generic_base0/spec/lib/avm/eac_generic_base0/sources/base_spec.rb
465
472
  - sub/avm-eac_generic_base0/spec/rubocop_spec.rb
466
473
  - sub/avm-eac_generic_base0/spec/spec_helper.rb
@@ -541,14 +548,17 @@ files:
541
548
  - sub/avm-eac_ruby_base1/Gemfile
542
549
  - sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec
543
550
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1.rb
544
- - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches.rb
545
- - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb
551
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb
552
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb
553
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb
554
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb
546
555
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb
547
556
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb
548
557
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb
549
558
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb
550
559
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources.rb
551
560
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb
561
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb
552
562
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb
553
563
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb
554
564
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb
@@ -762,11 +772,12 @@ files:
762
772
  - sub/avm/lib/avm/sources/base.rb
763
773
  - sub/avm/lib/avm/sources/base/configuration.rb
764
774
  - sub/avm/lib/avm/sources/base/instance.rb
775
+ - sub/avm/lib/avm/sources/base/parent.rb
765
776
  - sub/avm/lib/avm/sources/base/testing.rb
766
777
  - sub/avm/lib/avm/sources/configuration.rb
767
- - sub/avm/lib/avm/sources/configuration/_locale.rb
768
- - sub/avm/lib/avm/sources/configuration/_rubocop.rb
769
- - sub/avm/lib/avm/sources/configuration/_tests.rb
778
+ - sub/avm/lib/avm/sources/configuration/locale.rb
779
+ - sub/avm/lib/avm/sources/configuration/rubocop.rb
780
+ - sub/avm/lib/avm/sources/configuration/tests.rb
770
781
  - sub/avm/lib/avm/sources/tester.rb
771
782
  - sub/avm/lib/avm/sources/tests.rb
772
783
  - sub/avm/lib/avm/sources/tests/builder.rb
@@ -795,7 +806,6 @@ files:
795
806
  - sub/eac_cli/lib/eac_cli/definition/base_option.rb
796
807
  - sub/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb
797
808
  - sub/eac_cli/lib/eac_cli/definition/boolean_option.rb
798
- - sub/eac_cli/lib/eac_cli/definition/help_formatter.rb
799
809
  - sub/eac_cli/lib/eac_cli/definition/positional_argument.rb
800
810
  - sub/eac_cli/lib/eac_cli/enum.rb
801
811
  - sub/eac_cli/lib/eac_cli/old_configs.rb
@@ -821,6 +831,7 @@ files:
821
831
  - sub/eac_cli/lib/eac_cli/rspec/setup.rb
822
832
  - sub/eac_cli/lib/eac_cli/runner.rb
823
833
  - sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb
834
+ - sub/eac_cli/lib/eac_cli/runner/class_runner.rb
824
835
  - sub/eac_cli/lib/eac_cli/runner/context.rb
825
836
  - sub/eac_cli/lib/eac_cli/runner/exit.rb
826
837
  - sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
@@ -1281,6 +1292,11 @@ files:
1281
1292
  - sub/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb
1282
1293
  - sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
1283
1294
  - sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb
1295
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb
1296
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb
1297
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb
1298
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb
1299
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb
1284
1300
  - sub/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb
1285
1301
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patch.rb
1286
1302
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches.rb
@@ -1308,6 +1324,7 @@ files:
1308
1324
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb
1309
1325
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb
1310
1326
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/listable.rb
1327
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb
1311
1328
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb
1312
1329
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb
1313
1330
  - sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/simple_cache.rb
@@ -1380,6 +1397,7 @@ files:
1380
1397
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb
1381
1398
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb
1382
1399
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb
1400
+ - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb
1383
1401
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
1384
1402
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb
1385
1403
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb
@@ -1390,6 +1408,7 @@ files:
1390
1408
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb
1391
1409
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/compare_by_spec.rb
1392
1410
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb
1411
+ - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb
1393
1412
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb
1394
1413
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb
1395
1414
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/projects/stereotypes/ruby_gem/update'
4
-
5
- module Avm
6
- module Projects
7
- module Stereotypes
8
- class RailsApplication
9
- class Update < ::Avm::Projects::Stereotypes::RubyGem::Update
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/patches/i18n'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module Projects
8
- module Stereotypes
9
- class RubyGem
10
- class VersionBump
11
- enable_speaker
12
- common_constructor :instance, :target_version
13
-
14
- def run
15
- git_checkout
16
- change_version
17
- bundle_run
18
- git_commit
19
- end
20
-
21
- private
22
-
23
- def bundle_run
24
- infom 'Running "bundle install"...'
25
- instance.ruby_gem.bundle('install').execute!
26
- end
27
-
28
- def change_version
29
- infom 'Setting project version...'
30
- instance.version = target_version
31
- end
32
-
33
- def git_checkout
34
- return unless instance.respond_to?(:git_repo)
35
-
36
- infom "Checkouting #{changing_files.map(&:to_path).join(', ')}..."
37
- instance.git_repo.command('checkout', '--',
38
- *changing_files.map(&:to_path)).execute!
39
- end
40
-
41
- def git_commit
42
- return unless instance.respond_to?(:git_repo)
43
-
44
- infom "Commiting #{changing_files.map(&:to_path).join(', ')}..."
45
- instance.git_repo.command('commit', '-m', git_commit_message, '--',
46
- *changing_files.map(&:to_path)).execute!
47
- end
48
-
49
- def git_commit_message
50
- i18n_translate(__method__, version: target_version, __locale: instance.locale)
51
- end
52
-
53
- def changing_files
54
- [instance.ruby_gem.gemfile_lock_path, instance.ruby_gem.version_file_path]
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Sources
5
- class Configuration < ::EacConfig::OldConfigs
6
- RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
7
- RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
8
-
9
- def rubocop_command
10
- read_command(RUBOCOP_COMMAND_KEY)
11
- end
12
-
13
- def rubocop_gemfile
14
- gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
15
- return nil if gemfile_path.blank?
16
-
17
- gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
18
- return gemfile_path if gemfile_path.file?
19
-
20
- raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/patches/eac_ruby_gems_utils/gem'
4
-
5
- module Avm
6
- module Sources
7
- class Configuration < ::EacConfig::OldConfigs
8
- BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
9
- TEST_COMMAND_KEY = 'test.command'
10
-
11
- def any_test_command
12
- bundle_test_command || test_command
13
- end
14
-
15
- def test_command
16
- read_command(TEST_COMMAND_KEY)
17
- end
18
-
19
- def bundle_test_command
20
- read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
21
- args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
22
- ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'i18n'
5
-
6
- ::I18n.load_path += __dir__.to_pathname.expand_path.parent_n(4).join('locale').glob('*.yaml')
7
- .map(&:to_path)
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/help/builder/alternative'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module EacCli
7
- class Definition
8
- class HelpFormatter
9
- SEP = ' '
10
- IDENT = SEP * 2
11
- OPTION_DESC_SEP = IDENT * 2
12
-
13
- class << self
14
- def option_long(option)
15
- b = option.long
16
- b += '=VALUE' if option.argument?
17
- b
18
- end
19
-
20
- def option_short(option)
21
- b = option.short
22
- b += 'VALUE' if option.argument?
23
- b
24
- end
25
- end
26
-
27
- common_constructor :definition
28
-
29
- def positional_argument(positional)
30
- if positional.subcommand?
31
- ::EacCli::RunnerWith::Help::Builder::Alternative::SUBCOMMANDS_MACRO
32
- else
33
- r = "<#{positional.name}>"
34
- r += '...' if positional.repeat?
35
- r = "[#{r}]" if positional.optional?
36
- r
37
- end
38
- end
39
-
40
- def section(header, include_header = true)
41
- b = include_header ? "#{header.humanize}:\n" : ''
42
- b += send("self_#{header}") + "\n"
43
- # TO-DO: implement alternatives
44
- b
45
- end
46
-
47
- def self_options
48
- definition.options.map { |option| IDENT + option_definition(option) }.join("\n")
49
- end
50
-
51
- def self_usage
52
- IDENT + self_usage_arguments.join(SEP)
53
- end
54
-
55
- def self_usage_arguments
56
- [::EacCli::RunnerWith::Help::Builder::Alternative::PROGRAM_MACRO] +
57
- definition.options_argument.if_present([]) { |_v| ['[options]'] } +
58
- self_usage_arguments_options +
59
- self_usage_arguments_positional
60
- end
61
-
62
- def self_usage_arguments_options
63
- definition.options.select(&:show_on_usage?).map do |option|
64
- self.class.option_long(option)
65
- end
66
- end
67
-
68
- def self_usage_arguments_positional
69
- definition.positional.map { |p| positional_argument(p) }
70
- end
71
-
72
- def to_banner
73
- "#{definition.description}\n\n#{section('usage')}"
74
- end
75
- end
76
- end
77
- end