shelltastic 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +38 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/README.md +4 -1
- data/lib/shelltastic/command_io.rb +0 -1
- data/lib/shelltastic/version.rb +1 -1
- data/spec/output_formatter_spec.rb +6 -6
- data/spec/shelltastic_spec.rb +22 -23
- data/spec/spec_helper.rb +0 -1
- data/spec/timer_spec.rb +6 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20dc0136766aee9463af6c60624299cf3501267df0eb529b4b0f609434aeb9a2
|
4
|
+
data.tar.gz: b1daff36ac9f708334715dad20aab079ed2ca43bea163c820373639342cf1142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbb7ebf36c4682cb9062ed86a04a033bc7d46a2ed87382ac9d3999573539228c5f5159327601731114423e0d5abeb0cdb24a54e725ada965372036a845ee2348
|
7
|
+
data.tar.gz: 307c95d92238bb2776dec664b4a6be2335541787d172cfa63334fe18181f3cb3a0291234d4d562766825586b33540160390cc79e504ac9069c7932746f785ee4
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Shelltastic
|
2
2
|
Shelltastic is simple *nix shell wrapper for ruby. You can pass a single command or multiple commands to run.
|
3
3
|
|
4
|
+
[](https://badge.fury.io/rb/shelltastic)
|
5
|
+
|
6
|
+
|
4
7
|
## Installation
|
5
8
|
|
6
9
|
Add this line to your application's Gemfile:
|
@@ -91,7 +94,7 @@ The parent process (you) will not wait for the child to finish or return any inf
|
|
91
94
|
|
92
95
|
This is useful if you want to run a command, but dont care about the output or exit status.
|
93
96
|
|
94
|
-
__BEWARE__ of long running commands that could fail.
|
97
|
+
__BEWARE__ of long running commands that could fail. ShellTastic detaches itself from the child command.
|
95
98
|
|
96
99
|
|
97
100
|
|
data/lib/shelltastic/version.rb
CHANGED
@@ -7,20 +7,20 @@ describe ShellTastic::OutputFormatter do
|
|
7
7
|
pid: "10000000",
|
8
8
|
error: "No such file or directory")
|
9
9
|
end
|
10
|
-
it "
|
11
|
-
@result.inspect.
|
10
|
+
it "returns a hash" do
|
11
|
+
expect(@result.inspect).to be_kind_of(Hash)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "allows to add key value pairs" do
|
15
15
|
@result.command = "date"
|
16
|
-
@result.inspect[:command].
|
16
|
+
expect(@result.inspect[:command]).to eq("date")
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "contains total time" do
|
20
20
|
timer = ShellTastic::Timer.new
|
21
21
|
@result.start = timer.start
|
22
22
|
@result.stop = timer.stop
|
23
23
|
@result.total_time = timer.total_time
|
24
|
-
@result.total_time.
|
24
|
+
expect(@result.total_time).to_not be_nil
|
25
25
|
end
|
26
26
|
end
|
data/spec/shelltastic_spec.rb
CHANGED
@@ -1,65 +1,64 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ShellTastic do
|
4
|
-
it "
|
4
|
+
it "runs a shell command"do
|
5
5
|
result = ShellTastic::Command.run("ls -l").first
|
6
|
-
result.fetch(:exitstatus).
|
6
|
+
expect(result.fetch(:exitstatus)).to eq(0)
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "runs multiple commands"do
|
10
10
|
result = ShellTastic::Command.run("ls -l", "date")
|
11
|
-
result.size.
|
11
|
+
expect(result.size).to eq(2)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "takes an array of commands to run"do
|
15
15
|
result = ShellTastic::Command.run(["ls -l", "date"])
|
16
|
-
result.size.
|
16
|
+
expect(result.size).to eq(2)
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "raises a command exception"do
|
21
21
|
expect {
|
22
|
-
|
22
|
+
result = ShellTastic::Command.run("lss -l")
|
23
23
|
}.to raise_error(ShellTastic::CommandException)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "alerts if command is empty or nil"do
|
27
27
|
expect {
|
28
28
|
ShellTastic::Command.run("")
|
29
29
|
}.to raise_error(ShellTastic::CommandException)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "returns `false` for error if there is not any errors"do
|
33
33
|
result = ShellTastic::Command.run("date").first
|
34
|
-
result[:error].
|
34
|
+
expect(result[:error]).to eq(false)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
result = ShellTastic::Command.run("du -sh /tmp/
|
39
|
-
result[:error].
|
37
|
+
it "returns an error and exit status"do
|
38
|
+
result = ShellTastic::Command.run("du -sh /tmp/inotexist").first
|
39
|
+
expect(result[:error]).not_to be_nil
|
40
|
+
expect(result[:exitstatus]).to eq(1)
|
40
41
|
end
|
41
42
|
|
42
43
|
# fire and forget
|
43
|
-
it "
|
44
|
+
it "fires a command in the background and has a pid"do
|
44
45
|
result = ShellTastic::Command.start("ls -al /").first
|
45
|
-
result[:pid].
|
46
|
+
expect(result[:pid]).not_to be_nil
|
46
47
|
end
|
47
48
|
|
48
|
-
it "
|
49
|
+
it "fires a command in the background and has a command populated"do
|
49
50
|
result = ShellTastic::Command.start("ls -al /").first
|
50
|
-
result[:command].
|
51
|
+
expect(result[:command]).to eq("ls -al /")
|
51
52
|
end
|
52
53
|
|
53
|
-
it "
|
54
|
+
it "fires a command in the background and has no ouput"do
|
54
55
|
result = ShellTastic::Command.start("ls -al /").first
|
55
|
-
result[:output].
|
56
|
+
expect(result[:output]).to be_nil
|
56
57
|
end
|
57
58
|
|
58
|
-
it "
|
59
|
+
it "fires a command in the background and raises an error"do
|
59
60
|
expect {
|
60
61
|
ShellTastic::Command.start("foobar").first
|
61
62
|
}.to raise_error(ShellTastic::CommandException)
|
62
63
|
end
|
63
|
-
|
64
|
-
|
65
64
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/timer_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ShellTastic::Timer do
|
4
|
-
it "
|
4
|
+
it "reports start time" do
|
5
5
|
start = ShellTastic::Timer.new.start
|
6
|
-
start.class.
|
6
|
+
expect(start.class).to eq(Time)
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "reports the stop time" do
|
10
10
|
stop = ShellTastic::Timer.new.stop
|
11
|
-
stop.class.
|
11
|
+
expect(stop.class).to eq(Time)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "reports total time" do
|
15
15
|
timer = ShellTastic::Timer.new
|
16
16
|
start = timer.start
|
17
17
|
sleep 2
|
18
18
|
stop = timer.stop
|
19
19
|
total = timer.total_time
|
20
|
-
total.round.
|
20
|
+
expect(total.round).to eq(2)
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelltastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bradley Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open4
|
@@ -60,6 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/ruby.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
65
66
|
- CHANGELOG.md
|
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: '0'
|
100
101
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
+
rubygems_version: 3.3.26
|
102
103
|
signing_key:
|
103
104
|
specification_version: 4
|
104
105
|
summary: Shelltastic is a simple *nix shell wrapper.
|