avm-tools 0.76.1 → 0.81.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  3. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  4. data/lib/avm/patches/class/i18n.rb +31 -0
  5. data/lib/avm/patches/object/i18n.rb +2 -10
  6. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
  7. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
  8. data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
  9. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  10. data/lib/avm/tools/version.rb +1 -1
  11. data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
  12. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  13. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  14. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  15. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  16. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  17. data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
  18. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
  19. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  20. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  21. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  22. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  23. data/vendor/eac_cli/lib/eac_cli/runner.rb +12 -4
  24. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  25. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +16 -1
  26. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  27. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  29. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  30. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  31. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  32. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +17 -5
  33. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  34. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  35. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -1
  36. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
  37. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
  38. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  48. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  49. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  50. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  51. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  52. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  53. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  54. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  56. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  57. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  58. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  59. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  60. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  61. metadata +28 -7
  62. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  63. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
  64. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  65. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  66. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
@@ -8,7 +8,6 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
8
8
  the_module = described_class
9
9
  the_child = child_runner
10
10
  Class.new do
11
- include ::EacCli::Runner
12
11
  include the_module
13
12
  const_set('ChildCmd', the_child)
14
13
 
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/filesystem_cache'
4
5
 
5
6
  module EacRubyBase0
6
7
  class Application
7
8
  enable_simple_cache
8
- common_constructor :gemspec_dir do
9
+ enable_listable
10
+ lists.add_symbol :option, :name, :home_dir
11
+
12
+ common_constructor :gemspec_dir, :options, default: [{}] do
9
13
  self.gemspec_dir = gemspec_dir.to_pathname
14
+ self.options = options.symbolize_keys.assert_valid_keys(self.class.lists.option.values).freeze
10
15
  end
11
16
 
12
17
  delegate :version, to: :self_gem
@@ -15,6 +20,32 @@ module EacRubyBase0
15
20
  vendor_gems + [self_gem]
16
21
  end
17
22
 
