spirit_hands 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.gitignore +17 -0
  4. data/.hound.yml +20 -0
  5. data/.pryrc +2 -0
  6. data/.rubocop.yml +20 -0
  7. data/.ruby-gemset +1 -0
  8. data/CHANGELOG.md +147 -0
  9. data/CONTRIBUTING.md +18 -0
  10. data/CONTRIBUTORS.md +10 -0
  11. data/Gemfile +3 -0
  12. data/LICENSE.md +22 -0
  13. data/README.md +133 -0
  14. data/Rakefile +3 -0
  15. data/gem-public_cert.pem +32 -0
  16. data/lib/spirit_hands/hirb/fixes/enabled.rb +38 -0
  17. data/lib/spirit_hands/hirb/fixes/pager.rb +144 -0
  18. data/lib/spirit_hands/hirb/fixes/util.rb +23 -0
  19. data/lib/spirit_hands/hirb/fixes/view.rb +10 -0
  20. data/lib/spirit_hands/hirb/fixes.rb +5 -0
  21. data/lib/spirit_hands/hirb.rb +2 -0
  22. data/lib/spirit_hands/load_plugins.rb +10 -0
  23. data/lib/spirit_hands/mattr_accessor_with_default.rb +48 -0
  24. data/lib/spirit_hands/melody.rb +41 -0
  25. data/lib/spirit_hands/options/color.rb +12 -0
  26. data/lib/spirit_hands/options/hirb.rb +34 -0
  27. data/lib/spirit_hands/options/less/colorize.rb +42 -0
  28. data/lib/spirit_hands/options/less/show_raw_unicode.rb +38 -0
  29. data/lib/spirit_hands/options/less.rb +2 -0
  30. data/lib/spirit_hands/options.rb +57 -0
  31. data/lib/spirit_hands/plugin.rb +28 -0
  32. data/lib/spirit_hands/print.rb +72 -0
  33. data/lib/spirit_hands/prompt/base.rb +249 -0
  34. data/lib/spirit_hands/prompt/main.rb +18 -0
  35. data/lib/spirit_hands/prompt/multiline.rb +17 -0
  36. data/lib/spirit_hands/prompt.rb +13 -0
  37. data/lib/spirit_hands/railtie.rb +7 -0
  38. data/lib/spirit_hands/terminal.rb +14 -0
  39. data/lib/spirit_hands/version.rb +3 -0
  40. data/lib/spirit_hands.rb +13 -0
  41. data/spirit_hands.gemspec +37 -0
  42. data.tar.gz.sig +0 -0
  43. metadata +258 -0
  44. metadata.gz.sig +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d5a96385a8b9de971135d75dbdd00dccea10ccb
4
+ data.tar.gz: 944d1c9df0862f1f742f038afa930061e8785650
5
+ SHA512:
6
+ metadata.gz: 9ecae820d327c22323107267854875e6d953d3444ed2e88f19240bed25cc0ff25997e61c2449ea94bde874cac7a25bff8d04b42083ace2c4060a68b56e7967f1
7
+ data.tar.gz: 4534bb26300083fd4f1904c0951a81e42ada1a16d567fce7414ccb99de5901d7eee19d35a6af002ae8ac0306db736a822c8ab4f67041eedd451fc6ef4bf006d1
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.hound.yml ADDED
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/EachWithObject:
5
+ Enabled: false
6
+
7
+ Style/Encoding:
8
+ EnforcedStyle: when_needed
9
+
10
+ Style/FormatString:
11
+ Enabled: false
12
+
13
+ Style/HashSyntax:
14
+ EnforcedStyle: hash_rockets
15
+
16
+ Style/SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
data/.pryrc ADDED
@@ -0,0 +1,2 @@
1
+ require 'jazz_fingers'
2
+ JazzFingers.melody!
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/EachWithObject:
5
+ Enabled: false
6
+
7
+ Style/Encoding:
8
+ EnforcedStyle: when_needed
9
+
10
+ Style/FormatString:
11
+ Enabled: false
12
+
13
+ Style/HashSyntax:
14
+ EnforcedStyle: hash_rockets
15
+
16
+ Style/SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ jazz_fingers
data/CHANGELOG.md ADDED
@@ -0,0 +1,147 @@
1
+ ## 2.0.0 (2015-05-27)
2
+ * Way more configurable
3
+
4
+ ## 1.0.0 (2015-02-05)
5
+ * Downgrade [pry-byebug][pry-byebug] to v1.3.3
6
+
7
+ ## 0.5.5 (2015-02-03)
8
+
9
+ * Update [pry-byebug][pry-byebug] to v2.0.0
10
+ * Update [awesome_print][awesome_print] to v1.6.1
11
+
12
+ ## 0.5.4 (2014-11-06)
13
+
14
+ * Remove [pry-stack_explorer][pry-stack_explorer]
15
+
16
+ ## 0.5.3 (2014-11-04)
17
+
18
+ * Using [pry-byebug][pry-byebug] to use ruby >= 2.0.0.
19
+ * Switched [coolline][coolline] with [pry-coolline][pry-coolline]
20
+ * Upgrade [pry][pry] to 0.10, [pry-doc][pry-doc] to 0.6
21
+ * Rename to `SpiritHands` to allow releasing.
22
+
23
+ ## 0.5.2 (2013-10-24)
24
+
25
+ * Upgrade [pry-rails][pry-rails] to the latest 0.3.2,
26
+ [awesome_print][awesome_print] to 1.2 and loosen it's dependency, and removed
27
+ [coderay][coderay] as an explicit dependency since [pry][pry] already includes
28
+ it.
29
+
30
+ ## 0.5.1 (2013-06-28)
31
+
32
+ * Upgrade [pry-rails][pry-rails] to the latest 0.3.1, [pry-doc][pry-doc] 0.4.6,
33
+ [coolline][coolline] 0.4.2.
34
+
35
+
36
+ ## 0.5.0 (2013-03-13)
37
+
38
+ * Rails 4, Ruby 2.0.0 compatibility.
39
+ * Upgrade [pry][pry] to the latest 0.9.12,
40
+ [pry-stack_explorer][pry-stack_explorer] 0.4.9, [pry-remote][pry-remote]
41
+ 0.1.7, [pry-debugger][pry-debugger] 0.2.2, [hirb][hirb] 0.7.1,
42
+ [coderay][coderay] 1.0.9.
43
+
44
+
45
+ ## 0.4.0 (2012-12-27)
46
+
47
+ * Add [pry-rails][pry-rails] 0.2.2 for maintained console hooks and new
48
+ `show-routes`, `show-models`, and `show-middleware` commands.
49
+ * Add `SpiritHands.colored_prompt` and `SpiritHands.prompt_separator` options.
50
+ Detect readline library to turn off incompatible colored prompt or Unicode
51
+ prompt separator where appropriate. Fixes #1 and #2.
52
+ * Upgrade [pry][pry] to the latest 0.9.10, [pry-doc][pry-doc] 0.4.4,
53
+ [pry-stack_explorer][pry-stack_explorer] 0.4.7, [pry-remote][pry-remote]
54
+ 0.1.6, [pry-debugger][pry-debugger] 0.2.1, [hirb][hirb] 0.7.0,
55
+ [Coolline][coolline] 0.4.0, [coderay][coderay] 1.0.8,
56
+ [awesome_print][awesome_print] 1.1.0. Fixes #4.
57
+
58
+ ## 0.3.1 (2012-06-11)
59
+
60
+ * Upgrade [pry-debugger][pry-debugger] to 0.2.0.
61
+
62
+ ## 0.3.0 (2012-06-07)
63
+
64
+ * Replace [pry-nav][pry-nav] with [pry-debugger][pry-debugger] for improved
65
+ performance and no segfaults. `SpiritHands.enable_pry_nav` removed.
66
+ * Upgrade [pry][pry] to the latest 0.9.9, [pry-doc][pry-doc] 0.4.2,
67
+ [pry-git][pry-git] 0.2.3, [pry-stack_explorer][pry-stack_explorer] 0.4.2,
68
+ [pry-remote][pry-remote] 0.1.4, [coderay][coderay] 1.0.6.
69
+
70
+ ## 0.2.0 (2012-03-19)
71
+
72
+ * Add [pry-stack_explorer][pry-stack_explorer] 0.4.1.
73
+ * Upgrade [pry-remote][pry-remote] to 0.1.1 and [pry-nav][pry-nav] to 0.2.0.
74
+ * Upgrade recommended gem minor versions: [pry][pry] 0.9.8.4, [pry-doc][pry-doc]
75
+ 0.4.1, [hirb][hirb] 0.6.2, and [coderay][coderay] 1.0.5.
76
+
77
+ ## 0.1.2 (2012-01-23)
78
+
79
+ * Improved Rails 3.2 compatibility. Console methods like `app`, `new_session`,
80
+ `reload!`, `helper`, and `controller` work as expected.
81
+
82
+ ## 0.1.1 (2012-01-20)
83
+
84
+ * Rails 3.2 compatibility
85
+
86
+ ## 0.1.0 (2012-01-04)
87
+
88
+ * For performance, enable [pry-nav][pry-nav] only on MRI 1.9.3 by default. To
89
+ use on MRI 1.9.2, add `SpiritHands.enable_pry_nav` to a Rails initializer.
90
+ * Due to buggy behavior, syntax highlighting as you type via
91
+ [Coolline][coolline] and [Coderay][coderay] is disabled by default. Enable
92
+ with `SpiritHands.enable_syntax_highlighting_as_you_type` in a Rails
93
+ initializer. MRI 1.9.3 only.
94
+ * Fix [Hirb][hirb] support.
95
+ * Upgrade [awesome_print][awesome_print] to 1.0.2.
96
+
97
+ ## 0.0.6 (2011-12-03)
98
+
99
+ * Add line numbers to the prompt for easy reference when using `_in_` and
100
+ `_out`.
101
+ * Upgrade [pry-nav][pry-nav] to 0.0.4.
102
+
103
+
104
+ ## 0.0.5 (2011-12-01)
105
+
106
+ * Add [Hirb][hirb] support. Enable with `Hirb.enable` in the console.
107
+ * Upgrade [pry-nav][pry-nav] to 0.0.3.
108
+
109
+
110
+ ## 0.0.4 (2011-11-30)
111
+
112
+ * Add explicit requires for pry plugin gems.
113
+
114
+
115
+ ## 0.0.3 (2011-11-30)
116
+
117
+ * Add [pry-nav][pry-nav].
118
+ * Upgrade [awesome_print][awesome_print] to 1.0.1.
119
+
120
+
121
+ ## 0.0.2 (2011-11-25)
122
+
123
+ * Add [pry-doc][pry-doc].
124
+
125
+
126
+ ## 0.0.1 (2011-11-25)
127
+
128
+ * First release. Combine [pry][pry], [awesome_print][awesome_print],
129
+ [coolline][coolline] + [coderay][coderay], [pry-remote][pry-remote],
130
+ [pry-git][pry-git]. Bit of glue to replace IRB with pry in Rails console,
131
+ pretty colors.
132
+
133
+
134
+ [pry]: http://pry.github.com
135
+ [awesome_print]: https://github.com/michaeldv/awesome_print
136
+ [pry-doc]: https://github.com/pry/pry-doc
137
+ [pry-git]: https://github.com/pry/pry-git
138
+ [pry-nav]: https://github.com/nixme/pry-nav
139
+ [pry-remote]: https://github.com/Mon-Ouie/pry-remote
140
+ [coolline]: https://github.com/Mon-Ouie/coolline
141
+ [pry-coolline]: https://github.com/pry/pry-coolline
142
+ [coderay]: https://github.com/rubychan/coderay
143
+ [hirb]: https://github.com/cldwalker/hirb
144
+ [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer
145
+ [pry-debugger]: https://github.com/nixme/pry-debugger
146
+ [pry-rails]: https://github.com/rweng/pry-rails
147
+ [pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,18 @@
1
+ ## Getting Involved
2
+
3
+ New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
4
+
5
+ ### Coding
6
+
7
+ * Pick a task:
8
+ * Offer feedback on open [pull requests](https://github.com/plribeiro3000/spirit_hands/pulls).
9
+ * Review open [issues](https://github.com/plribeiro3000/spirit_hands/issues) for things to help on.
10
+ * [Create an issue](https://github.com/plribeiro3000/spirit_hands/issues/new) to start a discussion on additions or features.
11
+ * Fork the project, add your changes and tests to cover them in a topic branch.
12
+ * Commit your changes and rebase against `plribeiro3000/spirit_hands` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/plribeiro3000/spirit_hands/compare/)
14
+
15
+ ### Non-Coding
16
+
17
+ * Offer feedback on open [issues](https://github.com/plribeiro3000/spirit_hands/issues).
18
+ * Organize or volunteer at events.
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1,10 @@
1
+ # Original Author
2
+ * Gopal Patel <nixme@stillhope.com>
3
+
4
+ # Contributors
5
+ * Andrew Volozhanin <linuxheadrus@gmail.com>
6
+ * Casey Lang <hello@casey-lang.com>
7
+ * Fernando Paredes <nano@fdp.io>
8
+ * Micah Gates <github@mgates.com>
9
+ * Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
10
+ * Barry Allard <barry.allard@gmail.com>
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 [**Contributors**](Contributors)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ [Contributors]: https://raw.githubusercontent.com/steakknife/spirit_hands/master/CONTRIBUTORS.md
data/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # Spirit Fingers
2
+
3
+ This repo is an improved fork with real configuration syntax, with updates and bug fixes based on [`jazz_hands`](https://github.com/nixme/jazz_hands).
4
+
5
+ Spending hours in the rails console? Spruce it up and show off those
6
+ hard-working hands!
7
+
8
+ **spirit_hands** is an opinionated set of console-related gems and a bit of glue:
9
+
10
+ * [**Pry**][pry] for a powerful shell alternative to IRB.
11
+ * [**Awesome Print**][awesome_print] for stylish pretty print.
12
+ * [**Hirb**][hirb] for tabular collection output.
13
+ * [**Hirb Unicode**][hirb-unicode-steakknife] for aligned Unicode output1.
14
+ * [**Pry Rails**][pry-rails] for additional commands (`show-routes`,
15
+ `show-models`, `show-middleware`) in the Rails console.
16
+ * [**Pry Doc**][pry-doc] to browse Ruby source, including C, directly from the
17
+ console.
18
+ * [**Pry Git**][pry-git] to teach the console about git. Diffs, blames, and
19
+ commits on methods and classes, not just files.
20
+ * [**Pry Remote**][pry-remote] to connect remotely to a Pry console.
21
+ * [**Pry Coolline**][pry-coolline] for syntax highlighting as you type.
22
+
23
+
24
+ ## Usage
25
+
26
+ ### Rails or Ruby Project Integration
27
+
28
+ Ruby 2.0.0+, Rails 3 or 4 or Ruby project, add this to your project Gemfile:
29
+
30
+ ```ruby
31
+ group :development, :test do
32
+ gem 'spirit_hands'
33
+ end
34
+ ```
35
+
36
+ ### Global usage
37
+ `[sudo] gem install spirit_hands`
38
+
39
+ That's it. Run `rails console` as usual.
40
+
41
+ Ruby compiled against a proper readline library, ideally GNU readline, is
42
+ recommended. Alternatively, [`gem install rb-readline`][rb-readline] for an
43
+ acceptible backup. Using ruby compiled against a `libedit` wrapper (primarily OS
44
+ X) will work but is not recommended.
45
+
46
+
47
+ ## Options
48
+
49
+ Change the following options by creating a .pryrc in your Rails or Ruby project
50
+
51
+ ### Example `.pryrc`
52
+
53
+ ```ruby
54
+ if defined?(SpiritHands)
55
+ SpiritHands.colored_prompt = false
56
+ SpiritHands.hirb = false
57
+ end
58
+ ```
59
+
60
+ ### `awesome_print`
61
+
62
+ [**AwesomePrint**][awesome_print] is enabled by default.
63
+ `SpiritHands.awesome_print = false` to disable.
64
+
65
+ ### `color`
66
+
67
+ An alias for getting and setting `Pry.color`
68
+
69
+ ### `colored_prompt`
70
+
71
+ Color the console prompt? Defaults to `true` when the current ruby is compiled
72
+ against GNU readline or `rb-readline`, which don't have issues counting
73
+ characters in colored prompts. `false` for libedit.
74
+
75
+ **Note:** `Pry.color = false` trumps this setting and disables all console coloring.
76
+
77
+ ### `hirb`
78
+ [**Hirb**][hirb] is **enabled** by default.
79
+ `SpiritHands.hirb = false` to disable.
80
+
81
+ ### `hirb_unicode`
82
+ [**Hirb-unicode**][hirb-unicode] is enabled by default when hirb is enabled.
83
+ `SpiritHands.hirb_unicode = false` to disable.
84
+ No effect when hirb is disabled.
85
+
86
+
87
+ ### `prompt`
88
+
89
+ #### Pseudo-XML-like Syntax as follows
90
+
91
+ ```
92
+ current command number <cmd/>
93
+ app name <app/>
94
+
95
+ literal less-than < \< ( "\\<" in Ruby strings )
96
+ bold <bold>....<bold>
97
+
98
+ Foreground color:
99
+
100
+ black <black>...</black>
101
+ and red green yellow blue magenta cyan white
102
+
103
+ Background color:
104
+
105
+ bgblack bgred bggreen bgyellow bgblue bgmagenta bgcyan bgwhite
106
+
107
+ Even the frightening blink tag, where available <blink>...</blink>
108
+
109
+ More at: SpiritHands::Prompt::Render::MATCHED_TAG_CODES.keys
110
+
111
+ ```
112
+
113
+ ### `prompt_separator`
114
+
115
+ Separator string between the application name and line input. Defaults to `»`
116
+ for GNU readline or libedit. Defaults to `>` for `rb-readline` which fails on
117
+ mixed encodings.
118
+
119
+
120
+ [pry]: http://pry.github.com
121
+ [awesome_print]: https://github.com/michaeldv/awesome_print
122
+ [hirb]: https://github.com/cldwalker/hirb
123
+ [hirb-unicode-steakknife]: https://github.com/steakknife/hirb-unicode
124
+ [pry-rails]: https://github.com/rweng/pry-rails
125
+ [pry-doc]: https://github.com/pry/pry-doc
126
+ [pry-git]: https://github.com/pry/pry-git
127
+ [pry-remote]: https://github.com/Mon-Ouie/pry-remote
128
+ [pry-coolline]: https://github.com/pry/pry-coolline
129
+ [coderay]: https://github.com/rubychan/coderay
130
+ [rb-readline]: https://github.com/luislavena/rb-readline
131
+ [pullrequests]: https://github.com/steakknife/spirit_hands/pulls
132
+ [issues]: https://github.com/steakknife/spirit_hands/issues
133
+ [changelog]: https://github.com/steakknife/spirit_hands/blob/master/CHANGELOG.md
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,32 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ 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
31
+ t/HWh1yhriCUe/y8+De8M87btOs=
32
+ -----END CERTIFICATE-----
@@ -0,0 +1,38 @@
1
+ # Adds Hirb.enabled?
2
+ require 'hirb'
3
+ require 'pry'
4
+
5
+ module Hirb
6
+ class << self
7
+ @enabled = false
8
+ def enabled?
9
+ !!@enabled
10
+ end
11
+
12
+ protected
13
+
14
+ def set_enabled
15
+ @enabled = true
16
+ end
17
+
18
+ def set_disabled
19
+ @enabled = false
20
+ end
21
+ end
22
+ end
23
+
24
+ class << Hirb::View
25
+ alias_method :enable_output_method_existing, :enable_output_method
26
+ alias_method :disable_output_method_existing, :disable_output_method
27
+
28
+ def enable_output_method
29
+ @output_method = true
30
+ ::Hirb.send :set_enabled
31
+ enable_output_method_existing
32
+ end
33
+
34
+ def disable_output_method
35
+ ::Hirb.send :set_disabled
36
+ disable_output_method_existing
37
+ end
38
+ end
@@ -0,0 +1,144 @@
1
+ # Fixes pager_command
2
+ require 'hirb'
3
+ require 'shellwords'
4
+
5
+ module Hirb
6
+ # This class provides class methods for paging and an object which can conditionally page given a terminal size that is exceeded.
7
+ class Pager
8
+ class << self
9
+ # Pages using a configured or detected shell command.
10
+ def command_pager(output, options={})
11
+ if valid_pager_command?(pc = options[:pager_command])
12
+ basic_pager(output, pc)
13
+ end
14
+ end
15
+
16
+ # Exposed to allow user-custom, external-driven formatting
17
+ def basic_pager(output, override_pager_command=nil)
18
+ pc = basic_pager_command(override_pager_command)
19
+ pager = IO.popen(pc, "w")
20
+ begin
21
+ save_stdout = STDOUT.clone
22
+ STDOUT.reopen(pager)
23
+ STDOUT.puts output
24
+ rescue Errno::EPIPE
25
+ ensure
26
+ STDOUT.reopen(save_stdout)
27
+ save_stdout.close
28
+ pager.close
29
+ end
30
+ end
31
+
32
+ def pager_command=(*commands) #:nodoc:
33
+ @pager_command = pager_command_select(*commands)
34
+ end
35
+
36
+ def pager_command #:nodoc:
37
+ @pager_command || pager_command_select
38
+ end
39
+
40
+ # Pages with a ruby-only pager which either pages or quits.
41
+ def default_pager(output, options={})
42
+ pager = new(options[:width], options[:height])
43
+ while pager.activated_by?(output, options[:inspect])
44
+ puts pager.slice!(output, options[:inspect])
45
+ return unless continue_paging?
46
+ end
47
+ puts output
48
+ puts "=== Pager finished. ==="
49
+ end
50
+
51
+ def page(string, inspect_mode, pgr_cmd, width, height)
52
+ if valid_pager_command?(pgr_cmd)
53
+ command_pager(string, :pager_command=>pgr_cmd)
54
+ else
55
+ default_pager(string, :width=>width, :height=>height, :inspect=>inspect_mode)
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ #:stopdoc:
62
+ def valid_pager_command?(cmd)
63
+ cmd && Util.command_exists?(cmd.shellsplit[0])
64
+ end
65
+
66
+ # Default pager commands to try
67
+ def pager_command_fallbacks #:nodoc:
68
+ candidates = %w[less more pager cat]
69
+ candidates.unshift ENV['PAGER'] if ENV['PAGER']
70
+ candidates
71
+ end
72
+
73
+ # Pick the first valid command from commands
74
+ def pager_command_select(*commands)
75
+ commands += pager_command_fallbacks
76
+ commands.flatten.compact.uniq.find { |c| valid_pager_command? c }
77
+ end
78
+
79
+ # Actual command basic_pager needs to perform
80
+ def basic_pager_command(override_pager_command)
81
+ if valid_pager_command?(override_pager_command)
82
+ override_pager_command
83
+ else
84
+ pager_command
85
+ end
86
+ end
87
+
88
+ def continue_paging?
89
+ puts "=== Press enter/return to continue or q to quit: ==="
90
+ !$stdin.gets.chomp[/q/i]
91
+ end
92
+ #:startdoc:
93
+ end # class methods
94
+
95
+ attr_reader :width, :height, :options
96
+
97
+ def initialize(width, height, options={})
98
+ resize(width, height)
99
+ @options = options
100
+ end
101
+
102
+ def pager_command
103
+ options[:pager_command] || self.class.pager_command
104
+ end
105
+
106
+ # Pages given string using configured pager.
107
+ def page(string, inspect_mode)
108
+ self.class.page(string, inspect_mode, pager_command, @width, @height)
109
+ end
110
+
111
+ def slice!(output, inspect_mode=false) #:nodoc:
112
+ effective_height = @height - 2 # takes into account pager prompt
113
+ if inspect_mode
114
+ sliced_output = String.slice(output, 0, @width * effective_height)
115
+ output.replace String.slice(output, char_count(sliced_output), String.size(output))
116
+ sliced_output
117
+ else
118
+ # could use output.scan(/[^\n]*\n?/) instead of split
119
+ sliced_output = output.split("\n").slice(0, effective_height).join("\n")
120
+ output.replace output.split("\n").slice(effective_height..-1).join("\n")
121
+ sliced_output
122
+ end
123
+ end
124
+
125
+ # Determines if string should be paged based on configured width and height.
126
+ def activated_by?(string_to_page, inspect_mode=false)
127
+ inspect_mode ? (String.size(string_to_page) > @height * @width) : (string_to_page.count("\n") > @height)
128
+ end
129
+
130
+ if String.method_defined? :chars
131
+ def char_count(string) #:nodoc:
132
+ string.chars.count
133
+ end
134
+ else
135
+ def char_count(string) #:nodoc:
136
+ String.size(string)
137
+ end
138
+ end
139
+
140
+ def resize(width, height) #:nodoc:
141
+ @width, @height = View.determine_terminal_size(width, height)
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,23 @@
1
+ require 'hirb'
2
+ require 'pathname'
3
+
4
+ module Hirb
5
+ module Util
6
+ class << self
7
+ # Determines if a shell command exists by searching for it in ENV['PATH'].
8
+ # (Fixed version)
9
+ def command_exists?(command)
10
+ if c = Pathname.new(command)
11
+ return true if c.absolute? && c.exist?
12
+ end
13
+ executable_file_exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
14
+ ENV['PATH'].split(File::PATH_SEPARATOR).any? do |d|
15
+ executable_file_exts.any? do |ext|
16
+ f = File.expand_path(command + ext, d)
17
+ File.executable?(f) && !File.directory?(f)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ # Integrate Hirb + SpiritHands print output (AwesomePrint / inspect)
2
+ require 'hirb'
3
+ require 'spirit_hands'
4
+
5
+ class << Hirb::View
6
+ def view_or_page_output(str)
7
+ view_output(str) ||
8
+ page_output(::SpiritHands::Print.pretty(str), true)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ require 'hirb'
2
+ require 'spirit_hands/hirb/fixes/pager'
3
+ require 'spirit_hands/hirb/fixes/util'
4
+ require 'spirit_hands/hirb/fixes/view'
5
+ require 'spirit_hands/hirb/fixes/enabled'
@@ -0,0 +1,2 @@
1
+ require 'hirb'
2
+ require 'spirit_hands/hirb/fixes'