epi 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 66b9988a9dbc6d3cbacd39fd072b343c6175eaab
4
- data.tar.gz: a0f18a237c97efb644e0afeb7e8a61b9d5680edf
3
+ metadata.gz: b5e7e4338b1beae6f3f58eb12974ea98b1093d0a
4
+ data.tar.gz: 1b9090a1e6de1c5f6ae089afb5c716d524afa5da
5
5
  SHA512:
6
- metadata.gz: 584215c982e7ba5c564033e6ae248f123ae8935b487c90be273795e4ecf45b82a89a526e1ffcb76ff57c85bc459e978c0b87e896abc2fffc4e1a3bda2f163c90
7
- data.tar.gz: 55665a0b346ca8188f1c9945ee21610b759ca70f0e31ef70ca4b0e1aaa7b09d2427e6a4675c313628427dc11dbce9180af7ffbd5f3ef2cdb3e6df087ce99e179
6
+ metadata.gz: e3da43bc5ee0f6f19b9d39cda86029b0c076a16bad0d5e6fa4d40aebac2c0c9555643cfae13c436a5afd60635034b5c1893a774e9cf5c7d6d5289d24d26987d4
7
+ data.tar.gz: f2efd89e32244861ce7532f02cf7d4dd22447f1a2ada753a951e3da7006802625bb8b872b8dbf4afb1254859de11c4bf00a564fe31b7057eae9ace4209a4e79b
data/lib/epi/job.rb CHANGED
@@ -112,9 +112,7 @@ module Epi
112
112
  end
113
113
 
114
114
  def running_processes
115
- pids.map do |proc_id, pid|
116
- [proc_id, ProcessStatus[pid] || RunningProcess.new(pid)]
117
- end.to_h
115
+ pids.map { |proc_id, pid| [proc_id, ProcessStatus[pid] || RunningProcess.new(pid)] }.select { |_, v| v.was_alive? }.to_h
118
116
  end
119
117
 
120
118
  def running_count
data/lib/epi/launch.rb CHANGED
@@ -29,12 +29,9 @@ module Epi
29
29
  else
30
30
 
31
31
  # Command and arguments that need to be escaped
32
- command.each { |part| cmd << ' ' << Shellwords.escape(part) }
32
+ command.each { |part| cmd << ' ' << escape(part) }
33
33
  end
34
34
 
35
- # Include `su` command if a user is given
36
- cmd = "su #{user} -c #{cmd}" if user
37
-
38
35
  # STDOUT and STDERR redirection
39
36
  {:>> => stdout, :'2>>' => stderr}.each do |arrow, dest|
40
37
  cmd << " #{arrow} #{dest || '/dev/null'}" unless TrueClass === dest
@@ -43,8 +40,11 @@ module Epi
43
40
  # Run in background, and return PID of backgrounded process
44
41
  cmd << ' & echo $!'
45
42
 
43
+ # Include `su` command if a user is given
44
+ cmd = "su #{user} -c #{escape cmd}" if user
45
+
46
46
  # Include the working directory
47
- cmd = "cd #{Shellwords.escape cwd} && (#{cmd})" if cwd
47
+ cmd = "cd #{escape cwd} && (#{cmd})" if cwd
48
48
 
49
49
  # Convert environment variables to strings, and merge them with the current environment
50
50
  env = ENV.to_h.merge(env).map { |k, v| [k.to_s, v.to_s] }.to_h
@@ -56,4 +56,10 @@ module Epi
56
56
  logger.info "Process #{pid} started: #{`ps -p #{pid} -o command=`.chomp}"
57
57
  end
58
58
  end
59
+
60
+ private
61
+
62
+ def self.escape(*args)
63
+ Shellwords.escape *args
64
+ end
59
65
  end
@@ -54,7 +54,7 @@ module Epi
54
54
  @running_processes = {}
55
55
 
56
56
  # Run `ps`
57
- result = %x(ps x -o #{RunningProcess::PS_FORMAT})
57
+ result = %x(ps ax -o #{RunningProcess::PS_FORMAT})
58
58
 
59
59
  # Split into lines, and get rid of the first (heading) line
60
60
  @lines = result.lines[1..-1].map { |line| [line.lstrip.split(/\s/, 2).first.to_i, line] }.to_h
data/lib/epi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Epi
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
@@ -106,3 +106,4 @@ signing_key:
106
106
  specification_version: 4
107
107
  summary: Epinephrine
108
108
  test_files: []
109
+ has_rdoc: