tty-pager 0.9.0 → 0.13.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 +5 -5
- data/CHANGELOG.md +81 -10
- data/README.md +247 -29
- data/lib/tty-pager.rb +1 -3
- data/lib/tty/pager.rb +82 -83
- data/lib/tty/pager/abstract.rb +138 -0
- data/lib/tty/pager/basic.rb +198 -56
- data/lib/tty/pager/null.rb +22 -4
- data/lib/tty/pager/system.rb +185 -73
- data/lib/tty/pager/version.rb +3 -3
- metadata +31 -89
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.travis.yml +0 -25
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -14
- data/Rakefile +0 -8
- data/appveyor.yml +0 -25
- data/examples/basic_pager.rb +0 -7
- data/examples/system_pager.rb +0 -9
- data/examples/temp.txt +0 -49
- data/spec/spec_helper.rb +0 -45
- data/spec/unit/basic/page_spec.rb +0 -142
- data/spec/unit/null/page_spec.rb +0 -23
- data/spec/unit/page_spec.rb +0 -40
- data/spec/unit/system/available_spec.rb +0 -50
- data/spec/unit/system/command_exists_spec.rb +0 -15
- data/spec/unit/system/new_spec.rb +0 -10
- data/spec/unit/system/page_spec.rb +0 -21
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-pager.gemspec +0 -28
@@ -1,50 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe TTY::Pager::SystemPager, '#available' do
|
4
|
-
let(:execs) { ['less', 'more'] }
|
5
|
-
|
6
|
-
subject(:pager) { described_class }
|
7
|
-
|
8
|
-
it 'finds available command' do
|
9
|
-
allow(pager).to receive(:executables).and_return(execs)
|
10
|
-
allow(pager).to receive(:command_exists?).with('less') { true }
|
11
|
-
allow(pager).to receive(:command_exists?).with('more') { false }
|
12
|
-
expect(pager.available).to eql('less')
|
13
|
-
end
|
14
|
-
|
15
|
-
it "doesn't find command" do
|
16
|
-
allow(pager).to receive(:executables).and_return(execs)
|
17
|
-
allow(pager).to receive(:command_exists?) { false }
|
18
|
-
expect(pager.available).to be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "takes precedence over other commands" do
|
22
|
-
allow(pager).to receive(:command_exists?).with('more') { true }
|
23
|
-
expect(pager.available('more')).to eql('more')
|
24
|
-
end
|
25
|
-
|
26
|
-
it "allows to query for available command" do
|
27
|
-
allow(pager).to receive(:available).with('less') { true }
|
28
|
-
expect(pager.available?('less')).to eq(true)
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when given nil, blank, and whitespace commands" do
|
32
|
-
let(:execs) { [nil, "", " ", "less"] }
|
33
|
-
|
34
|
-
it "does not error" do
|
35
|
-
allow(pager).to receive(:executables).and_return(execs)
|
36
|
-
allow(pager).to receive(:command_exists?).with('less') { true }
|
37
|
-
expect(pager.available).to eql('less')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when given a multi-word executable" do
|
42
|
-
let(:execs) { ["diff-so-fancy | less --tabs=4 -RFX"] }
|
43
|
-
|
44
|
-
it "finds the command" do
|
45
|
-
allow(pager).to receive(:executables).and_return(execs)
|
46
|
-
allow(pager).to receive(:command_exists?).with("diff-so-fancy") { true }
|
47
|
-
expect(pager.available).to eql(execs.first)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe TTY::Pager::SystemPager, '#command_exists?' do
|
4
|
-
subject(:pager) { described_class }
|
5
|
-
|
6
|
-
it "successfully checks command exists on the system" do
|
7
|
-
allow(TTY::Which).to receive(:exist?).with('less').and_return('/usr/bin/less').and_return(true)
|
8
|
-
expect(pager.command_exists?('less')).to eq(true)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "fails to check command exists on the system" do
|
12
|
-
allow(TTY::Which).to receive(:exist?).with('less').and_return(false)
|
13
|
-
expect(pager.command_exists?('less')).to eq(false)
|
14
|
-
end
|
15
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe TTY::Pager::SystemPager, '#new' do
|
4
|
-
it "raises error if system paging is not supported" do
|
5
|
-
allow(TTY::Pager::SystemPager).to receive(:available?).and_return(false)
|
6
|
-
expect {
|
7
|
-
TTY::Pager::SystemPager.new
|
8
|
-
}.to raise_error(TTY::Pager::Error, "TTY::Pager::SystemPager cannot be used on your system due to lack of appropriate pager executable. Install `less` like pager or try using `BasicPager` instead.")
|
9
|
-
end
|
10
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe TTY::Pager::SystemPager, '.page' do
|
4
|
-
it "executes the pager command in a subprocess" do
|
5
|
-
text = "I try all things, I achieve what I can.\n"
|
6
|
-
allow(TTY::Pager::SystemPager).to receive(:available?).and_return(true)
|
7
|
-
output = double(:output, :tty? => true)
|
8
|
-
pager = described_class.new(output: output)
|
9
|
-
write_io = spy
|
10
|
-
pid = 12345
|
11
|
-
|
12
|
-
allow(pager).to receive(:open).and_return(write_io)
|
13
|
-
allow(write_io).to receive(:pid).and_return(pid)
|
14
|
-
status = double(:status, :success? => true)
|
15
|
-
allow(Process).to receive(:waitpid2).with(pid, any_args).and_return([1, status])
|
16
|
-
|
17
|
-
expect(pager.page(text)).to eq(true)
|
18
|
-
expect(write_io).to have_received(:write).with(text)
|
19
|
-
expect(write_io).to have_received(:close)
|
20
|
-
end
|
21
|
-
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-pager.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'tty/pager/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "tty-pager"
|
8
|
-
spec.version = TTY::Pager::VERSION
|
9
|
-
spec.authors = ["Piotr Murach"]
|
10
|
-
spec.email = [""]
|
11
|
-
spec.summary = %q{Terminal output paging in a cross-platform way supporting all major ruby interpreters.}
|
12
|
-
spec.description = %q{Terminal output paging in a cross-platform way supporting all major ruby interpreters.}
|
13
|
-
spec.homepage = "https://github.com/piotrmurach/tty-pager"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency 'tty-screen', '~> 0.5.0'
|
22
|
-
spec.add_dependency 'tty-which', '~> 0.3.0'
|
23
|
-
spec.add_dependency 'verse', '~> 0.5.0'
|
24
|
-
|
25
|
-
spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
|
26
|
-
spec.add_development_dependency 'rake'
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.6.0'
|
28
|
-
end
|