command-runner 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -52,6 +52,10 @@ but defaults to the best one.
52
52
  ## Compatibility
53
53
  It works on
54
54
 
55
- - MRI 2.0.0 and 1.9.3
55
+ - 2.0.0
56
+ - 1.9.3
57
+ - 1.8.7
58
+ - REE
59
+ - JRuby (1.8 Mode)
56
60
 
57
61
  unless the travis build fails.
@@ -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
- with_modified_env(env) do
35
- start_time = Time.now
36
- output << `#{command} #{arguments}`
37
- end_time = Time.now
38
- end
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
- Message.new :process_id => $?.pid,
41
- :exit_code => $?.exitstatus,
42
- :finished => true,
43
- :time => (end_time - start_time).abs,
44
- :env => env,
45
- :options => {},
46
- :stdout => output,
47
- :line => line,
48
- :executed => true,
49
- :status => $?
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
@@ -7,7 +7,7 @@ module Command
7
7
 
8
8
  # (see Fake.available?)
9
9
  def self.available?
10
- Process.respond_to?(:spawn)
10
+ Process.respond_to?(:spawn) && !(RUBY_PLATFORM == "java" && RUBY_VERSION =~ /\A1\.9/)
11
11
  end
12
12
 
13
13
  # Initialize the backend.
@@ -3,7 +3,7 @@ module Command
3
3
  class Runner
4
4
 
5
5
  # The current version of Runner.
6
- VERSION = "0.2.0"
6
+ VERSION = "0.2.1"
7
7
 
8
8
  end
9
9
  end
@@ -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? :spawn
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((1.0/100)).of(0.5)
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.0
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-20 00:00:00.000000000 Z
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: