avm-tools 0.76.1 → 0.77.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/tools/version.rb +1 -1
  3. data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
  4. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  5. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  6. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  7. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  8. data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
  9. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
  10. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  11. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  12. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  13. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  14. data/vendor/eac_cli/lib/eac_cli/runner.rb +2 -2
  15. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
  16. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  17. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  18. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  19. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  20. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +14 -5
  21. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
  22. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
  23. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  24. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +59 -0
  25. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  26. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  27. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  28. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  29. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  30. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  31. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  32. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  33. metadata +16 -5
  34. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  35. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  36. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
@@ -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,59 @@
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
+ @abstract_methods ||= Set.new
33
+ @abstract_methods += methods_names.map(&:to_sym)
34
+
35
+ @abstract_methods.to_enum
36
+ end
37
+ end
38
+
39
+ module InstanceMethods
40
+ def respond_to_missing?(method_name, include_private = false)
41
+ super || abstract_method?(method_name)
42
+ end
43
+
44
+ def method_missing(method_name, *arguments, &block)
45
+ raise_abstract_method(method_name) if abstract_method?(method_name)
46
+
47
+ super
48
+ end
49
+
50
+ def abstract_method?(method_name)
51
+ self.class.abstract_methods.include?(method_name.to_sym)
52
+ end
53
+
54
+ def raise_abstract_method(method_name)
55
+ raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\""
56
+ end
57
+ end
58
+ end
59
+ 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
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/configs/read_entry_options'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacRubyUtils
7
+ module Console
8
+ class Configs
9
+ class EntryReader
10
+ enable_console_speaker
11
+
12
+ class << self
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
21
+ end
22
+ end
23
+
24
+ common_constructor :console_configs, :entry_key, :options do
25
+ self.options = ::EacRubyUtils::Console::Configs::ReadEntryOptions.new(options)
26
+ end
27
+
28
+ def read
29
+ %w[envvars storage console].each do |suffix|
30
+ value = send("read_from_#{suffix}")
31
+ return value if value.present?
32
+ end
33
+ return nil unless options[:required]
34
+
35
+ raise "No value found for entry \"#{entry_key}\""
36
+ end
37
+
38
+ def read_from_storage
39
+ console_configs.configs.read_entry(entry_key)
40
+ end
41
+
42
+ def read_from_envvars
43
+ return if options[:noenv]
44
+
45
+ env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
46
+ return unless ENV.key?(env_entry_key)
47
+
48
+ ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
49
+ end
50
+
51
+ def read_from_console
52
+ return if options[:noinput]
53
+
54
+ options[:before_input].if_present(&:call)
55
+ entry_value = looped_entry_value_from_input
56
+ console_configs.configs.write_entry(entry_key, entry_value) if options[:store]
57
+ entry_value
58
+ end
59
+
60
+ private
61
+
62
+ def looped_entry_value_from_input
63
+ loop do
64
+ entry_value = entry_value_from_input(entry_key, options)
65
+ next if entry_value.blank?
66
+ next if options[:validator] && !options[:validator].call(entry_value)
67
+
68
+ return entry_value
69
+ end
70
+ end
71
+
72
+ def entry_value_from_input(entry_key, options)
73
+ entry_value = request_input("Value for entry \"#{entry_key}\"",
74
+ options.request_input_options)
75
+ warn('Entered value is blank') if entry_value.blank?
76
+ entry_value
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/configs/entry_reader'
4
+
5
+ module EacRubyUtils
6
+ module Console
7
+ class Configs
8
+ class PasswordEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
9
+ ENTRY_KEY = 'core.store_passwords'
10
+
11
+ def initialize(console_configs, entry_key, options = {})
12
+ super(console_configs, entry_key, options.merge(noecho: true,
13
+ store: console_configs.store_passwords?))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,13 +7,18 @@ module EacRubyUtils
7
7
  class Configs
8
8
  class ReadEntryOptions
9
9
  enable_simple_cache
10
- common_constructor :options
10
+ common_constructor :options do
11
+ self.options = options.to_h.symbolize_keys
12
+ .assert_valid_keys(DEFAULT_VALUES.keys).freeze
13
+ end
11
14
 
12
15
  DEFAULT_VALUES = {
13
16
  before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
14
- required: true, validator: nil
17
+ required: true, store: true, validator: nil
15
18
  }.freeze
16
19
 
20
+ delegate :to_h, to: :options
21
+
17
22
  def [](key)
18
23
  values.fetch(key.to_sym)
19
24
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/configs/entry_reader'
4
+
5
+ module EacRubyUtils
6
+ module Console
7
+ class Configs
8
+ class StorePasswordsEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
9
+ ENTRY_KEY = 'core.store_passwords'
10
+
11
+ def initialize(console_configs)
12
+ super(console_configs, ENTRY_KEY,
13
+ before_input: -> { banner },
14
+ validator: ->(entry_value) { %w[yes no].include?(entry_value) }
15
+ )
16
+ end
17
+
18
+ def banner
19
+ infom 'Do you wanna to store passwords?'
20
+ infom 'Warning: the passwords will be store in clear text in ' \
21
+ "\"#{console_configs.configs.storage_path}\""
22
+ infom 'Enter "yes" or "no"'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.51.0'
4
+ VERSION = '0.52.0'
5
5
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
3
4
  require 'yaml'
4
5
 
5
6
  module EacRubyUtils
6
7
  # A safe YAML loader/dumper with common types included.
7
8
  class Yaml
8
9
  class << self
9
- DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::FalseClass, ::Hash, ::NilClass, ::Numeric,
10
- ::String, ::Symbol, ::Time, ::TrueClass].freeze
10
+ DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::DateTime, ::FalseClass, ::Hash, ::NilClass,
11
+ ::Numeric, ::String, ::Symbol, ::Time, ::TrueClass].freeze
11
12
 
12
13
  def dump(object)
13
14
  ::YAML.dump(sanitize(object))
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ RSpec.describe(::EacRubyUtils::AbstractMethods) do
6
+ let(:base_class) do
7
+ the_module = described_class
8
+ ::Class.new do
9
+ include the_module
10
+
11
+ abstract_methods :method1, :method2
12
+ end
13
+ end
14
+ let(:base_instance) { base_class.new }
15
+ let(:sub_class) do
16
+ ::Class.new(base_class) do
17
+ def method1
18
+ 'a result'
19
+ end
20
+ end
21
+ end
22
+ let(:sub_instance) { sub_class.new }
23
+
24
+ it { expect { base_instance.method1 }.to raise_error(::NoMethodError) }
25
+ it { expect { base_instance.method2 }.to raise_error(::NoMethodError) }
26
+ it { expect(sub_instance.method1).to eq('a result') }
27
+ it { expect { sub_instance.method2 }.to raise_error(::NoMethodError) }
28
+ 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.76.1
4
+ version: 0.77.0
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: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -598,19 +598,23 @@ files:
598
598
  - vendor/eac_cli/lib/eac_cli/core_ext.rb
599
599
  - vendor/eac_cli/lib/eac_cli/default_runner.rb
600
600
  - vendor/eac_cli/lib/eac_cli/definition.rb
601
+ - vendor/eac_cli/lib/eac_cli/definition/alternative.rb
601
602
  - vendor/eac_cli/lib/eac_cli/definition/argument_option.rb
602
603
  - vendor/eac_cli/lib/eac_cli/definition/base_option.rb
603
604
  - vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb
604
605
  - vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb
605
606
  - vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb
606
607
  - vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb
608
+ - vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb
607
609
  - vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
608
610
  - vendor/eac_cli/lib/eac_cli/parser.rb
611
+ - vendor/eac_cli/lib/eac_cli/parser/alternative.rb
612
+ - vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb
613
+ - vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb
614
+ - vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb
615
+ - vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb
609
616
  - vendor/eac_cli/lib/eac_cli/parser/collector.rb
610
617
  - vendor/eac_cli/lib/eac_cli/parser/error.rb
611
- - vendor/eac_cli/lib/eac_cli/parser/options_collection.rb
612
- - vendor/eac_cli/lib/eac_cli/parser/parse_result.rb
613
- - vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb
614
618
  - vendor/eac_cli/lib/eac_cli/patches.rb
615
619
  - vendor/eac_cli/lib/eac_cli/patches/object.rb
616
620
  - vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb
@@ -621,7 +625,9 @@ files:
621
625
  - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
622
626
  - vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb
623
627
  - vendor/eac_cli/lib/eac_cli/version.rb
628
+ - vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb
624
629
  - vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb
630
+ - vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb
625
631
  - vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb
626
632
  - vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb
627
633
  - vendor/eac_cli/spec/rubocop_spec.rb
@@ -888,6 +894,7 @@ files:
888
894
  - vendor/eac_ruby_utils/README.rdoc
889
895
  - vendor/eac_ruby_utils/eac_ruby_utils.gemspec
890
896
  - vendor/eac_ruby_utils/lib/eac_ruby_utils.rb
897
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb
891
898
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb
892
899
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb
893
900
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb
@@ -899,7 +906,10 @@ files:
899
906
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb
900
907
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console.rb
901
908
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb
909
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb
910
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb
902
911
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
912
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb
903
913
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb
904
914
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb
905
915
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_doc.rb
@@ -1019,6 +1029,7 @@ files:
1019
1029
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb
1020
1030
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb
1021
1031
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb
1032
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb
1022
1033
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb
1023
1034
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb
1024
1035
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb