spirit_hands 2.1.10-universal-java-12
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 +7 -0
- data/.gitignore +17 -0
- data/.pryrc +1 -0
- data/.ruby-gemset +1 -0
- data/CHANGELOG.md +150 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +12 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +153 -0
- data/Rakefile +128 -0
- data/gem-public_cert.pem +31 -0
- data/lib/spirit_hands.rb +20 -0
- data/lib/spirit_hands/hirb.rb +2 -0
- data/lib/spirit_hands/hirb/fixes.rb +5 -0
- data/lib/spirit_hands/hirb/fixes/enabled.rb +36 -0
- data/lib/spirit_hands/hirb/fixes/pager.rb +157 -0
- data/lib/spirit_hands/hirb/fixes/util.rb +19 -0
- data/lib/spirit_hands/hirb/fixes/view.rb +11 -0
- data/lib/spirit_hands/mattr_accessor_with_default.rb +44 -0
- data/lib/spirit_hands/melody.rb +68 -0
- data/lib/spirit_hands/options.rb +99 -0
- data/lib/spirit_hands/options/color.rb +10 -0
- data/lib/spirit_hands/options/coolline.rb +60 -0
- data/lib/spirit_hands/options/hirb.rb +34 -0
- data/lib/spirit_hands/options/less.rb +2 -0
- data/lib/spirit_hands/options/less/colorize.rb +41 -0
- data/lib/spirit_hands/options/less/show_raw_unicode.rb +36 -0
- data/lib/spirit_hands/print.rb +76 -0
- data/lib/spirit_hands/prompt.rb +12 -0
- data/lib/spirit_hands/prompt/base.rb +25 -0
- data/lib/spirit_hands/prompt/base/render.rb +239 -0
- data/lib/spirit_hands/prompt/main.rb +18 -0
- data/lib/spirit_hands/prompt/multiline.rb +17 -0
- data/lib/spirit_hands/railtie.rb +11 -0
- data/lib/spirit_hands/terminal.rb +16 -0
- data/lib/spirit_hands/version.rb +3 -0
- data/note.txt +2 -0
- data/spirit_hands.gemspec +39 -0
- metadata +202 -0
data/gem-public_cert.pem
ADDED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-----
|
data/lib/spirit_hands.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Do this to use SpiritHands outside Rails
|
2
|
+
#
|
3
|
+
# # .pryrc
|
4
|
+
# require 'spirit_hands'
|
5
|
+
# # ...
|
6
|
+
#
|
7
|
+
#
|
8
|
+
require 'spirit_hands/options'
|
9
|
+
require 'spirit_hands/print'
|
10
|
+
require 'spirit_hands/prompt'
|
11
|
+
require 'spirit_hands/terminal'
|
12
|
+
require 'spirit_hands/version'
|
13
|
+
require 'spirit_hands/melody'
|
14
|
+
if defined? ::Rails
|
15
|
+
require 'pry-rails'
|
16
|
+
require 'spirit_hands/railtie'
|
17
|
+
Pry.plugins['rails'].activate!
|
18
|
+
else
|
19
|
+
SpiritHands.melody!
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Adds Hirb.enabled?
|
2
|
+
require 'hirb'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class << Hirb
|
6
|
+
@enabled = false
|
7
|
+
def enabled?
|
8
|
+
!!@enabled
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def set_enabled
|
14
|
+
@enabled = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_disabled
|
18
|
+
@enabled = false
|
19
|
+
end
|
20
|
+
end # Hirb.self
|
21
|
+
|
22
|
+
class << Hirb::View
|
23
|
+
alias_method :enable_output_method_existing, :enable_output_method
|
24
|
+
alias_method :disable_output_method_existing, :disable_output_method
|
25
|
+
|
26
|
+
def enable_output_method
|
27
|
+
@output_method = true
|
28
|
+
::Hirb.send :set_enabled
|
29
|
+
enable_output_method_existing
|
30
|
+
end
|
31
|
+
|
32
|
+
def disable_output_method
|
33
|
+
::Hirb.send :set_disabled
|
34
|
+
disable_output_method_existing
|
35
|
+
end
|
36
|
+
end # Hirb::View.self
|
@@ -0,0 +1,157 @@
|
|
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
|
+
remove_method :command_pager
|
11
|
+
def command_pager(output, options={})
|
12
|
+
if valid_pager_command?(pc = options[:pager_command])
|
13
|
+
basic_pager(output, pc)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Exposed to allow user-custom, external-driven formatting
|
18
|
+
remove_method :basic_pager
|
19
|
+
def basic_pager(output, override_pager_command=nil)
|
20
|
+
pc = basic_pager_command(override_pager_command)
|
21
|
+
pager = IO.popen(pc, "w")
|
22
|
+
begin
|
23
|
+
save_stdout = STDOUT.clone
|
24
|
+
STDOUT.reopen(pager)
|
25
|
+
STDOUT.puts output
|
26
|
+
rescue Errno::EPIPE
|
27
|
+
ensure
|
28
|
+
STDOUT.reopen(save_stdout)
|
29
|
+
save_stdout.close
|
30
|
+
pager.close
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def pager_command=(*commands) #:nodoc:
|
35
|
+
@pager_command = pager_command_select(*commands)
|
36
|
+
end
|
37
|
+
|
38
|
+
remove_method :pager_command
|
39
|
+
def pager_command #:nodoc:
|
40
|
+
@pager_command || pager_command_select
|
41
|
+
end
|
42
|
+
|
43
|
+
# Pages with a ruby-only pager which either pages or quits.
|
44
|
+
remove_method :default_pager
|
45
|
+
def default_pager(output, options={})
|
46
|
+
pager = new(options[:width], options[:height])
|
47
|
+
while pager.activated_by?(output, options[:inspect])
|
48
|
+
puts pager.slice!(output, options[:inspect])
|
49
|
+
return unless continue_paging?
|
50
|
+
end
|
51
|
+
puts output
|
52
|
+
puts "=== Pager finished. ==="
|
53
|
+
end
|
54
|
+
|
55
|
+
def page(string, inspect_mode, pgr_cmd, width, height)
|
56
|
+
if valid_pager_command?(pgr_cmd)
|
57
|
+
command_pager(string, :pager_command=>pgr_cmd)
|
58
|
+
else
|
59
|
+
default_pager(string, :width=>width, :height=>height, :inspect=>inspect_mode)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
#:stopdoc:
|
66
|
+
remove_method :valid_pager_command?
|
67
|
+
def valid_pager_command?(cmd)
|
68
|
+
cmd && Util.command_exists?(cmd.shellsplit[0])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Default pager commands to try
|
72
|
+
def pager_command_fallbacks #:nodoc:
|
73
|
+
candidates = %w[less more pager cat]
|
74
|
+
candidates.unshift ENV['PAGER'] if ENV['PAGER']
|
75
|
+
candidates
|
76
|
+
end
|
77
|
+
|
78
|
+
# Pick the first valid command from commands
|
79
|
+
def pager_command_select(*commands)
|
80
|
+
commands += pager_command_fallbacks
|
81
|
+
commands.flatten.compact.uniq.find { |c| valid_pager_command? c }
|
82
|
+
end
|
83
|
+
|
84
|
+
# Actual command basic_pager needs to perform
|
85
|
+
def basic_pager_command(override_pager_command)
|
86
|
+
if valid_pager_command?(override_pager_command)
|
87
|
+
override_pager_command
|
88
|
+
else
|
89
|
+
pager_command
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
remove_method :continue_paging?
|
94
|
+
def continue_paging?
|
95
|
+
puts "=== Press enter/return to continue or q to quit: ==="
|
96
|
+
!$stdin.gets.chomp[/q/i]
|
97
|
+
end
|
98
|
+
#:startdoc:
|
99
|
+
end # class methods
|
100
|
+
|
101
|
+
remove_method :width
|
102
|
+
remove_method :height
|
103
|
+
attr_reader :width, :height, :options
|
104
|
+
|
105
|
+
def initialize(width, height, options={})
|
106
|
+
resize(width, height)
|
107
|
+
@options = options
|
108
|
+
end
|
109
|
+
|
110
|
+
def pager_command
|
111
|
+
options[:pager_command] || self.class.pager_command
|
112
|
+
end
|
113
|
+
|
114
|
+
# Pages given string using configured pager.
|
115
|
+
remove_method :page
|
116
|
+
def page(string, inspect_mode)
|
117
|
+
self.class.page(string, inspect_mode, pager_command, @width, @height)
|
118
|
+
end
|
119
|
+
|
120
|
+
remove_method :slice!
|
121
|
+
def slice!(output, inspect_mode=false) #:nodoc:
|
122
|
+
effective_height = @height - 2 # takes into account pager prompt
|
123
|
+
if inspect_mode
|
124
|
+
sliced_output = String.slice(output, 0, @width * effective_height)
|
125
|
+
output.replace String.slice(output, char_count(sliced_output), String.size(output))
|
126
|
+
sliced_output
|
127
|
+
else
|
128
|
+
# could use output.scan(/[^\n]*\n?/) instead of split
|
129
|
+
sliced_output = output.split("\n").slice(0, effective_height).join("\n")
|
130
|
+
output.replace output.split("\n").slice(effective_height..-1).join("\n")
|
131
|
+
sliced_output
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Determines if string should be paged based on configured width and height.
|
136
|
+
remove_method :activated_by?
|
137
|
+
def activated_by?(string_to_page, inspect_mode=false)
|
138
|
+
inspect_mode ? (String.size(string_to_page) > @height * @width) : (string_to_page.count("\n") > @height)
|
139
|
+
end
|
140
|
+
|
141
|
+
remove_method :char_count
|
142
|
+
if String.method_defined? :chars
|
143
|
+
def char_count(string) #:nodoc:
|
144
|
+
string.chars.count
|
145
|
+
end
|
146
|
+
else
|
147
|
+
def char_count(string) #:nodoc:
|
148
|
+
String.size(string)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
remove_method :resize
|
153
|
+
def resize(width, height) #:nodoc:
|
154
|
+
@width, @height = View.determine_terminal_size(width, height)
|
155
|
+
end
|
156
|
+
end # Pager
|
157
|
+
end # Hirb
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'hirb'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
class << Hirb::Util
|
5
|
+
# Determines if a shell command exists by searching for it in ENV['PATH'].
|
6
|
+
# (Fixed version)
|
7
|
+
def command_exists?(command)
|
8
|
+
if c = Pathname.new(command)
|
9
|
+
return true if c.absolute? && c.exist?
|
10
|
+
end
|
11
|
+
executable_file_exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
12
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |d|
|
13
|
+
executable_file_exts.any? do |ext|
|
14
|
+
f = File.expand_path(command + ext, d)
|
15
|
+
File.executable?(f) && !File.directory?(f)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end # Hirb::Util.self
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Integrate Hirb + SpiritHands print output (AwesomePrint / inspect)
|
2
|
+
require 'hirb'
|
3
|
+
#require 'spirit_hands'
|
4
|
+
|
5
|
+
class << Hirb::View
|
6
|
+
remove_method :view_or_page_output
|
7
|
+
def view_or_page_output(str)
|
8
|
+
view_output(str) ||
|
9
|
+
page_output(::SpiritHands::Print.pretty(str), true)
|
10
|
+
end
|
11
|
+
end # Hirb::View.self
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Module
|
2
|
+
def mattr_accessor_with_default(property, default = nil, &block)
|
3
|
+
if block_given?
|
4
|
+
if default
|
5
|
+
raise ArgumentError, 'Must specify only one of +default+ or &block'
|
6
|
+
end
|
7
|
+
default = block
|
8
|
+
end
|
9
|
+
|
10
|
+
getter = property.to_sym
|
11
|
+
setter = "#{property}=".to_sym
|
12
|
+
class_var = "@@#{property}".to_sym
|
13
|
+
|
14
|
+
# self.property=
|
15
|
+
define_singleton_method(setter) do |value|
|
16
|
+
if value.nil?
|
17
|
+
remove_class_variable(class_var)
|
18
|
+
else
|
19
|
+
class_variable_set(class_var, value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# self.property
|
24
|
+
if default.respond_to?(:call) # default is callable
|
25
|
+
define_singleton_method(getter) do
|
26
|
+
if class_variable_defined?(class_var)
|
27
|
+
class_variable_get(class_var)
|
28
|
+
else
|
29
|
+
default.()
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else # default is literal object
|
33
|
+
default_value_name = "DEFAULT_#{property}".upcase.to_sym
|
34
|
+
const_set(default_value_name, default)
|
35
|
+
define_singleton_method(getter) do
|
36
|
+
if class_variable_defined?(class_var)
|
37
|
+
class_variable_get(class_var)
|
38
|
+
else
|
39
|
+
const_get(default_value_name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # Module
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
class << SpiritHands
|
4
|
+
# This modifies pry to play our tune
|
5
|
+
def melody!(app = nil)
|
6
|
+
return false if @installed
|
7
|
+
@installed = true
|
8
|
+
|
9
|
+
Pry.config.should_load_plugins = false
|
10
|
+
SpiritHands.app = app unless app.nil?
|
11
|
+
setup_less_colorize
|
12
|
+
setup_less_show_raw_unicode
|
13
|
+
setup_hirb
|
14
|
+
disable_remote
|
15
|
+
setup_coolline # setup Pry.config.input
|
16
|
+
setup_nav
|
17
|
+
setup_byebug
|
18
|
+
setup_doc
|
19
|
+
|
20
|
+
# Use awesome_print for output, but keep pry's pager. If Hirb is
|
21
|
+
# enabled, try printing with it first.
|
22
|
+
::SpiritHands::Print.install!
|
23
|
+
|
24
|
+
# Friendlier prompt - line number, app name, nesting levels look like
|
25
|
+
# directory paths.
|
26
|
+
#
|
27
|
+
# Configuration (like Pry.color) can be changed later or even during console usage.
|
28
|
+
::SpiritHands::Prompt.install!
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def setup_nav
|
34
|
+
return if Pry.plugins['nav'].is_a? Pry::PluginManager::NoPlugin
|
35
|
+
require 'pry-nav'
|
36
|
+
if jruby?
|
37
|
+
Pry.plugins['nav'].activate!
|
38
|
+
else
|
39
|
+
Pry.plugins['nav'].disable!
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_byebug
|
45
|
+
return if Pry.plugins['byebug'].is_a? Pry::PluginManager::NoPlugin
|
46
|
+
require 'pry-byebug'
|
47
|
+
if jruby?
|
48
|
+
Pry.plugins['byebug'].disable!
|
49
|
+
else
|
50
|
+
Pry.plugins['byebug'].activate!
|
51
|
+
end
|
52
|
+
rescue LoadError
|
53
|
+
end
|
54
|
+
|
55
|
+
def setup_doc
|
56
|
+
require 'pry-doc'
|
57
|
+
Pry.plugins['doc'].activate!
|
58
|
+
end
|
59
|
+
|
60
|
+
def disable_remote
|
61
|
+
return if Pry.plugins['remote'].is_a? Pry::PluginManager::NoPlugin
|
62
|
+
Pry.plugins['remote'].disable!
|
63
|
+
end
|
64
|
+
|
65
|
+
def jruby?
|
66
|
+
RUBY_ENGINE == 'jruby'
|
67
|
+
end
|
68
|
+
end # SpiritHands.self
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'readline'
|
3
|
+
require 'spirit_hands/mattr_accessor_with_default'
|
4
|
+
require 'spirit_hands/options/coolline'
|
5
|
+
require 'spirit_hands/options/color'
|
6
|
+
require 'spirit_hands/options/less'
|
7
|
+
require 'spirit_hands/options/hirb'
|
8
|
+
|
9
|
+
module SpiritHands
|
10
|
+
### Options ###
|
11
|
+
|
12
|
+
# When printing values, start with this (default: '=> ')
|
13
|
+
mattr_accessor_with_default :value_prompt, '=> '
|
14
|
+
|
15
|
+
# Spaces to indent value (default: 2 spaces)
|
16
|
+
mattr_accessor_with_default :value_indent, 2
|
17
|
+
|
18
|
+
# Name of the app, which can be displayed to <app/> tag in prompt
|
19
|
+
mattr_accessor_with_default :app, -> {
|
20
|
+
if defined?(::Rails)
|
21
|
+
::Rails.application
|
22
|
+
else
|
23
|
+
# Trumpet emoji or pry
|
24
|
+
(Terminal.unicode?) ? "\u{1F3BA}" : 'pry'
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
# <color>...</color>
|
29
|
+
# <bold>...</color>
|
30
|
+
# <cmd/> command number
|
31
|
+
# <app/> SpiritHands.app, which can be String or a Rails Applicatino object
|
32
|
+
# <sep/> SpiritHands.prompt_separator
|
33
|
+
#
|
34
|
+
# Use \ to escape literal <, so in a Ruby string constant, "\\<"
|
35
|
+
#
|
36
|
+
mattr_accessor_with_default :prompt,
|
37
|
+
'<b>[<cmd/>]</b> <blue><app/></blue><tgt/> <red><sep/></red> '
|
38
|
+
|
39
|
+
# Color the prompt?
|
40
|
+
#
|
41
|
+
# A different setting than Pry.color since some may like colored output, but a
|
42
|
+
# plain prompt.
|
43
|
+
#
|
44
|
+
# Default: 'true' for GNU readline or rb-readline which correctly count line
|
45
|
+
# widths with color codes when using \001 and \002 hints. 'false' for
|
46
|
+
# libedit-based wrapper (standard on OS X unless ruby is explicitly compiled
|
47
|
+
# otherwise).
|
48
|
+
mattr_accessor_with_default :colored_prompt, -> { ::Readline::VERSION !~ /EditLine/ }
|
49
|
+
|
50
|
+
# Separator between application name and input in the prompt.
|
51
|
+
#
|
52
|
+
# Default: right angle quote (chevron) or >
|
53
|
+
#
|
54
|
+
mattr_accessor_with_default :prompt_separator, -> {
|
55
|
+
(Terminal.unicode?) ? "\u{BB}" : '>'
|
56
|
+
}
|
57
|
+
|
58
|
+
# Enable or disable AwesomePrint (default: true)
|
59
|
+
mattr_accessor_with_default :awesome_print, true
|
60
|
+
|
61
|
+
def self.app_name
|
62
|
+
if app.class.respond_to?(:parent_name) && \
|
63
|
+
app.class.parent_name.respond_to?(:underscore)
|
64
|
+
app.class.parent_name.underscore
|
65
|
+
elsif app
|
66
|
+
app.to_s
|
67
|
+
else
|
68
|
+
::SpiritHands.app
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.config
|
73
|
+
c = CONFIG_KEYS.map do |k|
|
74
|
+
if k == :app
|
75
|
+
[k, app.to_s]
|
76
|
+
else
|
77
|
+
[k, public_send(k)]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
Hash[c]
|
81
|
+
end
|
82
|
+
|
83
|
+
CONFIG_KEYS = [
|
84
|
+
:app,
|
85
|
+
:app_name,
|
86
|
+
:awesome_print,
|
87
|
+
:color,
|
88
|
+
:colored_prompt,
|
89
|
+
:coolline,
|
90
|
+
:hirb,
|
91
|
+
:hirb_unicode,
|
92
|
+
:less_colorize,
|
93
|
+
:less_show_raw_unicode,
|
94
|
+
:prompt,
|
95
|
+
:prompt_separator,
|
96
|
+
:value_indent,
|
97
|
+
:value_prompt,
|
98
|
+
]
|
99
|
+
end
|