avm-tools 0.77.0 → 0.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/unit.rb +8 -3
  3. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  4. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  5. data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
  6. data/lib/avm/patches/class/i18n.rb +31 -0
  7. data/lib/avm/patches/object/i18n.rb +2 -10
  8. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
  9. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
  10. data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
  11. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  12. data/lib/avm/tools/version.rb +1 -1
  13. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  14. data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
  15. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -0
  16. data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
  17. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  18. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +15 -0
  19. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  20. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  21. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  22. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -3
  23. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  24. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  25. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -1
  26. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +5 -4
  27. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  28. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  29. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  30. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  31. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  32. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  38. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  40. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  41. metadata +14 -4
  42. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  43. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/hash/indifferent_access'
4
- require 'eac_ruby_utils/console/speaker'
5
- require 'eac_ruby_utils/envs/command/extra_options'
3
+ require 'eac_ruby_utils/core_ext'
6
4
  require 'eac_ruby_utils/envs/process'
7
5
  require 'eac_ruby_utils/envs/spawn'
8
6
  require 'pp'
@@ -11,8 +9,8 @@ require 'shellwords'
11
9
  module EacRubyUtils
12
10
  module Envs
13
11
  class Command
14
- include EacRubyUtils::Console::Speaker
15
- include EacRubyUtils::Envs::Command::ExtraOptions
12
+ require_sub __FILE__, include_modules: true
13
+ enable_console_speaker
16
14
 
17
15
  def initialize(env, command, extra_options = {})
18
16
  @env = env
@@ -47,7 +45,7 @@ module EacRubyUtils
47
45
  c = c.map { |x| escape(x) }.join(' ') if c.is_a?(Enumerable)
48
46
  append_command_options(
49
47
  @env.command_line(
50
- append_chdir(append_pipe(append_envvars(c)))
48
+ append_chdir(append_concat(append_envvars(c)))
51
49
  ),
52
50
  options
53
51
  )
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/struct'
4
+
5
+ module EacRubyUtils
6
+ module Envs
7
+ class Command
8
+ module Concat
9
+ def concat(operator, other_command)
10
+ duplicate_by_extra_options(concat: ::EacRubyUtils::Struct.new(
11
+ operator: operator, command: other_command
12
+ ))
13
+ end
14
+
15
+ def or(other_command)
16
+ concat('||', other_command)
17
+ end
18
+
19
+ def pipe(other_command)
20
+ concat('|', other_command)
21
+ end
22
+
23
+ private
24
+
25
+ def append_concat(command)
26
+ extra_options[:concat].if_present(command) do |v|
27
+ "#{command} #{v.operator} #{v.command.command}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Envs
5
+ class Command
6
+ module Envvars
7
+ def envvar(name, value)
8
+ duplicate_by_extra_options(envvars: envvars.merge(name => value))
9
+ end
10
+
11
+ private
12
+
13
+ def append_envvars(command)
14
+ e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
15
+ e.present? ? "#{e} #{command}" : command
16
+ end
17
+
18
+ def envvars
19
+ extra_options[:envvars] ||= {}.with_indifferent_access
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -12,39 +12,18 @@ module EacRubyUtils
12
12
  duplicate_by_extra_options(chdir: dir)
13
13
  end
14
14
 
15
- def envvar(name, value)
16
- duplicate_by_extra_options(envvars: envvars.merge(name => value))
17
- end
18
-
19
15
  def status_result(status_code, result)
20
16
  duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
21
17
  end
22
18
 
23
- def pipe(other_command)
24
- duplicate_by_extra_options(pipe: other_command)
25
- end
26
-
27
19
  private
28
20
 
29
21
  attr_reader :extra_options
30
22
 
31
- def envvars
32
- extra_options[:envvars] ||= {}.with_indifferent_access
33
- end
34
-
35
23
  def status_results
36
24
  extra_options[:status_results] ||= {}.with_indifferent_access
37
25
  end
38
26
 
39
- def append_envvars(command)
40
- e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
41
- e.present? ? "#{e} #{command}" : command
42
- end
43
-
44
- def append_pipe(command)
45
- extra_options[:pipe].present? ? "#{command} | #{extra_options[:pipe].command}" : command
46
- end
47
-
48
27
  def append_chdir(command)
49
28
  extra_options[:chdir].present? ? "(cd '#{extra_options[:chdir]}' ; #{command} )" : command
50
29
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ class Module
6
+ def enable_abstract_methods(*methods)
7
+ include ::EacRubyUtils::AbstractMethods
8
+ abstract_methods(*methods)
9
+ end
10
+ end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/hash_with_indifferent_access'
4
+ require 'active_support/core_ext/module/delegation'
4
5
  require 'active_support/core_ext/object/blank'
5
6
 
6
7
  module EacRubyUtils
7
8
  class Struct
8
9
  def initialize(initial_data = {})
9
- self.data = ::ActiveSupport::HashWithIndifferentAccess.new(initial_data)
10
+ self.data = initial_data.symbolize_keys
10
11
  end
11
12
 
12
13
  def [](key)
@@ -19,6 +20,11 @@ module EacRubyUtils
19
20
  bool ? fetch(key).present? : data.fetch(key)
20
21
  end
21
22
 
23
+ def merge(other)
24
+ other = self.class.new(other) unless other.is_a?(self.class)
25
+ self.class.new(to_h.merge(other.to_h))
26
+ end
27
+
22
28
  def method_missing(method_name, *arguments, &block)
23
29
  property_method?(method_name) ? fetch(method_name) : super
24
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.52.0'
4
+ VERSION = '0.55.0'
5
5
  end
@@ -9,34 +9,47 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
9
9
  end
10
10
  end
11
11
 
12
- module MyModule
13
- module ClassMethods
14
- def my_class_method
15
- 'class'
12
+ let(:stub_module) do
13
+ ::Module.new do
14
+ module ClassMethods # rubocop:disable RSpec/LeakyConstantDeclaration
15
+ def my_class_method
16
+ 'class'
17
+ end
16
18
  end
17
- end
18
19
 
19
- module InstanceMethods
20
- def my_instance_method
21
- 'instance'
20
+ module InstanceMethods # rubocop:disable RSpec/LeakyConstantDeclaration
21
+ def my_instance_method
22
+ 'instance'
23
+ end
22
24
  end
23
25
  end
24
26
  end
25
27
 
26
- class MyClass
27
- class << self
28
- attr_accessor :valor
28
+ let(:stub_class) do
29
+ ::Class.new do
30
+ class << self
31
+ attr_accessor :valor
32
+ end
33
+
34
+ def method1
35
+ 'from_stub_module'
36
+ end
29
37
  end
30
38
  end
31
39
 
32
- let(:subject) { MyClass.new }
40
+ let(:stub_class_instance) { stub_class.new }
33
41
 
34
42
  before do
35
- instance.setup(MyModule)
36
- MyClass.include MyModule
43
+ instance.setup(stub_module)
37
44
  end
38
45
 
39
- it { expect(subject.my_instance_method).to eq('instance') }
40
- it { expect(subject.class.my_class_method).to eq('class') }
41
- it { expect(subject.class.valor).to eq('changed') }
46
+ context 'when included' do
47
+ before do
48
+ stub_class.include stub_module
49
+ end
50
+
51
+ it { expect(stub_class_instance.my_instance_method).to eq('instance') }
52
+ it { expect(stub_class_instance.class.my_class_method).to eq('class') }
53
+ it { expect(stub_class_instance.class.valor).to eq('changed') }
54
+ end
42
55
  end
@@ -3,34 +3,92 @@
3
3
  require 'eac_ruby_utils/common_constructor'
4
4
 
5
5
  RSpec.describe ::EacRubyUtils::CommonConstructor do
6
- ARG_LIST = %i[a b c d].freeze
6
+ ARG_LIST = %i[a b c d].freeze # rubocop:disable RSpec/LeakyConstantDeclaration
7
+
7
8
  let(:instance) do
8
9
  described_class.new(*ARG_LIST, default: %w[Vcc Vd]) do
9
10
  @z = 'Vz'
10
11
  end
11
12
  end
12
13
 
13
- class MyClass
14
- attr_reader :z
14
+ let(:a_class) do
15
+ ::Class.new do
16
+ attr_reader :z
17
+ end
15
18
  end
16
19
 
17
- let(:subject) { MyClass.new('Va', 'Vb', 'Vc') }
20
+ let(:a_class_instance) { a_class.new('Va', 'Vb', 'Vc') }
18
21
 
19
22
  before do
20
- instance.setup_class(::MyClass)
23
+ instance.setup_class(a_class)
21
24
  end
22
25
 
23
- it { expect(subject.z).to eq('Vz') }
26
+ it { expect(a_class_instance.z).to eq('Vz') }
24
27
 
25
28
  ARG_LIST.each do |attr|
26
29
  expected_value = "V#{attr}"
27
30
  it "attribute \"#{attr}\" equal to \"#{expected_value}\"" do
28
- expect(subject.send(attr)).to eq(expected_value)
31
+ expect(a_class_instance.send(attr)).to eq(expected_value)
29
32
  end
30
33
 
31
34
  [false, true].each do |include_all|
32
35
  it "respond_to?('#{attr}', #{include_all}) == #{include_all}" do
33
- expect(subject.respond_to?("#{attr}=", include_all)).to eq(include_all)
36
+ expect(a_class_instance.respond_to?("#{attr}=", include_all)).to eq(include_all)
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'with super class' do
42
+ let(:super_class) do
43
+ ::Class.new do
44
+ attr_reader :super_a, :super_b
45
+
46
+ def initialize(a, b) # rubocop:disable Naming/MethodParameterName
47
+ @super_a = a
48
+ @super_b = b
49
+ end
50
+ end
51
+ end
52
+
53
+ let(:sub_class) do
54
+ sub_constructor.setup_class(::Class.new(super_class))
55
+ end
56
+
57
+ let(:sub_object) { sub_class.new(1, 2, 3, 4) }
58
+
59
+ context 'with super_args parameter' do
60
+ let(:sub_constructor) do
61
+ described_class.new(:c, :a, :b, :d, super_args: -> { [c, a] })
62
+ end
63
+
64
+ it { expect(sub_object.a).to eq(2) }
65
+ it { expect(sub_object.b).to eq(3) }
66
+ it { expect(sub_object.c).to eq(1) }
67
+ it { expect(sub_object.d).to eq(4) }
68
+ it { expect(sub_object.super_a).to eq(1) }
69
+ it { expect(sub_object.super_b).to eq(2) }
70
+ end
71
+
72
+ context 'without super_args parameter' do
73
+ let(:sub_constructor) do
74
+ described_class.new(:c, :a, :b, :d)
75
+ end
76
+
77
+ it { expect(sub_object.a).to eq(2) }
78
+ it { expect(sub_object.b).to eq(3) }
79
+ it { expect(sub_object.c).to eq(1) }
80
+ it { expect(sub_object.d).to eq(4) }
81
+ it { expect(sub_object.super_a).to eq(2) }
82
+ it { expect(sub_object.super_b).to eq(3) }
83
+ end
84
+
85
+ context 'with undefined super arguments' do
86
+ let(:sub_constructor) do
87
+ described_class.new(:x, :y, :w, :a)
88
+ end
89
+
90
+ it do
91
+ expect { sub_object }.to raise_error(::ArgumentError)
34
92
  end
35
93
  end
36
94
  end
@@ -3,7 +3,8 @@
3
3
  require 'eac_ruby_utils/struct'
4
4
 
5
5
  RSpec.describe ::EacRubyUtils::Struct do
6
- let(:instance) { described_class.new(a: 1, b: '') }
6
+ let(:instance) { described_class.new('a' => 1, b: '') }
7
+ let(:other) { described_class.new('a' => 'm1', c: 'm2') }
7
8
 
8
9
  describe '#[]' do
9
10
  it { expect(instance[:a]).to eq(1) }
@@ -35,6 +36,12 @@ RSpec.describe ::EacRubyUtils::Struct do
35
36
  it { expect { instance.fetch('c?') }.to raise_error(::KeyError) }
36
37
  end
37
38
 
39
+ describe '#merge' do
40
+ let(:merged) { instance.merge(other) }
41
+
42
+ it { expect(merged.to_h).to eq(a: 'm1', b: '', c: 'm2') }
43
+ end
44
+
38
45
  describe '#property_method' do
39
46
  it { expect(instance.a).to eq(1) }
40
47
  it { expect(instance.a?).to eq(true) }
@@ -43,4 +50,8 @@ RSpec.describe ::EacRubyUtils::Struct do
43
50
  it { expect { instance.c }.to raise_error(::NoMethodError) }
44
51
  it { expect { instance.c? }.to raise_error(::NoMethodError) }
45
52
  end
53
+
54
+ describe '#to_h' do
55
+ it { expect(instance.to_h).to eq(a: 1, b: '') }
56
+ end
46
57
  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.77.0
4
+ version: 0.82.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-12-03 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -300,6 +300,7 @@ files:
300
300
  - lib/avm/eac_rails_base1/runner.rb
301
301
  - lib/avm/eac_rails_base1/runner/bundle.rb
302
302
  - lib/avm/eac_rails_base1/runner/code_runner.rb
303
+ - lib/avm/eac_rails_base1/runner/rails_server.rb
303
304
  - lib/avm/eac_rails_base1/runner_with/bundle.rb
304
305
  - lib/avm/eac_redmine_base0.rb
305
306
  - lib/avm/eac_redmine_base0/core_update.rb
@@ -434,6 +435,7 @@ files:
434
435
  - lib/avm/local_projects.rb
435
436
  - lib/avm/local_projects/instance.rb
436
437
  - lib/avm/patches.rb
438
+ - lib/avm/patches/class/i18n.rb
437
439
  - lib/avm/patches/eac_ruby_gems_utils/gem.rb
438
440
  - lib/avm/patches/i18n.rb
439
441
  - lib/avm/patches/object/i18n.rb
@@ -485,8 +487,6 @@ files:
485
487
  - lib/avm/tools/runner.rb
486
488
  - lib/avm/tools/runner/eac_rails_base0.rb
487
489
  - lib/avm/tools/runner/eac_rails_base0/apache_path.rb
488
- - lib/avm/tools/runner/eac_rails_base0/rails_server.rb
489
- - lib/avm/tools/runner/eac_rails_base0/runner.rb
490
490
  - lib/avm/tools/runner/eac_redmine_base0.rb
491
491
  - lib/avm/tools/runner/eac_redmine_base0/core_update.rb
492
492
  - lib/avm/tools/runner/eac_redmine_base0/docker.rb
@@ -507,6 +507,8 @@ files:
507
507
  - lib/avm/tools/runner/git/revisions_test.rb
508
508
  - lib/avm/tools/runner/git/subrepo.rb
509
509
  - lib/avm/tools/runner/git/subrepo/check.rb
510
+ - lib/avm/tools/runner/git/subrepo/clone.rb
511
+ - lib/avm/tools/runner/git/subrepo/fix.rb
510
512
  - lib/avm/tools/runner/instance.rb
511
513
  - lib/avm/tools/runner/instance/info.rb
512
514
  - lib/avm/tools/runner/launcher.rb
@@ -620,6 +622,7 @@ files:
620
622
  - vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb
621
623
  - vendor/eac_cli/lib/eac_cli/runner.rb
622
624
  - vendor/eac_cli/lib/eac_cli/runner/context.rb
625
+ - vendor/eac_cli/lib/eac_cli/runner/exit.rb
623
626
  - vendor/eac_cli/lib/eac_cli/runner_with.rb
624
627
  - vendor/eac_cli/lib/eac_cli/runner_with/help.rb
625
628
  - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
@@ -629,6 +632,8 @@ files:
629
632
  - vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb
630
633
  - vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb
631
634
  - vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb
635
+ - vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb
636
+ - vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
632
637
  - vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb
633
638
  - vendor/eac_cli/spec/rubocop_spec.rb
634
639
  - vendor/eac_cli/spec/spec_helper.rb
@@ -900,6 +905,8 @@ files:
900
905
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb
901
906
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb
902
907
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb
908
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb
909
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb
903
910
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb
904
911
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb
905
912
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
@@ -926,6 +933,8 @@ files:
926
933
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs.rb
927
934
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/base_env.rb
928
935
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb
936
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb
937
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb
929
938
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb
930
939
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb
931
940
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/file.rb
@@ -980,6 +989,7 @@ files:
980
989
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb
981
990
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
982
991
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb
992
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb
983
993
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb
984
994
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/console_speaker.rb
985
995
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb