eac_ruby_utils 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 577ff3a1a8cfb859db63e0424fb7cfc6ea82ce8c3a768d8e751c4e819702cd60
4
- data.tar.gz: c4966b952f63dbbccd37166a9652337ffca716858621629f342631b3ef6431e3
3
+ metadata.gz: 9fbe0a23a64fda20b9d611c418b3162e45a3f94efab0ab60f9e54d82c7c55d17
4
+ data.tar.gz: a48d1f5c6dad95964ada07635cc77f54df5dd681ca65bfdb44c7ca280231e665
5
5
  SHA512:
6
- metadata.gz: 0421367b017f22db98c807b54ea47dfae0b8185918523507b612ea428c9f2c16306f6a68896bcddcc80f2653d550df85143ed0998537be6a219bd16df3e0116a
7
- data.tar.gz: ab05a9f30c8445bd88455e8e3920e774902842d2956cc446bd406c60b73d1c44355950a3f624a16de5ac484e090f02662f8405fd9422dd11a8977d46ba54f39a
6
+ metadata.gz: 0a1552f7e33250db1f919be80116f186f6f8aa24df98a05a37f34189992b7930b1d37eb35a5e2d9948d38dce83b2e303ea32919b1916a8e3a6b7d717d5e50b0e
7
+ data.tar.gz: 53adc2c3785559368608d92e17b28d78174653f9c86629f697f46756c4630f6d636943cd814d9a6a09de2ec526dc9dc2e82f7cf80f30d2bb2d785ad363ca450a
@@ -37,11 +37,17 @@ module EacRubyUtils
37
37
  def command(options = {})
38
38
  c = @command
39
39
  c = c.map { |x| escape(x) }.join(' ') if c.is_a?(Enumerable)
40
- e = @envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
41
- c = "#{e} #{c}" if e.present?
42
- c = "#{c} | #{@pipe.command}" if @pipe.present?
43
- c = @env.command_line(c)
44
- append_command_options(c, options)
40
+ append_command_options(
41
+ @env.command_line(
42
+ append_chdir(append_pipe(append_envvars(c)))
43
+ ),
44
+ options
45
+ )
46
+ end
47
+
48
+ def chdir(dir)
49
+ @chdir = dir
50
+ self
45
51
  end
46
52
 
47
53
  def execute!(options = {})
@@ -84,6 +90,19 @@ module EacRubyUtils
84
90
  ENV['DEBUG'].to_s.strip != ''
85
91
  end
86
92
 
93
+ def append_envvars(command)
94
+ e = @envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
95
+ e.present? ? "#{e} #{command}" : command
96
+ end
97
+
98
+ def append_pipe(command)
99
+ @pipe.present? ? "#{command} | #{@pipe.command}" : command
100
+ end
101
+
102
+ def append_chdir(command)
103
+ @chdir.present? ? "(cd '#{@chdir}' ; #{command} )" : command
104
+ end
105
+
87
106
  def append_command_options(command, options)
88
107
  command = options[:input].command + ' | ' + command if options[:input]
89
108
  if options[:input_file]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.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.4.0
4
+ version: 0.5.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: 2019-04-14 00:00:00.000000000 Z
11
+ date: 2019-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport