command-runner 0.2.0 → 0.2.1
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.
- data/README.md +5 -1
- data/lib/command/runner/backends/backticks.rb +18 -16
- data/lib/command/runner/backends/spawn.rb +1 -1
- data/lib/command/runner/version.rb +1 -1
- data/spec/backticks_spec.rb +21 -0
- data/spec/spawn_spec.rb +2 -2
- metadata +3 -2
data/README.md
CHANGED
@@ -3,7 +3,7 @@ module Command
|
|
3
3
|
module Backends
|
4
4
|
|
5
5
|
# A backend that uses ticks to do its bidding.
|
6
|
-
class Backticks
|
6
|
+
class Backticks < Fake
|
7
7
|
|
8
8
|
# Returns whether or not this backend is avialable on this
|
9
9
|
# platform.
|
@@ -31,22 +31,24 @@ module Command
|
|
31
31
|
start_time = nil
|
32
32
|
end_time = nil
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
future do
|
35
|
+
with_modified_env(env) do
|
36
|
+
start_time = Time.now
|
37
|
+
output << `#{command} #{arguments}`
|
38
|
+
end_time = Time.now
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
Message.new :process_id => $?.pid,
|
42
|
+
:exit_code => $?.exitstatus,
|
43
|
+
:finished => true,
|
44
|
+
:time => (end_time - start_time).abs,
|
45
|
+
:env => env,
|
46
|
+
:options => {},
|
47
|
+
:stdout => output,
|
48
|
+
:line => [command, arguments].join(' '),
|
49
|
+
:executed => true,
|
50
|
+
:status => $?
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
private
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe Command::Runner::Backends::Backticks do
|
2
|
+
|
3
|
+
it "is available" do
|
4
|
+
Command::Runner::Backends::Backticks.should be_available
|
5
|
+
end
|
6
|
+
|
7
|
+
it "returns a message" do
|
8
|
+
value = subject.call("echo", "hello")
|
9
|
+
value.should be_instance_of Command::Runner::Message
|
10
|
+
value.should be_executed
|
11
|
+
end
|
12
|
+
|
13
|
+
it "doesn't block" do
|
14
|
+
start_time = Time.now
|
15
|
+
value = subject.call("sleep", "0.5")
|
16
|
+
end_time = Time.now
|
17
|
+
|
18
|
+
(end_time - start_time).should be_within((1.0/100)).of(0)
|
19
|
+
value.time.should be_within(0.1).of(0.5)
|
20
|
+
end
|
21
|
+
end
|
data/spec/spawn_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Command::Runner::Backends::Spawn do
|
2
2
|
|
3
|
-
next unless Process.respond_to?
|
3
|
+
next unless Process.respond_to?(:spawn) && !(RUBY_PLATFORM == "java" && RUBY_VERSION =~ /\A1\.9/)
|
4
4
|
|
5
5
|
it "is available" do
|
6
6
|
Command::Runner::Backends::Spawn.should be_available
|
@@ -18,7 +18,7 @@ describe Command::Runner::Backends::Spawn do
|
|
18
18
|
end_time = Time.now
|
19
19
|
|
20
20
|
(end_time - start_time).should be_within((1.0/100)).of(0)
|
21
|
-
value.time.should be_within((
|
21
|
+
value.time.should be_within((2.0/100)).of(0.5)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "can not be available" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: promise
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/command/runner.rb
|
79
79
|
- spec/messenger_spec.rb
|
80
80
|
- spec/spawn_spec.rb
|
81
|
+
- spec/backticks_spec.rb
|
81
82
|
homepage: http://github.com/redjazz96/command-runner
|
82
83
|
licenses: []
|
83
84
|
post_install_message:
|