kommando 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +16 -0
- data/README.md +3 -1
- data/bin/e2e +20 -0
- data/bin/reinstall +7 -0
- data/examples/exit.rb +11 -0
- data/examples/ping.rb +6 -0
- data/examples/uptime.rb +6 -0
- data/kommando.gemspec +2 -0
- data/lib/kommando.rb +47 -3
- data/lib/kommando/buffer.rb +15 -0
- data/lib/kommando/error.rb +4 -0
- data/lib/kommando/version.rb +2 -2
- metadata +38 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60fcbc413614b3241e6a3f821c4d906b9c3dde0c
|
4
|
+
data.tar.gz: 1dcd5140f6d593f798d7b1fad08f91ca73c4bbbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e19c3f5ceeef34e4cc387f2eaa434ee92a8a4fc30c58af62338f0aefa6c84fabdee3aaf413bf1b460ffb51c7d39cd9f17b02724c7b7e18cd3336a484b4339b2e
|
7
|
+
data.tar.gz: 40d62317bb523c2b8dd29dd5f2f9cb8f3b892cdf36df42e885636cbb08dfb349835a6e5fe760ff94809cd5d7e574ae1444aab6cc710efde91ef3823599020297
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.0.2
|
4
|
+
Actually useful intial release.
|
5
|
+
|
6
|
+
- FEAT: Runs commands with arguments `Kommando.new "ping -c 1 google.com"`
|
7
|
+
- FEAT: Captures error code in `k.code`
|
8
|
+
- EXAMPLES: `ping` and `exit` added.
|
9
|
+
|
10
|
+
## 0.0.1
|
11
|
+
|
12
|
+
Initial release.
|
13
|
+
|
14
|
+
- FEAT: Runs command without arguments.
|
15
|
+
- FEAT: Records the standard out in `k.out`
|
16
|
+
- EXAMPLES: `uptime`
|
data/README.md
CHANGED
@@ -24,7 +24,9 @@ TODO: Write usage instructions here
|
|
24
24
|
|
25
25
|
## Development
|
26
26
|
|
27
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the specs. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
`bin/e2e` runs all Kommando files in `examples/` with `kommando`.
|
28
30
|
|
29
31
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
32
|
|
data/bin/e2e
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "./lib/kommando"
|
4
|
+
|
5
|
+
find_examples = Kommando.new "find examples -type f -name *"
|
6
|
+
find_examples.run
|
7
|
+
|
8
|
+
for example in find_examples.out.split("\r\n") do
|
9
|
+
print "Running #{example} ".ljust(74, ".")
|
10
|
+
example = Kommando.new "ruby #{example}"
|
11
|
+
example.run
|
12
|
+
|
13
|
+
raise "Example #{example} did not exit cleanly" unless example.code == 0
|
14
|
+
|
15
|
+
puts " done"
|
16
|
+
end
|
17
|
+
|
18
|
+
puts ""
|
19
|
+
puts "all good."
|
20
|
+
exit 0
|
data/bin/reinstall
ADDED
data/examples/exit.rb
ADDED
data/examples/ping.rb
ADDED
data/examples/uptime.rb
ADDED
data/kommando.gemspec
CHANGED
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency "rspec-autotest", "~> 1.0"
|
26
|
+
spec.add_development_dependency "ZenTest", "~> 4.11"
|
25
27
|
end
|
data/lib/kommando.rb
CHANGED
@@ -1,5 +1,49 @@
|
|
1
|
-
require "
|
1
|
+
require "pty"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative "kommando/error"
|
4
|
+
require_relative "kommando/version"
|
5
|
+
require_relative "kommando/buffer"
|
6
|
+
|
7
|
+
class Kommando
|
8
|
+
|
9
|
+
def initialize(cmd)
|
10
|
+
@cmd = cmd
|
11
|
+
@stdout = Buffer.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
command, *args = @cmd.split " "
|
16
|
+
begin
|
17
|
+
PTY.spawn(command, *args) do |stdout, stdin, pid|
|
18
|
+
Thread.abort_on_exception = true
|
19
|
+
|
20
|
+
thread_stdout = Thread.new do
|
21
|
+
while true do
|
22
|
+
break if stdout.eof?
|
23
|
+
|
24
|
+
c = stdout.getc
|
25
|
+
@stdout.append c if c
|
26
|
+
end
|
27
|
+
end
|
28
|
+
thread_stdout.join
|
29
|
+
|
30
|
+
# http://stackoverflow.com/a/7263243
|
31
|
+
Process.wait(pid)
|
32
|
+
|
33
|
+
@code = $?.exitstatus
|
34
|
+
end
|
35
|
+
rescue => ex
|
36
|
+
raise Kommando::Error, "Command '#{command}' not found"
|
37
|
+
end
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def out
|
43
|
+
@stdout.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
def code
|
47
|
+
@code
|
48
|
+
end
|
5
49
|
end
|
data/lib/kommando/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
class Kommando
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kommando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-autotest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ZenTest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.11'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.11'
|
55
83
|
description: Great for integration testing.
|
56
84
|
email:
|
57
85
|
- matti.paksula@iki.fi
|
@@ -64,14 +92,22 @@ files:
|
|
64
92
|
- ".ruby-gemset"
|
65
93
|
- ".ruby-version"
|
66
94
|
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
67
96
|
- Gemfile
|
68
97
|
- LICENSE.txt
|
69
98
|
- README.md
|
70
99
|
- Rakefile
|
71
100
|
- bin/console
|
101
|
+
- bin/e2e
|
102
|
+
- bin/reinstall
|
72
103
|
- bin/setup
|
104
|
+
- examples/exit.rb
|
105
|
+
- examples/ping.rb
|
106
|
+
- examples/uptime.rb
|
73
107
|
- kommando.gemspec
|
74
108
|
- lib/kommando.rb
|
109
|
+
- lib/kommando/buffer.rb
|
110
|
+
- lib/kommando/error.rb
|
75
111
|
- lib/kommando/version.rb
|
76
112
|
homepage: http://github.com/matti/kommando
|
77
113
|
licenses:
|