cocaine 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/README.md +16 -16
- data/Rakefile +1 -3
- data/cocaine.gemspec +24 -0
- data/lib/cocaine/command_line.rb +1 -1
- data/lib/cocaine/version.rb +1 -1
- data/spec/support/stub_os.rb +1 -1
- metadata +28 -9
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -13,22 +13,22 @@ Question? Idea? Problem? Bug? Something else? Comment? Concern? Like use questio
|
|
13
13
|
The basic, normal stuff.
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
line = Cocaine::CommandLine.
|
16
|
+
line = Cocaine::CommandLine.new("command", "some 'crazy' options")
|
17
17
|
line.command # => "command some 'crazy' options"
|
18
18
|
output = line.run # => Get you some output!
|
19
19
|
```
|
20
20
|
|
21
|
-
Allowing arguments to be dynamic
|
21
|
+
Allowing arguments to be dynamic:
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
line = Cocaine::CommandLine.new("convert", ":in -scale :resolution :out",
|
25
25
|
:in => "omg.jpg",
|
26
26
|
:resolution => "32x32",
|
27
|
-
:out => omg_thumb.jpg")
|
27
|
+
:out => "omg_thumb.jpg")
|
28
28
|
line.command # => "convert 'omg.jpg' -scale '32x32' 'omg_thumb.jpg'"
|
29
29
|
```
|
30
30
|
|
31
|
-
It prevents attempts at being bad
|
31
|
+
It prevents attempts at being bad:
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
line = Cocaine::CommandLine.new("cat", ":file", :file => "haha`rm -rf /`.txt")
|
@@ -38,7 +38,7 @@ line = Cocaine::CommandLine.new("cat", ":file", :file => "ohyeah?'`rm -rf /`.ha!
|
|
38
38
|
line.command # => "cat 'ohyeah?'\\''`rm -rf /`.ha!'"
|
39
39
|
```
|
40
40
|
|
41
|
-
You can ignore the result
|
41
|
+
You can ignore the result:
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
line = Cocaine::CommandLine.new("noisy", "--extra-verbose", :swallow_stderr => true)
|
@@ -48,7 +48,7 @@ line.command # => "noisy --extra-verbose 2>/dev/null"
|
|
48
48
|
line.command # => "noisy --extra-verbose 2>NUL"
|
49
49
|
```
|
50
50
|
|
51
|
-
If your command errors, you get an exception
|
51
|
+
If your command errors, you get an exception:
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
line = Cocaine::CommandLine.new("git", "commit")
|
@@ -59,7 +59,7 @@ rescue Cocaine::ExitStatusError => e
|
|
59
59
|
end
|
60
60
|
```
|
61
61
|
|
62
|
-
You don't have the command? You get an exception
|
62
|
+
You don't have the command? You get an exception:
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
line = Cocaine::CommandLine.new("lolwut")
|
@@ -70,7 +70,7 @@ rescue Cocaine::CommandNotFoundError => e
|
|
70
70
|
end
|
71
71
|
```
|
72
72
|
|
73
|
-
But don't fear, you can specify where to look for the command
|
73
|
+
But don't fear, you can specify where to look for the command:
|
74
74
|
|
75
75
|
```ruby
|
76
76
|
Cocaine::CommandLine.path = "/opt/bin"
|
@@ -78,24 +78,24 @@ line = Cocaine::CommandLine.new("lolwut")
|
|
78
78
|
line.command # => "lolwut", but it looks in /opt/bin for it.
|
79
79
|
```
|
80
80
|
|
81
|
-
You can even give it a bunch of places to look
|
81
|
+
You can even give it a bunch of places to look:
|
82
82
|
|
83
83
|
```ruby
|
84
|
-
FileUtils.rm("/opt/bin/lolwut")
|
85
|
-
`echo 'echo Hello' > /usr/local/bin/lolwut`
|
86
|
-
Cocaine::CommandLine.path = ["/opt/bin", "/usr/local/bin"]
|
87
|
-
line = Cocaine::CommandLine.new("lolwut")
|
88
|
-
line.run # => prints 'Hello', because it searches the path
|
84
|
+
FileUtils.rm("/opt/bin/lolwut")
|
85
|
+
`echo 'echo Hello' > /usr/local/bin/lolwut`
|
86
|
+
Cocaine::CommandLine.path = ["/opt/bin", "/usr/local/bin"]
|
87
|
+
line = Cocaine::CommandLine.new("lolwut")
|
88
|
+
line.run # => prints 'Hello', because it searches the path
|
89
89
|
```
|
90
90
|
|
91
|
-
Or
|
91
|
+
Or just put it in the command:
|
92
92
|
|
93
93
|
```ruby
|
94
94
|
line = Cocaine::CommandLine.new("/opt/bin/lolwut")
|
95
95
|
line.command # => "/opt/bin/lolwut"
|
96
96
|
```
|
97
97
|
|
98
|
-
If your command might return something non-zero, and you expect that, it's cool
|
98
|
+
If your command might return something non-zero, and you expect that, it's cool:
|
99
99
|
|
100
100
|
```ruby
|
101
101
|
line = Cocaine::CommandLine.new("/usr/bin/false", "", :expected_outcodes => [0, 1])
|
data/Rakefile
CHANGED
data/cocaine.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'cocaine/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "cocaine"
|
6
|
+
s.version = Cocaine::VERSION.dup
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.author = "Jon Yurek"
|
9
|
+
s.email = "jyurek@thoughtbot.com"
|
10
|
+
s.homepage = "http://www.thoughtbot.com/projects/cocaine"
|
11
|
+
s.summary = "A small library for doing (command) lines"
|
12
|
+
s.description = "A small library for doing (command) lines"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_development_dependency('rspec')
|
20
|
+
s.add_development_dependency('bourne')
|
21
|
+
s.add_development_dependency('mocha')
|
22
|
+
s.add_development_dependency('rake')
|
23
|
+
end
|
24
|
+
|
data/lib/cocaine/command_line.rb
CHANGED
data/lib/cocaine/version.rb
CHANGED
data/spec/support/stub_os.rb
CHANGED
@@ -9,6 +9,6 @@ module StubOS
|
|
9
9
|
|
10
10
|
def stub_os(host_string)
|
11
11
|
# http://blog.emptyway.com/2009/11/03/proper-way-to-detect-windows-platform-in-ruby/
|
12
|
-
|
12
|
+
RbConfig::CONFIG.stubs(:[]).with('host_os').returns(host_string)
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocaine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Yurek
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-12-13 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
@@ -60,6 +59,20 @@ dependencies:
|
|
60
59
|
version: "0"
|
61
60
|
type: :development
|
62
61
|
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
63
76
|
description: A small library for doing (command) lines
|
64
77
|
email: jyurek@thoughtbot.com
|
65
78
|
executables: []
|
@@ -69,18 +82,21 @@ extensions: []
|
|
69
82
|
extra_rdoc_files: []
|
70
83
|
|
71
84
|
files:
|
72
|
-
-
|
85
|
+
- .gitignore
|
86
|
+
- .travis.yml
|
87
|
+
- Gemfile
|
73
88
|
- LICENSE
|
89
|
+
- README.md
|
74
90
|
- Rakefile
|
91
|
+
- cocaine.gemspec
|
92
|
+
- lib/cocaine.rb
|
75
93
|
- lib/cocaine/command_line.rb
|
76
94
|
- lib/cocaine/exceptions.rb
|
77
95
|
- lib/cocaine/version.rb
|
78
|
-
- lib/cocaine.rb
|
79
96
|
- spec/cocaine/command_line_spec.rb
|
80
97
|
- spec/spec_helper.rb
|
81
98
|
- spec/support/stub_os.rb
|
82
99
|
- spec/support/with_exitstatus.rb
|
83
|
-
has_rdoc: true
|
84
100
|
homepage: http://www.thoughtbot.com/projects/cocaine
|
85
101
|
licenses: []
|
86
102
|
|
@@ -110,9 +126,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
126
|
requirements: []
|
111
127
|
|
112
128
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.6
|
129
|
+
rubygems_version: 1.8.6
|
114
130
|
signing_key:
|
115
131
|
specification_version: 3
|
116
132
|
summary: A small library for doing (command) lines
|
117
133
|
test_files:
|
118
134
|
- spec/cocaine/command_line_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/support/stub_os.rb
|
137
|
+
- spec/support/with_exitstatus.rb
|