eac_tools 0.25.0 → 0.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +25 -25
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +2 -2
  5. data/sub/avm/lib/avm/entries/auto_values/uri_entry.rb +1 -1
  6. data/sub/avm/lib/avm/version.rb +1 -1
  7. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +2 -2
  8. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/deploy.rb +37 -0
  9. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/runners/base.rb +1 -1
  10. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  11. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/{deploy → instances/deploy}/config/install.sh.template +0 -0
  12. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/{deploy → instances/deploy}/config/secrets.yml +0 -0
  13. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
  14. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb +7 -1
  15. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  16. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +2 -2
  17. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/runner/deploy.rb +2 -0
  18. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  19. data/sub/eac_config/eac_config.gemspec +1 -1
  20. data/sub/eac_config/lib/eac_config/entry.rb +4 -0
  21. data/sub/eac_config/lib/eac_config/envvars_node.rb +4 -0
  22. data/sub/eac_config/lib/eac_config/node_entry.rb +5 -0
  23. data/sub/eac_config/lib/eac_config/version.rb +1 -1
  24. data/sub/eac_config/lib/eac_config/yaml_file_node.rb +4 -0
  25. data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +11 -0
  26. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +2 -2
  27. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +53 -20
  28. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb +36 -0
  29. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects.rb +52 -0
  30. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  31. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/{ruby_spec.rb → ruby/on_clean_environment_spec.rb} +11 -0
  32. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_replace_objects_spec.rb +67 -0
  33. metadata +23 -26
  34. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/deploy.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b50382fd923923ea176726318a5adeed1194cdc1aac56b3d70c2211a030d2e86
4
- data.tar.gz: f35a6fe715fc7d265f046e3692201a8edbab95e16cc324942956ab31804bff0d
3
+ metadata.gz: 2dd36587fe5621b65a2fd826e04b44f9c941b848a9e5d3bb82f0e40375ec679b
4
+ data.tar.gz: '0880b563b0f3b7f367ddc299a385a76c626260937d779f4cd92f1884ad0ecc3d'
5
5
  SHA512:
6
- metadata.gz: 8495da6e5565b3b03901d8c11a4f5bfe1d08fbe02cfafed82d59c4d33c69e92a43f8042e78e29ac32416eeed25250ab46088e9ca21193e0a912db82c2987c3ef
7
- data.tar.gz: 81f4b76062b762acd52c63f9b4ec03bbb8e7d599032d7235ea24f2f291001664c3674fbb4db74d0e8f31783e36760f7a59427e1893d38ad087eaa34b24d87b29
6
+ metadata.gz: 8edc33b2af676aaa9ba92138791e4e13fea951c028acd1efc6988a2d4922efd03bad2bb39ff15391110f070c63872ae17bb6a2831421095b62768f8a64c63864
7
+ data.tar.gz: 68360fc6669359864fbebeab00cf8a858bd341ffc849ed6855a4f5783efa5ee319c4c5a861a5752b0c55894be786b9a7230c0af5c5624cf99ef14bc354ccb064
data/Gemfile.lock CHANGED
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.25.0)
5
- avm (~> 0.39)
4
+ eac_tools (0.25.1)
5
+ avm (~> 0.39, >= 0.39.1)
6
6
  avm-eac_asciidoctor_base0 (~> 0.5)
7
7
  avm-eac_generic_base0 (~> 0.5)
8
8
  avm-eac_latex_base0 (~> 0.1, >= 0.1.2)
9
9
  avm-eac_rails_base0 (~> 0.7)
10
10
  avm-eac_rails_base1 (~> 0.5)
11
- avm-eac_redmine_base0 (~> 0.12)
11
+ avm-eac_redmine_base0 (~> 0.13)
12
12
  avm-eac_redmine_plugin_base0 (~> 0.3)
13
- avm-eac_ruby_base1 (~> 0.19, >= 0.19.1)
14
- avm-eac_webapp_base0 (~> 0.4, >= 0.4.1)
13
+ avm-eac_ruby_base1 (~> 0.20)
14
+ avm-eac_webapp_base0 (~> 0.5)
15
15
  avm-eac_wordpress_base0 (~> 0.1, >= 0.1.2)
16
16
  avm-tools (~> 0.133)
17
- eac_ruby_utils (~> 0.101)
17
+ eac_ruby_utils (~> 0.102)
18
18
 
19
19
  PATH
20
20
  remote: sub/avm-eac_asciidoctor_base0
@@ -60,15 +60,15 @@ PATH
60
60
  PATH
61
61
  remote: sub/avm-eac_redmine_base0
62
62
  specs:
63
- avm-eac_redmine_base0 (0.12.0)
64
- avm (~> 0.35, >= 0.35.1)
63
+ avm-eac_redmine_base0 (0.13.0)
64
+ avm (~> 0.39, >= 0.39.1)
65
65
  avm-eac_generic_base0 (~> 0.5)
66
66
  avm-eac_rails_base1 (~> 0.5)
67
67
  avm-eac_ubuntu_base0 (~> 0.3)
68
68
  curb (~> 0.9, >= 0.9.11)
69
69
  eac_fs (~> 0.12, >= 0.12.3)
70
70
  eac_rest (~> 0.6, >= 0.6.1)
71
- eac_ruby_utils (~> 0.98)
71
+ eac_ruby_utils (~> 0.102)
72
72
 
73
73
  PATH
74
74
  remote: sub/avm-eac_redmine_plugin_base0
@@ -80,20 +80,20 @@ PATH
80
80
  PATH
81
81
  remote: sub/avm-eac_ruby_base1
82
82
  specs:
83
- avm-eac_ruby_base1 (0.19.1)
84
- avm (~> 0.35, >= 0.35.1)
83
+ avm-eac_ruby_base1 (0.20.0)
84
+ avm (~> 0.39, >= 0.39.1)
85
85
  avm-eac_generic_base0 (~> 0.5)
86
- eac_ruby_utils (~> 0.98)
86
+ eac_ruby_utils (~> 0.102)
87
87
 
88
88
  PATH
89
89
  remote: sub/avm-eac_webapp_base0
90
90
  specs:
91
- avm-eac_webapp_base0 (0.4.1)
92
- avm (~> 0.39)
91
+ avm-eac_webapp_base0 (0.5.0)
92
+ avm (~> 0.39, >= 0.39.1)
93
93
  avm-eac_generic_base0 (~> 0.5)
94
94
  avm-eac_postgresql_base0 (~> 0.2)
95
95
  avm-eac_ubuntu_base0 (~> 0.3)
96
- eac_ruby_utils (~> 0.101)
96
+ eac_ruby_utils (~> 0.102)
97
97
 
98
98
  PATH
99
99
  remote: sub/avm-eac_wordpress_base0
@@ -124,12 +124,12 @@ PATH
124
124
  PATH
125
125
  remote: sub/avm
126
126
  specs:
127
- avm (0.39.0)
127
+ avm (0.39.1)
128
128
  eac_cli (~> 0.27, >= 0.27.8)
129
- eac_config (~> 0.11)
129
+ eac_config (~> 0.11, >= 0.11.1)
130
130
  eac_docker (~> 0.4, >= 0.4.2)
131
131
  eac_git (~> 0.12, >= 0.12.2)
132
- eac_ruby_utils (~> 0.101)
132
+ eac_ruby_utils (~> 0.102)
133
133
  eac_templates (~> 0.3, >= 0.3.1)
134
134
  filesize (~> 0.2)
135
135
  htmlbeautifier (~> 1.4, >= 1.4.2)
@@ -146,9 +146,9 @@ PATH
146
146
  PATH
147
147
  remote: sub/eac_config
148
148
  specs:
149
- eac_config (0.11.0)
149
+ eac_config (0.11.1)
150
150
  addressable (~> 2.8)
151
- eac_ruby_utils (~> 0.100)
151
+ eac_ruby_utils (~> 0.102)
152
152
 
153
153
  PATH
154
154
  remote: sub/eac_docker
@@ -177,11 +177,11 @@ PATH
177
177
  PATH
178
178
  remote: sub/eac_ruby_utils
179
179
  specs:
180
- eac_ruby_utils (0.101.0)
180
+ eac_ruby_utils (0.102.0)
181
181
  activesupport (>= 4, < 7)
182
- addressable (~> 2.6)
182
+ addressable (~> 2.8)
183
183
  bundler
184
- filesize
184
+ filesize (~> 0.2)
185
185
  net-ssh (~> 4.2)
186
186
 
187
187
  GEM
@@ -280,7 +280,7 @@ GEM
280
280
  concurrent-ruby (~> 1.0)
281
281
  jaro_winkler (1.5.4)
282
282
  minitar (0.9)
283
- minitest (5.16.2)
283
+ minitest (5.16.3)
284
284
  multipart-post (2.2.3)
285
285
  net-ssh (4.2.0)
286
286
  nokogiri (1.13.8-x86_64-linux)
@@ -361,4 +361,4 @@ DEPENDENCIES
361
361
  eac_tools!
362
362
 
363
363
  BUNDLED WITH
364
- 2.3.18
364
+ 2.3.20
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.25.0'
4
+ VERSION = '0.25.1'
5
5
  end
data/sub/avm/avm.gemspec CHANGED
@@ -13,10 +13,10 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
15
  s.add_dependency 'eac_cli', '~> 0.27', '>= 0.27.8'
16
- s.add_dependency 'eac_config', '~> 0.11'
16
+ s.add_dependency 'eac_config', '~> 0.11', '>= 0.11.1'
17
17
  s.add_dependency 'eac_docker', '~> 0.4', '>= 0.4.2'
18
18
  s.add_dependency 'eac_git', '~> 0.12', '>= 0.12.2'
19
- s.add_dependency 'eac_ruby_utils', '~> 0.101'
19
+ s.add_dependency 'eac_ruby_utils', '~> 0.102'
20
20
  s.add_dependency 'eac_templates', '~> 0.3', '>= 0.3.1'
21
21
  s.add_dependency 'filesize', '~> 0.2'
22
22
  s.add_dependency 'htmlbeautifier', '~> 1.4', '>= 1.4.2'
@@ -15,7 +15,7 @@ module Avm
15
15
 
16
16
  def value
17
17
  ::Avm::Entries::UriBuilder.from_all_fields do |field_name|
18
- entries_provider.entry([suffix, field_name]).value
18
+ entries_provider.entry([suffix, field_name]).optional_value
19
19
  end.to_uri.to_s
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.39.0'
4
+ VERSION = '0.39.1'
5
5
  end
@@ -12,14 +12,14 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,locale,template}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.35', '>= 0.35.1'
15
+ s.add_dependency 'avm', '~> 0.39', '>= 0.39.1'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.5'
17
17
  s.add_dependency 'avm-eac_rails_base1', '~> 0.5'
18
18
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
19
19
  s.add_dependency 'curb', '~> 0.9', '>= 0.9.11'
20
20
  s.add_dependency 'eac_fs', '~> 0.12', '>= 0.12.3'
21
21
  s.add_dependency 'eac_rest', '~> 0.6', '>= 0.6.1'
22
- s.add_dependency 'eac_ruby_utils', '~> 0.98'
22
+ s.add_dependency 'eac_ruby_utils', '~> 0.102'
23
23
 
24
24
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
25
25
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/deploy'
4
+ require 'eac_ruby_utils/ruby'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ module Instances
9
+ class Deploy < ::Avm::EacWebappBase0::Deploy
10
+ set_callback :assert_instance_branch, :after, :run_installer
11
+
12
+ def run_installer
13
+ infom 'Running installer'
14
+ ::EacRubyUtils::Ruby.on_clean_environment do
15
+ installer_command.system!
16
+ end
17
+ end
18
+
19
+ def installer_command
20
+ instance.host_env.command(installer_path, install_task)
21
+ end
22
+
23
+ def installer_path
24
+ ::File.join(instance.fs_path, 'plugins', 'redmine_installer', 'installer', 'run.sh')
25
+ end
26
+
27
+ def install_task
28
+ if instance.web_path_optional.present?
29
+ 'redmine_as_apache_path'
30
+ else
31
+ 'redmine_as_apache_base'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_redmine_base0/instances/base'
4
- require 'avm/eac_redmine_base0/deploy'
4
+ require 'avm/eac_redmine_base0/instances/deploy'
5
5
  require 'avm/eac_redmine_base0/apache_host'
6
6
  require 'avm/eac_rails_base1/runner'
7
7
  require 'eac_ruby_utils/core_ext'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRedmineBase0
5
- VERSION = '0.12.0'
5
+ VERSION = '0.13.0'
6
6
  end
7
7
  end
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,locale,template}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.35', '>= 0.35.1'
15
+ s.add_dependency 'avm', '~> 0.39', '>= 0.39.1'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.5'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.98'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.102'
18
18
 
19
19
  s.add_development_dependency 'aranha-parsers', '~> 0.14', '>= 0.14.1'
20
20
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
@@ -11,6 +11,7 @@ module Avm
11
11
  class UpdateDependenciesRequirements
12
12
  runner_with :help do
13
13
  bool_opt '-a', '--all'
14
+ arg_opt '-e', '--exclude', repeat: true
14
15
  pos_arg :gem_name, repeat: true, optional: true
15
16
  end
16
17
 
@@ -32,8 +33,13 @@ module Avm
32
33
 
33
34
  private
34
35
 
36
+ def exclude?(gem_name)
37
+ parsed.exclude.include?(gem_name)
38
+ end
39
+
35
40
  def gem_names_uncached
36
- ::Set.new(parsed.gem_name + gem_names_from_all).sort
41
+ ::Set.new(parsed.gem_name + gem_names_from_all).reject { |gem_name| exclude?(gem_name) }
42
+ .sort
37
43
  end
38
44
 
39
45
  def gem_names_from_all
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.19.1'
5
+ VERSION = '0.20.0'
6
6
  end
7
7
  end
@@ -12,11 +12,11 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.39'
15
+ s.add_dependency 'avm', '~> 0.39', '>= 0.39.1'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.5'
17
17
  s.add_dependency 'avm-eac_postgresql_base0', '~> 0.2'
18
18
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
19
- s.add_dependency 'eac_ruby_utils', '~> 0.101'
19
+ s.add_dependency 'eac_ruby_utils', '~> 0.102'
20
20
 
21
21
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
22
22
  end
@@ -16,6 +16,8 @@ module Avm
16
16
  end
17
17
 
18
18
  def deploy_class
19
+ runner_context.call(:stereotype_module).const_get('Instances').const_get('Deploy')
20
+ rescue ::NameError
19
21
  runner_context.call(:stereotype_module).const_get('Deploy')
20
22
  end
21
23
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacWebappBase0
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
15
  s.add_dependency 'addressable', '~> 2.8'
16
- s.add_dependency 'eac_ruby_utils', '~> 0.100'
16
+ s.add_dependency 'eac_ruby_utils', '~> 0.102'
17
17
 
18
18
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
19
19
  end
@@ -22,6 +22,10 @@ module EacConfig
22
22
  node_entry.if_present(&:secret_value)
23
23
  end
24
24
 
25
+ def to_s
26
+ "#{self.class}[RootNode: #{root_node}, Path: #{path}]"
27
+ end
28
+
25
29
  def value
26
30
  node_entry.if_present(&:value)
27
31
  end
@@ -21,5 +21,9 @@ module EacConfig
21
21
  def url
22
22
  URI
23
23
  end
24
+
25
+ def to_s
26
+ "#{self.class}[ObjectId: #{object_id}]}"
27
+ end
24
28
  end
25
29
  end
@@ -18,5 +18,10 @@ module EacConfig
18
18
  def secret_value
19
19
  value
20
20
  end
21
+
22
+ # @return [String]
23
+ def to_s
24
+ "#{self.class}[Node: #{node}, Path: #{path}]"
25
+ end
21
26
  end
22
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.1'
5
5
  end
@@ -31,6 +31,10 @@ module EacConfig
31
31
  ::Addressable::URI.parse("file://#{path.expand_path}")
32
32
  end
33
33
 
34
+ def to_s
35
+ "#{self.class}[#{path}]"
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def data_uncached
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_config/envvars_node'
4
+ require 'eac_ruby_utils/ruby'
4
5
 
5
6
  RSpec.describe ::EacConfig::EnvvarsNode do
6
7
  let(:instance) { described_class.new }
@@ -18,6 +19,16 @@ RSpec.describe ::EacConfig::EnvvarsNode do
18
19
  it { expect(entry.value).to eq('AAA') }
19
20
  it { expect(entry.found_node).to eq(instance) }
20
21
  it { expect(entry).to be_found }
22
+
23
+ context 'with a clean ruby environment' do
24
+ let(:entry_value) do
25
+ ::EacRubyUtils::Ruby.on_clean_environment do
26
+ entry.value
27
+ end
28
+ end
29
+
30
+ it { expect(entry_value).to eq('AAA') }
31
+ end
21
32
  end
22
33
 
23
34
  context 'with blank entry' do
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
16
16
  s.files = Dir['{lib}/**/*', 'MIT-LICENSE', 'README.rdoc']
17
17
 
18
18
  s.add_dependency 'activesupport', '>= 4', '< 7'
19
- s.add_dependency 'addressable', '~> 2.6'
19
+ s.add_dependency 'addressable', '~> 2.8'
20
20
  s.add_dependency 'bundler'
21
- s.add_dependency 'filesize'
21
+ s.add_dependency 'filesize', '~> 0.2'
22
22
  s.add_dependency 'net-ssh', '~> 4.2'
23
23
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
24
24
  end
@@ -1,37 +1,70 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler'
4
+ require 'eac_ruby_utils/ruby/on_replace_objects'
4
5
 
5
6
  module EacRubyUtils
6
7
  module Ruby
7
8
  class << self
8
9
  # Executes a block in an environment when the variables BUNDLE* and RUBY* are removed.
9
- def on_clean_environment
10
- bundler_with_unbundled_env do
11
- on_clean_envvars('BUNDLE', 'RUBY') { yield }
12
- end
10
+ def on_clean_environment(&block)
11
+ OnCleanEnvironment.new(&block).perform
13
12
  end
14
13
 
15
- private
14
+ class OnCleanEnvironment
15
+ ENVVARS_PREFIXES_TO_CLEAN = %w[BUNDLE RUBY].freeze
16
+
17
+ attr_reader :block, :original_env
16
18
 
17
- def bundler_with_unbundled_env(&block)
18
- if ::Bundler.respond_to?(:with_unbundled_env)
19
- ::Bundler.with_unbundled_env(&block)
20
- else
21
- ::Bundler.with_clean_env(&block)
19
+ def initialize(&block)
20
+ @block = block
21
+ @original_env = ::ENV.to_h
22
22
  end
23
- end
24
23
 
25
- def on_clean_envvars(*start_with_vars)
26
- old_values = envvars_starting_with(start_with_vars)
27
- old_values.each_key { |k| ENV.delete(k) }
28
- yield
29
- ensure
30
- old_values&.each { |k, v| ENV[k] = v }
31
- end
24
+ # @return [Array<String>]
25
+ def envvars_prefixes_to_clean
26
+ ENVVARS_PREFIXES_TO_CLEAN
27
+ end
32
28
 
33
- def envvars_starting_with(start_with_vars)
34
- ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
29
+ def perform
30
+ bundler_with_unbundled_env do
31
+ on_clean_envvars
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def bundler_with_unbundled_env(&block)
38
+ with_bundler_modified do
39
+ ::Bundler.send(bundler_with_env_method_name, &block)
40
+ end
41
+ end
42
+
43
+ def bundler_with_env_method_name
44
+ if ::Bundler.respond_to?(:with_unbundled_env)
45
+ :with_unbundled_env
46
+ else
47
+ :with_clean_env
48
+ end
49
+ end
50
+
51
+ def clean_env
52
+ r = original_env.dup
53
+ r.delete_if { |k, _| envvars_prefixes_to_clean.any? { |prefix| k.start_with?(prefix) } }
54
+ r
55
+ end
56
+
57
+ def on_clean_envvars
58
+ ::Bundler.send('with_env', clean_env) { block.call }
59
+ end
60
+
61
+ def with_bundler_modified(&block)
62
+ cloned_env = original_env.dup
63
+ ::EacRubyUtils::Ruby.on_replace_objects do |replacer|
64
+ replacer.replace_self_method(::Bundler, :original_env) { cloned_env }
65
+ block.call
66
+ end
67
+ end
35
68
  end
36
69
  end
37
70
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/inflector'
4
+ require 'eac_ruby_utils/ruby/on_replace_objects/replace_instance_method'
5
+
6
+ module EacRubyUtils
7
+ module Ruby
8
+ class OnReplaceObjects
9
+ class ReplaceInstanceMethod
10
+ attr_reader :a_module, :method_new_block, :original_method
11
+
12
+ def initialize(a_module, method_name, &method_new_block)
13
+ @a_module = a_module
14
+ @original_method = a_module.instance_method(method_name)
15
+ @method_new_block = method_new_block
16
+ end
17
+
18
+ def apply
19
+ a_module.define_method(method_name, &method_new_block)
20
+
21
+ self
22
+ end
23
+
24
+ def method_name
25
+ original_method.name
26
+ end
27
+
28
+ def restore
29
+ a_module.define_method(method_name, original_method)
30
+
31
+ self
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/inflector'
4
+ require 'eac_ruby_utils/ruby/on_replace_objects/replace_instance_method'
5
+
6
+ module EacRubyUtils
7
+ module Ruby
8
+ class << self
9
+ def on_replace_objects
10
+ replacer = OnReplaceObjects.new
11
+ replacer.on_replacement do
12
+ yield(replacer)
13
+ end
14
+ end
15
+ end
16
+
17
+ class OnReplaceObjects
18
+ def on_replacement(&block)
19
+ clear_replacements
20
+ block.call(self)
21
+ ensure
22
+ restore_replacements
23
+ end
24
+
25
+ def replace_instance_method(a_module, method_name, &block)
26
+ add_replacement(__method__, a_module, method_name, &block)
27
+ end
28
+
29
+ def replace_self_method(object, method_name, &block)
30
+ add_replacement(:replace_instance_method, object.singleton_class, method_name, &block)
31
+ end
32
+
33
+ private
34
+
35
+ def add_replacement(method_name, *args, &block)
36
+ @replacements << replacement_class(method_name).new(*args, &block).apply
37
+ end
38
+
39
+ def replacement_class(method_name)
40
+ self.class.const_get(::ActiveSupport::Inflector.camelize(method_name))
41
+ end
42
+
43
+ def clear_replacements
44
+ @replacements = []
45
+ end
46
+
47
+ def restore_replacements
48
+ @replacements.reverse.each(&:restore)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.101.0'
4
+ VERSION = '0.102.0'
5
5
  end
@@ -6,9 +6,12 @@ RSpec.describe ::EacRubyUtils::Ruby do
6
6
  describe '#on_clean_environment' do
7
7
  let(:envvar_name) { 'BUNDLE_NOT_EXISTENT_ENV_VAR' }
8
8
  let(:envvar_value) { 'any value' }
9
+ let(:noruby_envvar_name) { 'ANY_ENVIRONMENT_VARIABLE' }
10
+ let(:noruby_envvar_value) { 'another any value' }
9
11
 
10
12
  before do
11
13
  ENV[envvar_name] = envvar_value
14
+ ENV[noruby_envvar_name] = noruby_envvar_value
12
15
  end
13
16
 
14
17
  it do # rubocop:disable RSpec/MultipleExpectations
@@ -18,5 +21,13 @@ RSpec.describe ::EacRubyUtils::Ruby do
18
21
  end
19
22
  expect(ENV[envvar_name]).to eq(envvar_value)
20
23
  end
24
+
25
+ it do # rubocop:disable RSpec/MultipleExpectations
26
+ expect(ENV[noruby_envvar_name]).to eq(noruby_envvar_value)
27
+ described_class.on_clean_environment do
28
+ expect(ENV[noruby_envvar_name]).to eq(noruby_envvar_value)
29
+ end
30
+ expect(ENV[noruby_envvar_name]).to eq(noruby_envvar_value)
31
+ end
21
32
  end
22
33
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/ruby'
4
+
5
+ RSpec.describe ::EacRubyUtils::Ruby do
6
+ describe '#on_replace_objects' do
7
+ let(:stub_class) do
8
+ ::Class.new do
9
+ def self.my_class_method
10
+ 'Original'
11
+ end
12
+
13
+ def my_instance_method
14
+ 'Original'
15
+ end
16
+ end
17
+ end
18
+
19
+ let(:stub_instance) { stub_class.new }
20
+
21
+ let(:replace_block) do
22
+ ::Proc.new { 'Replaced' }
23
+ end
24
+
25
+ describe '#my_instance_method' do
26
+ let(:before) { stub_instance.my_instance_method }
27
+ let(:inside) do
28
+ described_class.on_replace_objects do |replacer|
29
+ replacer.replace_instance_method(stub_class, :my_instance_method, &replace_block)
30
+ stub_instance.my_instance_method
31
+ end
32
+ end
33
+ let(:after) { stub_instance.my_instance_method }
34
+
35
+ before do
36
+ before
37
+ inside
38
+ after
39
+ end
40
+
41
+ it { expect(before).to eq('Original') }
42
+ it { expect(inside).to eq('Replaced') }
43
+ it { expect(after).to eq('Original') }
44
+ end
45
+
46
+ describe '#replace_self_method' do
47
+ let(:before) { stub_class.my_class_method }
48
+ let(:inside) do
49
+ described_class.on_replace_objects do |replacer|
50
+ replacer.replace_self_method(stub_class, :my_class_method, &replace_block)
51
+ stub_class.my_class_method
52
+ end
53
+ end
54
+ let(:after) { stub_class.my_class_method }
55
+
56
+ before do
57
+ before
58
+ inside
59
+ after
60
+ end
61
+
62
+ it { expect(before).to eq('Original') }
63
+ it { expect(inside).to eq('Replaced') }
64
+ it { expect(after).to eq('Original') }
65
+ end
66
+ end
67
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.39'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.39.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.39'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.39.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: avm-eac_asciidoctor_base0
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +112,14 @@ dependencies:
106
112
  requirements:
107
113
  - - "~>"
108
114
  - !ruby/object:Gem::Version
109
- version: '0.12'
115
+ version: '0.13'
110
116
  type: :runtime
111
117
  prerelease: false
112
118
  version_requirements: !ruby/object:Gem::Requirement
113
119
  requirements:
114
120
  - - "~>"
115
121
  - !ruby/object:Gem::Version
116
- version: '0.12'
122
+ version: '0.13'
117
123
  - !ruby/object:Gem::Dependency
118
124
  name: avm-eac_redmine_plugin_base0
119
125
  requirement: !ruby/object:Gem::Requirement
@@ -134,40 +140,28 @@ dependencies:
134
140
  requirements:
135
141
  - - "~>"
136
142
  - !ruby/object:Gem::Version
137
- version: '0.19'
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: 0.19.1
143
+ version: '0.20'
141
144
  type: :runtime
142
145
  prerelease: false
143
146
  version_requirements: !ruby/object:Gem::Requirement
144
147
  requirements:
145
148
  - - "~>"
146
149
  - !ruby/object:Gem::Version
147
- version: '0.19'
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: 0.19.1
150
+ version: '0.20'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: avm-eac_webapp_base0
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '0.4'
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: 0.4.1
157
+ version: '0.5'
161
158
  type: :runtime
162
159
  prerelease: false
163
160
  version_requirements: !ruby/object:Gem::Requirement
164
161
  requirements:
165
162
  - - "~>"
166
163
  - !ruby/object:Gem::Version
167
- version: '0.4'
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- version: 0.4.1
164
+ version: '0.5'
171
165
  - !ruby/object:Gem::Dependency
172
166
  name: avm-eac_wordpress_base0
173
167
  requirement: !ruby/object:Gem::Requirement
@@ -208,14 +202,14 @@ dependencies:
208
202
  requirements:
209
203
  - - "~>"
210
204
  - !ruby/object:Gem::Version
211
- version: '0.101'
205
+ version: '0.102'
212
206
  type: :runtime
213
207
  prerelease: false
214
208
  version_requirements: !ruby/object:Gem::Requirement
215
209
  requirements:
216
210
  - - "~>"
217
211
  - !ruby/object:Gem::Version
218
- version: '0.101'
212
+ version: '0.102'
219
213
  - !ruby/object:Gem::Dependency
220
214
  name: eac_ruby_gem_support
221
215
  requirement: !ruby/object:Gem::Requirement
@@ -392,9 +386,9 @@ files:
392
386
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/apache_host.rb
393
387
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb
394
388
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/data_unit.rb
395
- - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/deploy.rb
396
389
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances.rb
397
390
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base.rb
391
+ - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/deploy.rb
398
392
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb
399
393
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners.rb
400
394
  - sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners/docker.rb
@@ -412,8 +406,8 @@ files:
412
406
  - sub/avm-eac_redmine_base0/locale/pt-BR.yml
413
407
  - sub/avm-eac_redmine_base0/spec/rubocop_spec.rb
414
408
  - sub/avm-eac_redmine_base0/spec/spec_helper.rb
415
- - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template
416
- - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/secrets.yml
409
+ - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/deploy/config/install.sh.template
410
+ - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/deploy/config/secrets.yml
417
411
  - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile.template
418
412
  - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile_apache_setup
419
413
  - sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/apache_http_virtualhost.conf.template
@@ -1195,6 +1189,8 @@ files:
1195
1189
  - sub/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb
1196
1190
  - sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb
1197
1191
  - sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb
1192
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects.rb
1193
+ - sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb
1198
1194
  - sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb
1199
1195
  - sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb
1200
1196
  - sub/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb
@@ -1252,7 +1248,8 @@ files:
1252
1248
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec.rb
1253
1249
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec/stubbed_module_a.rb
1254
1250
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec/stubbed_not_module.rb
1255
- - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb
1251
+ - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_clean_environment_spec.rb
1252
+ - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_replace_objects_spec.rb
1256
1253
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb
1257
1254
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb
1258
1255
  - sub/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_webapp_base0/deploy'
4
- require 'eac_ruby_utils/ruby'
5
-
6
- module Avm
7
- module EacRedmineBase0
8
- class Deploy < ::Avm::EacWebappBase0::Deploy
9
- set_callback :assert_instance_branch, :after, :run_installer
10
-
11
- def run_installer
12
- infom 'Running installer'
13
- ::EacRubyUtils::Ruby.on_clean_environment do
14
- installer_command.system!
15
- end
16
- end
17
-
18
- def installer_command
19
- instance.host_env.command(installer_path, install_task)
20
- end
21
-
22
- def installer_path
23
- ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH), 'plugins',
24
- 'redmine_installer', 'installer', 'run.sh')
25
- end
26
-
27
- def install_task
28
- if instance.read_entry_optional('web.path').present?
29
- 'redmine_as_apache_path'
30
- else
31
- 'redmine_as_apache_base'
32
- end
33
- end
34
- end
35
- end
36
- end