tty-command 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +1 -1
- data/README.md +44 -44
- data/lib/tty-command.rb +1 -1
- data/lib/tty/command.rb +18 -18
- data/lib/tty/command/child_process.rb +9 -9
- data/lib/tty/command/cmd.rb +11 -11
- data/lib/tty/command/dry_runner.rb +3 -3
- data/lib/tty/command/exit_error.rb +1 -1
- data/lib/tty/command/printers/abstract.rb +8 -10
- data/lib/tty/command/printers/null.rb +1 -4
- data/lib/tty/command/printers/pretty.rb +10 -15
- data/lib/tty/command/printers/progress.rb +3 -8
- data/lib/tty/command/printers/quiet.rb +3 -7
- data/lib/tty/command/process_runner.rb +25 -17
- data/lib/tty/command/truncator.rb +3 -3
- data/lib/tty/command/version.rb +1 -1
- metadata +20 -68
- data/Rakefile +0 -10
- data/bin/console +0 -6
- data/bin/setup +0 -6
- data/examples/bash.rb +0 -12
- data/examples/basic.rb +0 -9
- data/examples/buffer.rb +0 -4
- data/examples/env.rb +0 -9
- data/examples/logger.rb +0 -10
- data/examples/output.rb +0 -10
- data/examples/pty.rb +0 -9
- data/examples/redirect_stderr.rb +0 -10
- data/examples/redirect_stdin.rb +0 -15
- data/examples/redirect_stdout.rb +0 -10
- data/examples/stdin_input.rb +0 -10
- data/examples/threaded.rb +0 -14
- data/examples/timeout.rb +0 -11
- data/examples/timeout_input.rb +0 -12
- data/examples/wait.rb +0 -21
- data/spec/spec_helper.rb +0 -78
- data/spec/unit/binmode_spec.rb +0 -29
- data/spec/unit/cmd_spec.rb +0 -152
- data/spec/unit/dry_run_spec.rb +0 -42
- data/spec/unit/exit_error_spec.rb +0 -25
- data/spec/unit/input_spec.rb +0 -13
- data/spec/unit/output_spec.rb +0 -25
- data/spec/unit/printer_spec.rb +0 -50
- data/spec/unit/printers/custom_spec.rb +0 -48
- data/spec/unit/printers/null_spec.rb +0 -36
- data/spec/unit/printers/pretty_spec.rb +0 -172
- data/spec/unit/printers/progress_spec.rb +0 -45
- data/spec/unit/printers/quiet_spec.rb +0 -71
- data/spec/unit/pty_spec.rb +0 -62
- data/spec/unit/redirect_spec.rb +0 -103
- data/spec/unit/result_spec.rb +0 -64
- data/spec/unit/ruby_spec.rb +0 -20
- data/spec/unit/run_spec.rb +0 -159
- data/spec/unit/test_spec.rb +0 -11
- data/spec/unit/timeout_spec.rb +0 -36
- data/spec/unit/truncator_spec.rb +0 -73
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-command.gemspec +0 -30
data/spec/unit/test_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe TTY::Command, '#test' do
|
4
|
-
it "implements classic bash command" do
|
5
|
-
cmd = TTY::Command.new
|
6
|
-
result = double(:success? => true)
|
7
|
-
allow(cmd).to receive(:run!).with(:test, '-e /etc/passwd').and_return(result)
|
8
|
-
expect(cmd.test("-e /etc/passwd")).to eq(true)
|
9
|
-
expect(cmd).to have_received(:run!)
|
10
|
-
end
|
11
|
-
end
|
data/spec/unit/timeout_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe TTY::Command, '#run' do
|
4
|
-
it "times out infinite process without input or output" do
|
5
|
-
infinite = fixtures_path('infinite_no_output')
|
6
|
-
output = StringIO.new
|
7
|
-
cmd = TTY::Command.new(output: output)
|
8
|
-
|
9
|
-
expect {
|
10
|
-
cmd.run("ruby #{infinite}", timeout: 0.1)
|
11
|
-
}.to raise_error(TTY::Command::TimeoutExceeded)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "times out an infite process with constant output" do
|
15
|
-
infinite = fixtures_path('infinite_output')
|
16
|
-
output = StringIO.new
|
17
|
-
cmd = TTY::Command.new(output: output, timeout: 0.1)
|
18
|
-
|
19
|
-
expect {
|
20
|
-
cmd.run("ruby #{infinite}")
|
21
|
-
}.to raise_error(TTY::Command::TimeoutExceeded)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "times out an infinite process with constant input data" do
|
25
|
-
cli = fixtures_path('infinite_input')
|
26
|
-
output = StringIO.new
|
27
|
-
cmd = TTY::Command.new(output: output)
|
28
|
-
|
29
|
-
range = 1..Float::INFINITY
|
30
|
-
infinite_input = range.lazy.map { |x| "hello" }.first(100).join("\n")
|
31
|
-
|
32
|
-
expect {
|
33
|
-
cmd.run("ruby #{cli}", input: infinite_input, timeout: 0.1)
|
34
|
-
}.to raise_error(TTY::Command::TimeoutExceeded)
|
35
|
-
end
|
36
|
-
end
|
data/spec/unit/truncator_spec.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe TTY::Command::Truncator do
|
4
|
-
it "writes nil content" do
|
5
|
-
truncator = described_class.new(max_size: 2)
|
6
|
-
|
7
|
-
truncator.write(nil)
|
8
|
-
|
9
|
-
expect(truncator.read).to eq('')
|
10
|
-
end
|
11
|
-
|
12
|
-
it "writes content within maximum size" do
|
13
|
-
truncator = described_class.new(max_size: 2)
|
14
|
-
|
15
|
-
truncator.write("a")
|
16
|
-
|
17
|
-
expect(truncator.read).to eq("a")
|
18
|
-
end
|
19
|
-
|
20
|
-
it "writes both prefix and suffix" do
|
21
|
-
truncator = described_class.new(max_size: 2)
|
22
|
-
|
23
|
-
truncator.write("abc")
|
24
|
-
truncator.write("d")
|
25
|
-
|
26
|
-
expect(truncator.read).to eq("abcd")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "writes more bytes letter" do
|
30
|
-
truncator = described_class.new(max_size: 1000)
|
31
|
-
multibytes_string = "’test’"
|
32
|
-
|
33
|
-
truncator.write(multibytes_string)
|
34
|
-
|
35
|
-
expect(truncator.read).to eq(multibytes_string)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "overflows prefix and suffix " do
|
39
|
-
truncator = described_class.new(max_size: 2)
|
40
|
-
|
41
|
-
truncator.write("abc")
|
42
|
-
truncator.write("d")
|
43
|
-
truncator.write("e")
|
44
|
-
|
45
|
-
expect(truncator.read).to eq("ab\n... omitting 1 bytes ...\nde")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "omits bytes " do
|
49
|
-
truncator = described_class.new(max_size: 2)
|
50
|
-
|
51
|
-
truncator.write("abc___________________yz")
|
52
|
-
|
53
|
-
expect(truncator.read).to eq("ab\n... omitting 20 bytes ...\nyz")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "reflows suffix with less content" do
|
57
|
-
truncator = described_class.new(max_size: 2)
|
58
|
-
|
59
|
-
truncator.write("abc____________________y")
|
60
|
-
truncator.write("z")
|
61
|
-
|
62
|
-
expect(truncator.read).to eq("ab\n... omitting 21 bytes ...\nyz")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "reflows suffix with more content" do
|
66
|
-
truncator = described_class.new(max_size: 2)
|
67
|
-
|
68
|
-
truncator.write("abc____________________y")
|
69
|
-
truncator.write("zwx")
|
70
|
-
|
71
|
-
expect(truncator.read).to eq("ab\n... omitting 23 bytes ...\nwx")
|
72
|
-
end
|
73
|
-
end
|
data/tasks/console.rake
DELETED
data/tasks/coverage.rake
DELETED
data/tasks/spec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
desc 'Run all specs'
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :spec do
|
12
|
-
desc 'Run unit specs'
|
13
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Run integration specs'
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue LoadError
|
24
|
-
%w[spec spec:unit spec:integration].each do |name|
|
25
|
-
task name do
|
26
|
-
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/tty-command.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'tty/command/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "tty-command"
|
7
|
-
spec.version = TTY::Command::VERSION
|
8
|
-
spec.authors = ["Piotr Murach"]
|
9
|
-
spec.email = ["me@piotrmurach.com"]
|
10
|
-
|
11
|
-
spec.summary = %q{Execute shell commands with pretty output logging and capture their stdout, stderr and exit status.}
|
12
|
-
spec.description = %q{Execute shell commands with pretty output logging and capture their stdout, stderr and exit status. Redirect stdin, stdout and stderr of each command to a file or a string.}
|
13
|
-
spec.homepage = "https://piotrmurach.github.io/tty"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = Dir['{lib,spec,examples}/**/*.rb']
|
17
|
-
spec.files += Dir['{bin,tasks}/*', 'tty-command.gemspec']
|
18
|
-
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
19
|
-
spec.bindir = "exe"
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = ["lib"]
|
22
|
-
|
23
|
-
spec.required_ruby_version = '>= 2.0.0'
|
24
|
-
|
25
|
-
spec.add_dependency 'pastel', '~> 0.7.0'
|
26
|
-
|
27
|
-
spec.add_development_dependency 'bundler', '>= 1.5.0'
|
28
|
-
spec.add_development_dependency 'rake'
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
-
end
|