avm-tools 0.70.0 → 0.73.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/instance/files_unit.rb +1 -0
  3. data/lib/avm/eac_rails_base0/instance.rb +2 -2
  4. data/lib/avm/eac_redmine_base0/instance.rb +2 -2
  5. data/lib/avm/git/auto_commit_path.rb +4 -2
  6. data/lib/avm/instances/application.rb +4 -0
  7. data/lib/avm/instances/base.rb +2 -1
  8. data/lib/avm/instances/base/auto_values.rb +2 -1
  9. data/lib/avm/instances/base/auto_values/access.rb +5 -4
  10. data/lib/avm/instances/base/auto_values/admin.rb +2 -2
  11. data/lib/avm/instances/base/auto_values/database.rb +1 -1
  12. data/lib/avm/instances/base/auto_values/filesystem.rb +6 -2
  13. data/lib/avm/instances/base/auto_values/mailer.rb +34 -0
  14. data/lib/avm/instances/base/auto_values/ruby.rb +1 -1
  15. data/lib/avm/instances/base/auto_values/system.rb +2 -2
  16. data/lib/avm/instances/entry.rb +7 -1
  17. data/lib/avm/instances/entry_keys.rb +42 -7
  18. data/lib/avm/patches/i18n.rb +1 -1
  19. data/lib/avm/patches/object/template.rb +1 -1
  20. data/lib/avm/rails/instance.rb +19 -0
  21. data/lib/avm/self.rb +0 -4
  22. data/lib/avm/self/root.rb +13 -0
  23. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +41 -0
  24. data/lib/avm/tools/runner/instance.rb +28 -0
  25. data/lib/avm/tools/runner/instance/info.rb +44 -0
  26. data/lib/avm/tools/version.rb +1 -1
  27. data/template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template +11 -0
  28. data/vendor/eac_cli/lib/eac_cli/runner.rb +1 -1
  29. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +19 -2
  30. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  31. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +12 -0
  32. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  33. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +2 -1
  34. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +1 -1
  35. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +10 -6
  36. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  37. data/vendor/eac_ruby_gems_utils/spec/{rubocop_check_spec.rb → code/rubocop_check_spec.rb} +0 -0
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +43 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +12 -31
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -1
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +21 -58
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +8 -0
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +67 -0
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +39 -0
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +2 -1
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  48. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
  49. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +15 -0
  50. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +52 -13
  51. metadata +16 -4
  52. data/lib/avm/stereotypes/rails/instance.rb +0 -20
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class PathsHash
5
+ class EntryKeyError < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/paths_hash/entry_key_error'
5
+
6
+ module EacRubyUtils
7
+ class PathsHash
8
+ class Node
9
+ PATH_SEARCH_UNENDED_ERROR_MESSAGE = 'Path search is not a Node and is not ended'
10
+
11
+ def initialize(source_hash)
12
+ source_hash.assert_argument(Hash, 'source_hash')
13
+ @data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
14
+ end
15
+
16
+ def entry?(path_search)
17
+ return false unless data.key?(path_search.cursor)
18
+ return true if path_search.ended?
19
+ return data.fetch(path_search.cursor).entry?(path_search.succeeding) if
20
+ data.fetch(path_search.cursor).is_a?(Node)
21
+
22
+ false # Paths continue and there is not available nodes
23
+ end
24
+
25
+ def fetch(path_search)
26
+ if data.key?(path_search.cursor)
27
+ node = data.fetch(path_search.cursor)
28
+ return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
29
+ return nil if node.blank?
30
+ return node.fetch(path_search.succeeding) if node.is_a?(Node)
31
+ end
32
+
33
+ path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
34
+ end
35
+
36
+ def to_h
37
+ data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
38
+ end
39
+
40
+ def read_entry(path_search)
41
+ node = data[path_search.cursor]
42
+ return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
43
+ return nil if node.blank?
44
+ return node.read_entry(path_search.succeeding) if node.is_a?(Node)
45
+
46
+ path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
47
+ end
48
+
49
+ def write_entry(path_search, value)
50
+ if path_search.ended?
51
+ data[path_search.cursor] = value.is_a?(Hash) ? self.class.new(value) : value
52
+ else
53
+ assert_data_node(path_search.cursor).write_entry(path_search.succeeding, value)
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ attr_reader :data
60
+
61
+ def assert_data_node(key)
62
+ data[key] = self.class.new({}) unless data[key].is_a?(Node)
63
+ data[key]
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class PathsHash
5
+ class PathSearch
6
+ class << self
7
+ def parse_entry_key(string)
8
+ new(::EacRubyUtils::PathsHash.parse_entry_key(string), [])
9
+ end
10
+ end
11
+
12
+ common_constructor :current, :previous do
13
+ self.current = current.assert_argument(Array, 'current').freeze
14
+ self.previous = previous.assert_argument(Array, 'previous')
15
+ raise ::EacRubyUtils::PathsHash::EntryKeyError, 'Current is empty' if current.empty?
16
+ end
17
+
18
+ def cursor
19
+ current.first
20
+ end
21
+
22
+ def ended?
23
+ current.count <= 1
24
+ end
25
+
26
+ def raise_error(message)
27
+ raise ::EacRubyUtils::PathsHash::EntryKeyError, "#{message} (#{self})"
28
+ end
29
+
30
+ def succeeding
31
+ self.class.new(current[1..-1], previous + [cursor])
32
+ end
33
+
34
+ def to_s
35
+ "#{self.class}[Current: #{current}, Previous: #{previous}]"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -8,7 +8,8 @@ module EacRubyUtils
8
8
  # A [EacRubyUtils::Envs::Command] which runs in a clean Ruby environment.
9
9
  class Command < ::EacRubyUtils::Envs::Command
10
10
  def initialize(bundle_args, extra_options = {})
11
- super(::EacRubyUtils::Envs.local, bundle_args, extra_options)
11
+ host_env = extra_options.delete(:host_env)
12
+ super(host_env || ::EacRubyUtils::Envs.local, bundle_args, extra_options)
12
13
  end
13
14
 
14
15
  %w[system execute].each do |method_prefix|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.46.0'
4
+ VERSION = '0.48.0'
5
5
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/blank_not_blank'
4
+
5
+ RSpec.describe ::EacRubyUtils::BlankNotBlank do
6
+ let(:instance) { described_class.instance }
7
+
8
+ it do
9
+ expect { described_class.new }.to raise_error(::NoMethodError)
10
+ end
11
+
12
+ it { expect(instance).to be_present }
13
+ it { expect(instance).not_to be_blank }
14
+ it { expect(instance).to be_truthy }
15
+ it { expect(instance).to eq('') }
16
+ end
@@ -28,4 +28,19 @@ RSpec.describe ::EacRubyUtils::Configs do
28
28
 
29
29
  it { expect(::YAML.load_file(storage_path)).to eq(parent: { child: 'value1' }) }
30
30
  end
31
+
32
+ describe '#read' do
33
+ let(:present_key) { 'a.present.key' }
34
+ let(:blank_key) { 'a.blank.key' }
35
+
36
+ before do
37
+ instance[present_key] = 'A value'
38
+ instance[blank_key] = ''
39
+ instance.save
40
+ instance.load
41
+ end
42
+
43
+ it { expect(instance[present_key]).to be_present }
44
+ it { expect(instance[blank_key]).to be_present }
45
+ end
31
46
  end
@@ -3,20 +3,20 @@
3
3
  require 'eac_ruby_utils/paths_hash'
4
4
 
5
5
  RSpec.describe ::EacRubyUtils::PathsHash do
6
- describe '#[]' do
7
- let(:source_hash) do
8
- {
9
- parent: {
10
- child1: {
11
- child1_1: 'v1_1',
12
- child1_2: 'v1_2'
13
- },
14
- child2: 'v2'
15
- }
6
+ let(:source_hash) do
7
+ {
8
+ parent: {
9
+ child1: {
10
+ child1_1: 'v1_1',
11
+ child1_2: 'v1_2'
12
+ },
13
+ child2: 'v2'
16
14
  }
17
- end
18
- let(:instance) { described_class.new(source_hash) }
15
+ }
16
+ end
17
+ let(:instance) { described_class.new(source_hash) }
19
18
 
19
+ describe '#[]' do
20
20
  {
21
21
  'parent.child1.child1_1' => 'v1_1',
22
22
  'parent.child1.child1_2' => 'v1_2',
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::PathsHash do
38
38
  end
39
39
 
40
40
  describe '#[]=' do
41
- let(:instance) { described_class.new }
41
+ let(:source_hash) { {} }
42
42
 
43
43
  before do
44
44
  instance['a.b.c'] = '123'
@@ -46,4 +46,43 @@ RSpec.describe ::EacRubyUtils::PathsHash do
46
46
 
47
47
  it { expect(instance.to_h).to eq(a: { b: { c: '123' } }) }
48
48
  end
49
+
50
+ describe '#fetch' do
51
+ {
52
+ 'parent.child1.child1_1' => 'v1_1',
53
+ 'parent.child1.child1_2' => 'v1_2',
54
+ 'parent.child1.child1_2.no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
55
+ 'parent.child1.child1_3' => ::EacRubyUtils::PathsHash::EntryKeyError,
56
+ 'parent.child2' => 'v2',
57
+ 'no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
58
+ 'parent.child1' => {
59
+ child1_1: 'v1_1',
60
+ child1_2: 'v1_2'
61
+ }
62
+ }.each do |entry_key, expected_value|
63
+ if expected_value.is_a?(::Class) && expected_value < ::Exception
64
+ it "raise error #{expected_value}" do
65
+ expect { instance.fetch(entry_key) }.to raise_error(expected_value)
66
+ end
67
+ else
68
+ it "\#fetch return \"#{expected_value}\"" do
69
+ expect(instance.fetch(entry_key)).to eq(expected_value)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '#key?' do
76
+ {
77
+ 'parent.child1.child1_1' => true,
78
+ 'parent.child1.child1_2' => true,
79
+ 'parent.child1.child1_2.no_exist' => false,
80
+ 'parent.child1.child1_3' => false,
81
+ 'parent.child2' => true,
82
+ 'no_exist' => false,
83
+ 'parent.child1' => true
84
+ }.each do |entry_key, expected_value|
85
+ it { expect(instance.key?(entry_key)).to eq(expected_value) }
86
+ end
87
+ end
49
88
  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.70.0
4
+ version: 0.73.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-10-08 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -374,6 +374,7 @@ files:
374
374
  - lib/avm/instances/base/auto_values/data.rb
375
375
  - lib/avm/instances/base/auto_values/database.rb
376
376
  - lib/avm/instances/base/auto_values/filesystem.rb
377
+ - lib/avm/instances/base/auto_values/mailer.rb
377
378
  - lib/avm/instances/base/auto_values/ruby.rb
378
379
  - lib/avm/instances/base/auto_values/source.rb
379
380
  - lib/avm/instances/base/auto_values/system.rb
@@ -425,6 +426,7 @@ files:
425
426
  - lib/avm/projects/stereotypes/ruby_gem/update.rb
426
427
  - lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
427
428
  - lib/avm/rails.rb
429
+ - lib/avm/rails/instance.rb
428
430
  - lib/avm/rails/runners.rb
429
431
  - lib/avm/rails/runners/bundle.rb
430
432
  - lib/avm/rails/runners/runner.rb
@@ -440,6 +442,7 @@ files:
440
442
  - lib/avm/self/docker_image.rb
441
443
  - lib/avm/self/instance.rb
442
444
  - lib/avm/self/instance/entry_keys.rb
445
+ - lib/avm/self/root.rb
443
446
  - lib/avm/stereotypes.rb
444
447
  - lib/avm/stereotypes/eac_rails_base0.rb
445
448
  - lib/avm/stereotypes/eac_redmine_base0.rb
@@ -453,7 +456,6 @@ files:
453
456
  - lib/avm/stereotypes/postgresql/instance/data_unit.rb
454
457
  - lib/avm/stereotypes/postgresql/instance_with.rb
455
458
  - lib/avm/stereotypes/rails.rb
456
- - lib/avm/stereotypes/rails/instance.rb
457
459
  - lib/avm/sync.rb
458
460
  - lib/avm/tools.rb
459
461
  - lib/avm/tools/runner.rb
@@ -463,6 +465,7 @@ files:
463
465
  - lib/avm/tools/runner/eac_rails_base0/bundle.rb
464
466
  - lib/avm/tools/runner/eac_rails_base0/data.rb
465
467
  - lib/avm/tools/runner/eac_rails_base0/deploy.rb
468
+ - lib/avm/tools/runner/eac_rails_base0/rails_server.rb
466
469
  - lib/avm/tools/runner/eac_rails_base0/runner.rb
467
470
  - lib/avm/tools/runner/eac_redmine_base0.rb
468
471
  - lib/avm/tools/runner/eac_redmine_base0/bundle.rb
@@ -491,6 +494,8 @@ files:
491
494
  - lib/avm/tools/runner/git/revisions_test.rb
492
495
  - lib/avm/tools/runner/git/subrepo.rb
493
496
  - lib/avm/tools/runner/git/subrepo/check.rb
497
+ - lib/avm/tools/runner/instance.rb
498
+ - lib/avm/tools/runner/instance/info.rb
494
499
  - lib/avm/tools/runner/launcher.rb
495
500
  - lib/avm/tools/runner/launcher/instances.rb
496
501
  - lib/avm/tools/runner/launcher/projects.rb
@@ -547,6 +552,7 @@ files:
547
552
  - lib/eac_launcher/version.rb
548
553
  - template/avm/eac_rails_base0/apache_path/default.conf
549
554
  - template/avm/eac_rails_base0/deploy/config/database.yml.template
555
+ - template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template
550
556
  - template/avm/eac_redmine_base0/deploy/config/install.sh.template
551
557
  - template/avm/eac_redmine_base0/deploy/config/secrets.yml
552
558
  - template/avm/eac_webapp_base0/apache_host/no_ssl.conf
@@ -835,10 +841,10 @@ files:
835
841
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb
836
842
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb
837
843
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb
844
+ - vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb
838
845
  - vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb
839
846
  - vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb
840
847
  - vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb
841
- - vendor/eac_ruby_gems_utils/spec/rubocop_check_spec.rb
842
848
  - vendor/eac_ruby_gems_utils/spec/spec_helper.rb
843
849
  - vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile
844
850
  - vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock
@@ -853,11 +859,13 @@ files:
853
859
  - vendor/eac_ruby_utils/eac_ruby_utils.gemspec
854
860
  - vendor/eac_ruby_utils/lib/eac_ruby_utils.rb
855
861
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb
862
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb
856
863
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb
857
864
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb
858
865
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb
859
866
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb
860
867
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb
868
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
861
869
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb
862
870
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console.rb
863
871
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb
@@ -950,6 +958,9 @@ files:
950
958
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
951
959
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb
952
960
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb
961
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb
962
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb
963
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb
953
964
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb
954
965
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb
955
966
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb
@@ -973,6 +984,7 @@ files:
973
984
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb
974
985
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb
975
986
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb
987
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb
976
988
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
977
989
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb
978
990
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Stereotypes
5
- module Rails
6
- module Instance
7
- def bundle(*args)
8
- host_env.command('bundle', *args)
9
- .envvar('BUNDLE_GEMFILE', ::File.join(read_entry('fs_path'), 'Gemfile'))
10
- .envvar('RAILS_ENV', 'production')
11
- .chdir(read_entry('fs_path'))
12
- end
13
-
14
- def rake(*args)
15
- bundle('exec', 'rake', *args)
16
- end
17
- end
18
- end
19
- end
20
- end