cocaine 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis.yml +1 -3
- data/Gemfile +1 -1
- data/README.md +9 -9
- data/cocaine.gemspec +1 -1
- data/lib/cocaine/command_line.rb +1 -1
- data/lib/cocaine/command_line/runners/posix_runner.rb +11 -4
- data/lib/cocaine/version.rb +1 -1
- data/spec/cocaine/command_line_spec.rb +1 -1
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmY5NWQ4N2NiMDRiZjU4NDExMzU5Y2M0YzU3YzZlMDdkYzcyZDgzMA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ODg5YjRhZDEzMmI0NWUxOWMxN2ZjZTkwNjdlNGVjOWMwMGIwNTIyYg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MGZkM2I3YmI2YmE5ODZjZGIzZDVmOWQwZTJkYjMwOGMwN2MzNmI5YmM5OTZl
|
10
|
+
MmQ3YWZiYTY3M2I2MWJkNDgxOGE5ZTI0NGY5ZTYwZTdkZDlkNDg0MWMxOTdj
|
11
|
+
ZGIzOGIxNmUzYzJkYWY5OTUyOGI1ZDZjZGQ2NzczNTc4MGJkMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjFmNTZhMjA5NWI4MjUyNWI2NzM3YjI3MmI0NzIzODJmM2UyNWRjOTg4NDky
|
14
|
+
OTU4NzY4ZTg3OTc3OTFiMTc0OGVjZDNiYmUyYTdmNTBlMjVkYmIxNzgxYzQz
|
15
|
+
MzIxYzc1MmIzMWExNGMzNTEwYzM1YzE2NTQ4N2Q4NGYwYmVmMzg=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,9 +18,9 @@ Interpolated arguments:
|
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
line = Cocaine::CommandLine.new("convert", ":in -scale :resolution :out")
|
21
|
-
line.command(:
|
22
|
-
:
|
23
|
-
:
|
21
|
+
line.command(in: "omg.jpg",
|
22
|
+
resolution: "32x32",
|
23
|
+
out: "omg_thumb.jpg")
|
24
24
|
# => "convert 'omg.jpg' -scale '32x32' 'omg_thumb.jpg'"
|
25
25
|
```
|
26
26
|
|
@@ -28,10 +28,10 @@ It prevents attempts at being bad:
|
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
line = Cocaine::CommandLine.new("cat", ":file")
|
31
|
-
line.command(:
|
31
|
+
line.command(file: "haha`rm -rf /`.txt") # => "cat 'haha`rm -rf /`.txt'"
|
32
32
|
|
33
33
|
line = Cocaine::CommandLine.new("cat", ":file")
|
34
|
-
line.command(:
|
34
|
+
line.command(file: "ohyeah?'`rm -rf /`.ha!") # => "cat 'ohyeah?'\\''`rm -rf /`.ha!'"
|
35
35
|
```
|
36
36
|
|
37
37
|
NOTE: It only does that for arguments interpolated via `run`, NOT arguments
|
@@ -46,7 +46,7 @@ line.run # => "hahawebserver"
|
|
46
46
|
You can ignore the result:
|
47
47
|
|
48
48
|
```ruby
|
49
|
-
line = Cocaine::CommandLine.new("noisy", "--extra-verbose", :
|
49
|
+
line = Cocaine::CommandLine.new("noisy", "--extra-verbose", swallow_stderr: true)
|
50
50
|
line.command # => "noisy --extra-verbose 2>/dev/null"
|
51
51
|
|
52
52
|
# ... and on Windows...
|
@@ -67,7 +67,7 @@ end
|
|
67
67
|
If your command might return something non-zero, and you expect that, it's cool:
|
68
68
|
|
69
69
|
```ruby
|
70
|
-
line = Cocaine::CommandLine.new("/usr/bin/false", "", :
|
70
|
+
line = Cocaine::CommandLine.new("/usr/bin/false", "", expected_outcodes: [0, 1])
|
71
71
|
begin
|
72
72
|
line.run
|
73
73
|
rescue Cocaine::ExitStatusError => e
|
@@ -114,8 +114,8 @@ line.command # => "/opt/bin/lolwut"
|
|
114
114
|
You can see what's getting run. The 'Command' part it logs is in green for visibility!
|
115
115
|
|
116
116
|
```ruby
|
117
|
-
line = Cocaine::CommandLine.new("echo", ":var", :
|
118
|
-
line.run(:
|
117
|
+
line = Cocaine::CommandLine.new("echo", ":var", logger: Logger.new(STDOUT))
|
118
|
+
line.run(var: "LOL!") # => Logs this with #info -> Command :: echo 'LOL!'
|
119
119
|
```
|
120
120
|
|
121
121
|
Or log every command:
|
data/cocaine.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.author = "Jon Yurek"
|
9
9
|
s.email = "jyurek@thoughtbot.com"
|
10
|
-
s.homepage = "
|
10
|
+
s.homepage = "https://github.com/thoughtbot/cocaine"
|
11
11
|
s.summary = "A small library for doing (command) lines"
|
12
12
|
s.description = "A small library for doing (command) lines"
|
13
13
|
s.license = "MIT"
|
data/lib/cocaine/command_line.rb
CHANGED
@@ -4,10 +4,9 @@ module Cocaine
|
|
4
4
|
class CommandLine
|
5
5
|
class PosixRunner
|
6
6
|
def self.available?
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
false
|
7
|
+
return @available unless @available.nil?
|
8
|
+
|
9
|
+
@available = posix_spawn_gem_available?
|
11
10
|
end
|
12
11
|
|
13
12
|
def self.supported?
|
@@ -42,6 +41,14 @@ module Cocaine
|
|
42
41
|
Process.waitpid(pid)
|
43
42
|
end
|
44
43
|
|
44
|
+
def self.posix_spawn_gem_available?
|
45
|
+
require 'posix/spawn'
|
46
|
+
true
|
47
|
+
rescue
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
private_class_method :posix_spawn_gem_available?
|
45
52
|
end
|
46
53
|
end
|
47
54
|
end
|
data/lib/cocaine/version.rb
CHANGED
@@ -14,7 +14,7 @@ describe Cocaine::CommandLine do
|
|
14
14
|
it "specifies the $PATH where the command can be found on unix" do
|
15
15
|
Cocaine::CommandLine.path = ["/path/to/command/dir", "/"]
|
16
16
|
cmd = Cocaine::CommandLine.new("ls")
|
17
|
-
cmd.command.should == "PATH=/path/to/command/dir:/:$PATH ls"
|
17
|
+
cmd.command.should == "PATH=/path/to/command/dir:/:$PATH; ls"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "specifies the %PATH% where the command can be found on windows" do
|
metadata
CHANGED
@@ -1,123 +1,123 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocaine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Yurek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.0.3
|
20
|
-
- -
|
20
|
+
- - <
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.0.3
|
30
|
-
- -
|
30
|
+
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rspec
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ! '>='
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bourne
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: mocha
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ! '>='
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ! '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rake
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ! '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ! '>='
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: activesupport
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ! '>='
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 3.0.0
|
96
|
-
- -
|
96
|
+
- - <
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '5.0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
101
|
version_requirements: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ! '>='
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: 3.0.0
|
106
|
-
- -
|
106
|
+
- - <
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '5.0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: pry
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - ! '>='
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ! '>='
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
description: A small library for doing (command) lines
|
@@ -126,8 +126,8 @@ executables: []
|
|
126
126
|
extensions: []
|
127
127
|
extra_rdoc_files: []
|
128
128
|
files:
|
129
|
-
-
|
130
|
-
-
|
129
|
+
- .gitignore
|
130
|
+
- .travis.yml
|
131
131
|
- GOALS
|
132
132
|
- Gemfile
|
133
133
|
- LICENSE
|
@@ -161,7 +161,7 @@ files:
|
|
161
161
|
- spec/support/stub_os.rb
|
162
162
|
- spec/support/unsetting_exitstatus.rb
|
163
163
|
- spec/support/with_exitstatus.rb
|
164
|
-
homepage:
|
164
|
+
homepage: https://github.com/thoughtbot/cocaine
|
165
165
|
licenses:
|
166
166
|
- MIT
|
167
167
|
metadata: {}
|
@@ -171,17 +171,17 @@ require_paths:
|
|
171
171
|
- lib
|
172
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- -
|
174
|
+
- - ! '>='
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- -
|
179
|
+
- - ! '>='
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.4.5
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: A small library for doing (command) lines
|