cocaine 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,9 +6,10 @@ module Cocaine
6
6
  def call(command, env = {})
7
7
  input, output = IO.pipe
8
8
  pid = spawn(env, command, :out => output)
9
- waitpid(pid)
10
9
  output.close
11
- input.read
10
+ result = input.read
11
+ waitpid(pid)
12
+ result
12
13
  end
13
14
 
14
15
  private
@@ -6,9 +6,10 @@ module Cocaine
6
6
  def call(command, env = {})
7
7
  input, output = IO.pipe
8
8
  pid = spawn(env, command, :out => output)
9
- waitpid(pid)
10
9
  output.close
11
- input.read
10
+ result = input.read
11
+ waitpid(pid)
12
+ result
12
13
  end
13
14
 
14
15
  private
@@ -1,3 +1,3 @@
1
1
  module Cocaine
2
- VERSION = "0.3.1".freeze
2
+ VERSION = "0.3.2".freeze
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Cocaine::CommandLine::BackticksRunner do
4
+ it_behaves_like 'a command that does not block'
5
+
4
6
  it 'runs the command given' do
5
7
  subject.call("echo hello").should == "hello\n"
6
8
  end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Cocaine::CommandLine::PosixRunner do
4
4
  if Cocaine::CommandLine::posix_spawn_available?
5
+ it_behaves_like 'a command that does not block'
6
+
5
7
  it 'runs the command given' do
6
8
  subject.call("echo hello").should == "hello\n"
7
9
  end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Cocaine::CommandLine::ProcessRunner do
4
4
  if Process.respond_to?(:spawn)
5
+ it_behaves_like "a command that does not block"
6
+
5
7
  it 'runs the command given' do
6
8
  subject.call("echo hello").should == "hello\n"
7
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'rspec'
2
- require './spec/support/with_exitstatus'
3
- require './spec/support/stub_os'
4
2
  require 'mocha'
5
3
  require 'bourne'
6
4
  require 'cocaine'
5
+ require 'timeout'
6
+ require 'tempfile'
7
+
8
+ Dir[File.dirname(__FILE__) + "/support/**.rb"].each{|support_file| require support_file }
7
9
 
8
10
  RSpec.configure do |config|
9
11
  config.mock_with :mocha
@@ -0,0 +1,12 @@
1
+ shared_examples_for "a command that does not block" do
2
+ it 'does not block if the command outputs a lot of data' do
3
+ garbage_file = Tempfile.new("garbage")
4
+ 10.times{ garbage_file.write("A" * 1024 * 1024) }
5
+
6
+ Timeout::timeout(5) do
7
+ output = subject.call("cat '#{garbage_file.path}'")
8
+ $?.exitstatus.should == 0
9
+ output.length.should == 10 * 1024 * 1024
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,102 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cocaine
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 2
10
+ version: 0.3.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jon Yurek
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-09-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: bourne
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: bourne
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: mocha
48
- requirement: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
49
38
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
57
52
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
70
60
  type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
73
66
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: posix-spawn
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
86
74
  type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: posix-spawn
87
78
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
79
+ requirement: &id005 !ruby/object:Gem::Requirement
89
80
  none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ type: :development
89
+ version_requirements: *id005
94
90
  description: A small library for doing (command) lines
95
91
  email: jyurek@thoughtbot.com
96
92
  executables: []
93
+
97
94
  extensions: []
95
+
98
96
  extra_rdoc_files: []
99
- files:
97
+
98
+ files:
100
99
  - .gitignore
101
100
  - .travis.yml
102
101
  - GOALS
@@ -119,38 +118,48 @@ files:
119
118
  - spec/cocaine/command_line/runners/process_runner_spec.rb
120
119
  - spec/cocaine/command_line_spec.rb
121
120
  - spec/spec_helper.rb
121
+ - spec/support/nonblocking_examples.rb
122
122
  - spec/support/stub_os.rb
123
123
  - spec/support/with_exitstatus.rb
124
124
  homepage: http://github.com/thoughtbot/cocaine
125
125
  licenses: []
126
+
126
127
  post_install_message:
127
128
  rdoc_options: []
128
- require_paths:
129
+
130
+ require_paths:
129
131
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
132
+ required_ruby_version: !ruby/object:Gem::Requirement
131
133
  none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
- required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ hash: 3
138
+ segments:
139
+ - 0
140
+ version: "0"
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
142
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
142
150
  requirements: []
151
+
143
152
  rubyforge_project:
144
153
  rubygems_version: 1.8.24
145
154
  signing_key:
146
155
  specification_version: 3
147
156
  summary: A small library for doing (command) lines
148
- test_files:
157
+ test_files:
149
158
  - spec/cocaine/command_line/runners/backticks_runner_spec.rb
150
159
  - spec/cocaine/command_line/runners/posix_runner_spec.rb
151
160
  - spec/cocaine/command_line/runners/process_runner_spec.rb
152
161
  - spec/cocaine/command_line_spec.rb
153
162
  - spec/spec_helper.rb
163
+ - spec/support/nonblocking_examples.rb
154
164
  - spec/support/stub_os.rb
155
165
  - spec/support/with_exitstatus.rb
156
- has_rdoc: