eac_ruby_utils 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b13fd043a71f9c041b8f3480e6a90381baba9c2738c7aea8e9d12a8c86ab827b
4
- data.tar.gz: b0bcf3b1c78333b58f909b4926a239c35bc28a5d08b235d0a43fed8d07c8d225
3
+ metadata.gz: cfb2a1fd2c1122f700f061be368854e35b9c47218bb558d6b5491eff3e0291fe
4
+ data.tar.gz: e966b104345dd201267c09e719180e08b3c5f8c532a2b7819cd0fc733373a2a1
5
5
  SHA512:
6
- metadata.gz: d3d4c591e636688bf439bd7e1ff05788725ef13a30a2558ce640cbdc62b6d5bce593f27543ae2a9fc0df629a4403b25524ddbe420cfa833d2aa0e063788cf88d
7
- data.tar.gz: 2dc4524a56bfd3106abea448f98f03f06d72a6fa250bea0f27c0b469c6af731d125c07af482d8b2b3990eb4696fcdedea1829c2d2eab3c8167794f26774a626f
6
+ metadata.gz: 0ac76c77d50a91fb42e22e9b8203e904483526f34be079a0011750664619a23cc488cc7750b1831aeef4dbc5f1b2a2f8597796d7cff3162c6cac86076e22b9b3
7
+ data.tar.gz: 382fc3f33de11d79e4fd8e8ea9b03e2144f2be130c420a2a5d84ad347cfce0437cfc8db5f6fdb48acac4d21ecc7d41abf70517297351b9115f555bd51b2fdfe6
@@ -88,16 +88,22 @@ module EacRubyUtils
88
88
  Kernel.system(c)
89
89
  end
90
90
 
91
+ protected
92
+
93
+ def duplicate(command, extra_options)
94
+ self.class.new(@env, command, extra_options)
95
+ end
96
+
91
97
  private
92
98
 
93
99
  attr_reader :extra_options
94
100
 
95
101
  def duplicate_by_command(new_command)
96
- self.class.new(@env, new_command, @extra_options)
102
+ duplicate(new_command, @extra_options)
97
103
  end
98
104
 
99
105
  def duplicate_by_extra_options(set_extra_options)
100
- self.class.new(@env, @command, @extra_options.merge(set_extra_options))
106
+ duplicate(@command, @extra_options.merge(set_extra_options))
101
107
  end
102
108
 
103
109
  def debug?
@@ -1,23 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/ruby/on_clean_environment'
4
+
3
5
  module EacRubyUtils
4
6
  class << self
5
- def on_clean_ruby_environment
6
- on_clean_envvars('BUNDLE', 'RUBY') { yield }
7
- end
8
-
9
- private
10
-
11
- def on_clean_envvars(*start_with_vars)
12
- old_values = envvars_starting_with(start_with_vars)
13
- old_values.keys.each { |k| ENV.delete(k) }
14
- yield
15
- ensure
16
- old_values&.each { |k, v| ENV[k] = v }
17
- end
18
-
19
- def envvars_starting_with(start_with_vars)
20
- ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
7
+ # <b>DEPRECATED:</b> Please use <tt>EacRubyUtils::Ruby.on_clean_environment</tt> instead.
8
+ def on_clean_ruby_environment(*args, &block)
9
+ ::EacRubyUtils::Ruby.on_clean_environment(*args, &block)
21
10
  end
22
11
  end
23
12
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+
5
+ module EacRubyUtils
6
+ module Ruby
7
+ ::EacRubyUtils.require_sub(__FILE__)
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs/command'
4
+ require 'eac_ruby_utils/ruby/on_clean_environment'
5
+
6
+ module EacRubyUtils
7
+ module Ruby
8
+ # A [EacRubyUtils::Envs::Command] which runs in a clean Ruby environment.
9
+ class Command < ::EacRubyUtils::Envs::Command
10
+ def initialize(bundle_args, extra_options = {})
11
+ super(::EacRubyUtils::Envs.local, bundle_args, extra_options)
12
+ end
13
+
14
+ %w[system execute].each do |method_prefix|
15
+ [method_prefix, "#{method_prefix}!"].each do |method_name|
16
+ define_method method_name do |*args, &block|
17
+ ::EacRubyUtils::Ruby.on_clean_environment do
18
+ super(*args, &block)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def duplicate(command, extra_options)
27
+ self.class.new(gem, command, extra_options)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Ruby
5
+ class << self
6
+ # Executes a block in an environment when the variables BUNDLE* and RUBY* are removed.
7
+ def on_clean_environment
8
+ on_clean_envvars('BUNDLE', 'RUBY') { yield }
9
+ end
10
+
11
+ private
12
+
13
+ def on_clean_envvars(*start_with_vars)
14
+ old_values = envvars_starting_with(start_with_vars)
15
+ old_values.keys.each { |k| ENV.delete(k) }
16
+ yield
17
+ ensure
18
+ old_values&.each { |k, v| ENV[k] = v }
19
+ end
20
+
21
+ def envvars_starting_with(start_with_vars)
22
+ ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.28.0'
4
+ VERSION = '0.29.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-26 00:00:00.000000000 Z
11
+ date: 2020-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -171,6 +171,9 @@ files:
171
171
  - lib/eac_ruby_utils/rspec.rb
172
172
  - lib/eac_ruby_utils/rspec/conditional.rb
173
173
  - lib/eac_ruby_utils/rspec/stubbed_ssh.rb
174
+ - lib/eac_ruby_utils/ruby.rb
175
+ - lib/eac_ruby_utils/ruby/command.rb
176
+ - lib/eac_ruby_utils/ruby/on_clean_environment.rb
174
177
  - lib/eac_ruby_utils/settings_provider.rb
175
178
  - lib/eac_ruby_utils/simple_cache.rb
176
179
  - lib/eac_ruby_utils/templates.rb