elf 0.0.2 → 0.0.3

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.
@@ -28,7 +28,14 @@ module Elf
28
28
  def fire
29
29
  puts "Fired: #{@cmd} # #{@comment}"
30
30
  fork_pid = ::Process.fork do
31
- exec @cmd
31
+ case @cmd
32
+ when String
33
+ exec @cmd
34
+ when Symbol
35
+ send @cmd
36
+ when Array
37
+ send @cmd[0], *@cmd[1..-1]
38
+ end
32
39
  end
33
40
  fake = fork{ "sleep 10" }
34
41
  pid, @status = ::Process.waitpid2(fork_pid)
@@ -1,3 +1,3 @@
1
1
  module Elf
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -119,4 +119,24 @@ describe Elf::Process do
119
119
  end
120
120
  (Time.now-start).to_i.must_equal(4)
121
121
  end
122
+
123
+ it "should run Ruby method in background" do
124
+ start = Time.now
125
+ Elf::Process.new do |elf|
126
+ elf.fork([:sleep, 1], "async sleep")
127
+ elf.fork([:sleep, 1], "async sleep")
128
+ elf.fork([:sleep, 1], "async sleep")
129
+ end
130
+ (Time.now-start).to_i.must_equal(1)
131
+ end
132
+
133
+ it "should run Ruby method in background" do
134
+ start = Time.now
135
+ Elf::Process.new do |elf|
136
+ elf.sync([:sleep, 1], "async sleep")
137
+ elf.fork([:sleep, 1], "async sleep")
138
+ elf.fork([:sleep, 1], "async sleep")
139
+ end
140
+ (Time.now-start).to_i.must_equal(2)
141
+ end
122
142
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: