pager 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/pager.rb +31 -0
- data/lib/pager/version.rb +3 -0
- data/pager.gemspec +17 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Nathan Weizenbaum
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Pager
|
2
|
+
|
3
|
+
Git-style automatic paging in Ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install pager
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
require 'pager'
|
12
|
+
|
13
|
+
class Example
|
14
|
+
include Pager
|
15
|
+
|
16
|
+
def output_lots_of_text
|
17
|
+
page
|
18
|
+
# any output after this line will be automatically paged
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
## History
|
23
|
+
|
24
|
+
This library is merely a packaged version of the [run_pager code snippet][blog]
|
25
|
+
by [Nathan Weizenbaum][nex3]. It was originally built for use with [cheat][] by
|
26
|
+
[Chris Wanstrath][defunkt]. The snipped was packaged as a gem by [Erik
|
27
|
+
Michaels-Ober][sferik] for use with his [t][] gem.
|
28
|
+
|
29
|
+
[blog]: http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
|
30
|
+
[nex3]: https://github.com/nex3
|
31
|
+
[cheat]: http://cheat.errtheblog.com/
|
32
|
+
[defunkt]: https://github.com/defunkt
|
33
|
+
[sferik]: https://github.com/sferik
|
34
|
+
[t]: https://github.com/sferik/t
|
35
|
+
|
36
|
+
# irb-pager
|
37
|
+
|
38
|
+
Many thanks to [Denis Knauf][DenisKnauf] for relinquishing the `pager` gem name
|
39
|
+
to this project. If you're looking for irb-pager, it can be found
|
40
|
+
[here][irb-pager].
|
41
|
+
|
42
|
+
[DenisKnauf]: https://github.com/DenisKnauf
|
43
|
+
[irb-pager]: https://github.com/DenisKnauf/irb-pager
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/pager.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "pager/version"
|
2
|
+
|
3
|
+
module Pager
|
4
|
+
|
5
|
+
def page
|
6
|
+
return if RUBY_PLATFORM =~ /win32/
|
7
|
+
return unless STDOUT.tty?
|
8
|
+
|
9
|
+
read, write = IO.pipe
|
10
|
+
|
11
|
+
unless Kernel.fork # Child process
|
12
|
+
STDOUT.reopen(write)
|
13
|
+
STDERR.reopen(write) if STDERR.tty?
|
14
|
+
read.close
|
15
|
+
write.close
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parent process, become pager
|
20
|
+
STDIN.reopen(read)
|
21
|
+
read.close
|
22
|
+
write.close
|
23
|
+
|
24
|
+
ENV['LESS'] = 'FSRX' # Don't page if the input is short enough
|
25
|
+
|
26
|
+
Kernel.select [STDIN] # Wait until we have input before we start the pager
|
27
|
+
pager = ENV['PAGER'] || 'less'
|
28
|
+
exec pager rescue exec "/bin/sh", "-c", pager
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/pager.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/pager/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Erik Michaels-Ober", "Nathan Weizenbaum"]
|
6
|
+
gem.email = ["sferik@gmail.com", "nex342@gmail.com"]
|
7
|
+
gem.description = %q{Git-style automatic paging}
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.homepage = "https://github.com/sferik/pager"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "pager"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Pager::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Erik Michaels-Ober
|
9
|
+
- Nathan Weizenbaum
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-01-19 00:00:00.000000000Z
|
14
|
+
dependencies: []
|
15
|
+
description: Git-style automatic paging
|
16
|
+
email:
|
17
|
+
- sferik@gmail.com
|
18
|
+
- nex342@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/pager.rb
|
29
|
+
- lib/pager/version.rb
|
30
|
+
- pager.gemspec
|
31
|
+
homepage: https://github.com/sferik/pager
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.8.15
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: Git-style automatic paging
|
55
|
+
test_files: []
|
56
|
+
has_rdoc:
|