23
+ { cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
24
+ xdg_env_method_name = "#{item}_xdg_env"
25
+
26
+ define_method xdg_env_method_name do
27
+ ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
28
+ end
29
+
30
+ define_method "#{item}_dir" do
31
+ (send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
32
+ end
33
+ end
34
+
35
+ def fs_cache
36
+ @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(
37
+ cache_dir.join(::EacRubyUtils::FilesystemCache.name.parameterize)
38
+ )
39
+ end
40
+
41
+ def home_dir
42
+ @home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
43
+ end
44
+
45
+ def name
46
+ options[OPTION_NAME] || self_gem.name
47
+ end
48
+
18
49
  def vendor_dir
19
50
  gemspec_dir.join('vendor')
20
51
  end
@@ -13,7 +13,7 @@ module EacRubyBase0
13
13
  bool_opt '-I', '--no-input', 'Fail if a input is requested.'
14
14
  subcommands
15
15
  alt do
16
- bool_opt '-V', '--version', 'Show version.'
16
+ bool_opt '-V', '--version', 'Show version.', usage: true, required: true
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/common_concern'
4
+
5
+ module EacRubyUtils
6
+ # Support to abstract methods.
7
+ #
8
+ # Usage:
9
+ #
10
+ # require 'eac_ruby_utils/abstract_methods'
11
+ #
12
+ # class BaseClass
13
+ # include EacRubyUtils::AbstractMethods
14
+ #
15
+ # abstract_methods :mymethod
16
+ # end
17
+ #
18
+ # BaseClass.new.mymethod # raise "Abstract method: mymethod"
19
+ #
20
+ # class SubClass
21
+ # def mymethod
22
+ # "Implemented"
23
+ # end
24
+ # end
25
+ #
26
+ # SubClass.new.mymethod # return "Implemented"
27
+ module AbstractMethods
28
+ common_concern
29
+
30
+ module ClassMethods
31
+ def abstract_methods(*methods_names)
32
+ methods_names.each do |method_name|
33
+ define_method method_name do
34
+ raise_abstract_method(method_name)
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ module InstanceMethods
41
+ def respond_to_missing?(method_name, include_private = false)
42
+ super || abstract_method?(method_name)
43
+ end
44
+
45
+ def method_missing(method_name, *arguments, &block)
46
+ raise_abstract_method(method_name) if abstract_method?(method_name)
47
+
48
+ super
49
+ end
50
+
51
+ def abstract_method?(method_name)
52
+ self.class.abstract_methods.include?(method_name.to_sym)
53
+ end
54
+
55
+ def raise_abstract_method(method_name)
56
+ raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\""
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/concern'
4
- require 'eac_ruby_utils/simple_cache'
5
- require 'eac_ruby_utils/patches/object/if_present'
3
+ require 'eac_ruby_utils/common_concern/module_setup'
6
4
 
7
5
  module EacRubyUtils
8
6
  class CommonConcern
@@ -16,53 +14,7 @@ module EacRubyUtils
16
14
  end
17
15
 
18
16
  def setup(a_module)
19
- Setup.new(self, a_module).run
20
- end
21
-
22
- class Setup
23
- include ::EacRubyUtils::SimpleCache
24
- attr_reader :a_module, :common_concern
25
-
26
- def initialize(common_concern, a_module)
27
- @common_concern = common_concern
28
- @a_module = a_module
29
- end
30
-
31
- def run
32
- setup = self
33
- a_module.extend(::ActiveSupport::Concern)
34
- a_module.included do
35
- %w[class_methods instance_methods after_callback].each do |suffix|
36
- setup.send("setup_#{suffix}", self)
37
- end
38
- end
39
- end
40
-
41
- def setup_class_methods(base)
42
- class_methods_module.if_present { |v| base.extend v }
43
- end
44
-
45
- def setup_instance_methods(base)
46
- instance_methods_module.if_present { |v| base.include v }
47
- end
48
-
49
- def setup_after_callback(base)
50
- common_concern.after_callback.if_present do |v|
51
- base.instance_eval(&v)
52
- end
53
- end
54
-
55
- def class_methods_module_uncached
56
- a_module.const_get(CLASS_METHODS_MODULE_NAME)
57
- rescue NameError
58
- nil
59
- end
60
-
61
- def instance_methods_module_uncached
62
- a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
63
- rescue NameError
64
- nil
65
- end
17
+ ::EacRubyUtils::CommonConcern::ModuleSetup.new(self, a_module).run
66
18
  end
67
19
  end
68
20
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'eac_ruby_utils/simple_cache'
5
+ require 'eac_ruby_utils/patches/object/if_present'
6
+
7
+ module EacRubyUtils
8
+ class CommonConcern
9
+ class ClassSetup
10
+ include ::EacRubyUtils::SimpleCache
11
+ attr_reader :a_class, :module_setup, :include_method
12
+
13
+ def initialize(module_setup, a_class, include_method)
14
+ @module_setup = module_setup
15
+ @a_class = a_class
16
+ @include_method = include_method
17
+ end
18
+
19
+ def run
20
+ %w[class_methods instance_methods after_callback].each do |suffix|
21
+ send("setup_#{suffix}")
22
+ end
23
+ end
24
+
25
+ def setup_class_methods
26
+ class_methods_module.if_present { |v| a_class.extend v }
27
+ end
28
+
29
+ def setup_instance_methods
30
+ instance_methods_module.if_present { |v| a_class.send(include_method, v) }
31
+ end
32
+
33
+ def setup_after_callback
34
+ module_setup.common_concern.after_callback.if_present do |v|
35
+ a_class.instance_eval(&v)
36
+ end
37
+ end
38
+
39
+ def class_methods_module_uncached
40
+ module_setup.a_module.const_get(CLASS_METHODS_MODULE_NAME)
41
+ rescue NameError
42
+ nil
43
+ end
44
+
45
+ def instance_methods_module_uncached
46
+ module_setup.a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
47
+ rescue NameError
48
+ nil
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'eac_ruby_utils/common_concern/class_setup'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'eac_ruby_utils/patches/object/if_present'
7
+
8
+ module EacRubyUtils
9
+ class CommonConcern
10
+ class ModuleSetup
11
+ include ::EacRubyUtils::SimpleCache
12
+ attr_reader :a_module, :common_concern
13
+
14
+ def initialize(common_concern, a_module)
15
+ @common_concern = common_concern
16
+ @a_module = a_module
17
+ end
18
+
19
+ def run
20
+ setup = self
21
+ a_module.extend(::ActiveSupport::Concern)
22
+ a_module.included do
23
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :include).run
24
+ end
25
+ a_module.prepended do
26
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :prepend).run
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -61,6 +61,8 @@ module EacRubyUtils
61
61
  setup_class_attr_readers(klass)
62
62
  setup_class_attr_writers(klass)
63
63
  setup_class_initialize(klass)
64
+
65
+ klass
64
66
  end
65
67
 
66
68
  def setup_class_attr_readers(klass)
@@ -79,9 +81,14 @@ module EacRubyUtils
79
81
  klass.define_callbacks :initialize
80
82
  klass.send(:define_method, :initialize) do |*args|
81
83
  Initialize.new(common_constructor, args, self).run
84
+ super(*SuperArgs.new(common_constructor, args, self).result)
82
85
  end
83
86
  end
84
87
 
88
+ def super_args
89
+ options[:super_args]
90
+ end
91
+
85
92
  class Initialize
86
93
  attr_reader :common_constructor, :args, :object
87
94
 
@@ -129,5 +136,51 @@ module EacRubyUtils
129
136
  " (given #{args.count}, expected #{common_constructor.args_count})"
130
137
  end
131
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
132
185
  end
133
186
  end
@@ -11,18 +11,10 @@ module EacRubyUtils
11
11
 
12
12
  class << self
13
13
  def entry_key_to_envvar_name(entry_key)
14
- path = if entry_key.is_a?(::Array)
15
- entry_key
16
- else
17
- ::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
18
- end
19
- path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
20
- .gsub(/_{2,}/, '_').upcase
14
+ ::EacRubyUtils::Console::Configs::EntryReader.entry_key_to_envvar_name(entry_key)
21
15
  end
22
16
  end
23
17
 
24
- STORE_PASSWORDS_KEY = 'core.store_passwords'
25
-
26
18
  attr_reader :configs
27
19
 
28
20
  def initialize(configs_key, options = {})
@@ -31,72 +23,15 @@ module EacRubyUtils
31
23
  end
32
24
 
33
25
  def read_password(entry_key, options = {})
34
- options = ReadEntryOptions.new(options.merge(noecho: true))
35
- if store_passwords?
36
- read_entry(entry_key, options)
37
- else
38
- looped_entry_value_from_input(entry_key, options)
39
- end
26
+ ::EacRubyUtils::Console::Configs::PasswordEntryReader.new(self, entry_key, options).read
40
27
  end
41
28
 
42
29
  def read_entry(entry_key, options = {})
43
- options = ReadEntryOptions.new(options)
44
- unless options[:noenv]
45
- envvar_value = envvar_read_entry(entry_key)
46
- return envvar_value if envvar_value.present?
47
- end
48
- stored_value = configs.read_entry(entry_key)
49
- return stored_value if stored_value
50
- return read_entry_from_console(entry_key, options) unless options[:noinput]
51
-
52
- raise "No value found for entry \"#{entry_key}\"" if options[:required]
30
+ ::EacRubyUtils::Console::Configs::EntryReader.new(self, entry_key, options).read
53
31
  end
54
32
 
55
33
  def store_passwords?
56
- read_entry(
57
- STORE_PASSWORDS_KEY,
58
- before_input: -> { store_password_banner },
59
- validator: ->(entry_value) { %w[yes no].include?(entry_value) }
60
- ) == 'yes'
61
- end
62
-
63
- protected
64
-
65
- def envvar_read_entry(entry_key)
66
- env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
67
- return nil unless ENV.key?(env_entry_key)
68
-
69
- ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
70
- end
71
-
72
- def read_entry_from_console(entry_key, options)
73
- options[:before_input].call if options[:before_input].present?
74
- entry_value = looped_entry_value_from_input(entry_key, options)
75
- configs.write_entry(entry_key, entry_value)
76
- entry_value
77
- end
78
-
79
- def store_password_banner
80
- infom 'Do you wanna to store passwords?'
81
- infom "Warning: the passwords will be store in clear text in \"#{configs.storage_path}\""
82
- infom 'Enter "yes" or "no"'
83
- end
84
-
85
- def looped_entry_value_from_input(entry_key, options)
86
- loop do
87
- entry_value = entry_value_from_input(entry_key, options)
88
- next if entry_value.blank?
89
- next if options[:validator] && !options[:validator].call(entry_value)
90
-
91
- return entry_value
92
- end
93
- end
94
-
95
- def entry_value_from_input(entry_key, options)
96
- entry_value = request_input("Value for entry \"#{entry_key}\"",
97
- options.request_input_options)
98
- warn('Entered value is blank') if entry_value.blank?
99
- entry_value
34
+ ::EacRubyUtils::Console::Configs::StorePasswordsEntryReader.new(self) == 'yes'
100
35
  end
101
36
  end
102
37
  end