fancy_irb 0.8.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG.rdoc → CHANGELOG.md} +27 -10
- data/README.md +55 -0
- data/Rakefile +2 -0
- data/fancy_irb.gemspec +7 -3
- data/lib/fancy_irb/implementation.rb +42 -44
- data/lib/fancy_irb/irb_ext.rb +6 -31
- data/lib/fancy_irb/size_detector.rb +10 -11
- data/lib/fancy_irb/version.rb +1 -1
- data/lib/fancy_irb.rb +0 -22
- data/spec/fixtures.rb +13 -0
- data/spec/size_detector_spec.rb +58 -0
- metadata +42 -6
- data/README.rdoc +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f559efa7e0408fea662a4c4f6c830ee55a37384a
|
4
|
+
data.tar.gz: 694324fa73a9f55ca3a3ab5ef81e50c4332dbfa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3450bb467f66b2fd872448fad46e3245a24865fb0d8e127bc83d9a50c6061f343e15b71178e8c1099b4a01dd458d2fd19abd1d61a621b3c9a8c67da54a1b7367
|
7
|
+
data.tar.gz: a8b9a0e89cb41c7326b25970b8074b96336c1dbe5d8d8b37c99bfc23a065d63ca1893294e3f88c815bdf1b1db0d945c31a5401add0aaac3b028fd3fc4d094fad
|
@@ -1,36 +1,53 @@
|
|
1
|
-
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 1.0.0
|
4
|
+
* More tidying behind the scenes
|
5
|
+
* Remove :result_proc and :output_procs options. Please use `IRB::Inspector.def_inspector` if you need this feature
|
6
|
+
* Recognize multi-line regexes
|
7
|
+
* Improve size detector (-> less wrongly placed rockets)
|
8
|
+
|
9
|
+
|
10
|
+
## 0.8.2
|
2
11
|
* Support objects that don't support #inspect
|
3
12
|
|
4
|
-
|
13
|
+
|
14
|
+
## 0.8.1
|
5
15
|
* Use io/console correctly, fixes bug on mingw
|
6
16
|
|
7
|
-
|
17
|
+
|
18
|
+
## 0.8.0
|
8
19
|
* Internals partly refactored
|
9
20
|
* Bump paint and unicode-display_width dependencies
|
10
21
|
* Drop official support for Ruby 1
|
11
22
|
* Don't depend on ansicon specifics for windows (use io/console)
|
12
23
|
* Also patch input methods for ARGF
|
13
24
|
* Don't try to catch exception when printing to stderr
|
14
|
-
* Remove [:colorizer]
|
25
|
+
* Remove [:[colorizer]](:output) option
|
15
26
|
* Not patching Kernel anymore
|
16
27
|
* Only path String if east_asian_width option is used
|
17
28
|
|
18
|
-
|
29
|
+
|
30
|
+
## 0.7.3
|
19
31
|
* Don't colorize stdout by default
|
20
32
|
* Deactivate rocket for common system commands
|
21
33
|
|
22
|
-
|
34
|
+
|
35
|
+
## 0.7.2
|
23
36
|
* Fix a small bug that happens if there was no last line
|
24
37
|
|
25
|
-
|
38
|
+
|
39
|
+
## 0.7.1
|
26
40
|
* Deactivate buggy input coloring :/
|
27
41
|
|
28
|
-
|
42
|
+
|
43
|
+
## 0.7.0
|
29
44
|
* Use paint gem for terminal colors
|
30
45
|
* Fix some rocket issues (when using with colored content)
|
31
46
|
|
32
|
-
|
47
|
+
|
48
|
+
## 0.6.5
|
33
49
|
* Windows support
|
34
50
|
|
35
|
-
|
51
|
+
|
52
|
+
## < 0.6.5
|
36
53
|
See https://github.com/janlelis/fancy_irb/commits/0.6.4
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# FancyIrb [![version](https://badge.fury.io/rb/fancy_irb.svg)](http://badge.fury.io/rb/fancy_irb)
|
2
|
+
|
3
|
+
* Colorizes IRB prompts, errors, `$stderr` and `$stdout`
|
4
|
+
* Uses "Hash Rockets" (# =>) to display IRB results
|
5
|
+
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
require 'fancy_irb'
|
10
|
+
FancyIrb.start
|
11
|
+
|
12
|
+
You can pass an options hash. These are the default values:
|
13
|
+
|
14
|
+
DEFAULT_OPTIONS = {
|
15
|
+
:rocket_mode => true, # activate or deactivate #=> rocket
|
16
|
+
:rocket_prompt => '#=> ', # prompt to use for the rocket
|
17
|
+
:result_prompt => '=> ', # prompt to use for normal output
|
18
|
+
:east_asian_width => false, # set to true if you have double-width characters (slower)
|
19
|
+
:colorize => { # colors hash. Set to nil to deactivate colors
|
20
|
+
:rocket_prompt => [:blue],
|
21
|
+
:result_prompt => [:blue],
|
22
|
+
:input_prompt => nil,
|
23
|
+
:irb_errors => [:red, :clean],
|
24
|
+
:stderr => [:red, :bright],
|
25
|
+
:stdout => nil,
|
26
|
+
:input => nil,
|
27
|
+
},
|
28
|
+
}
|
29
|
+
|
30
|
+
Rocket mode means: Output result as comment if there is enough space left on
|
31
|
+
the terminal line and `stdout` does not output more than the current terminal
|
32
|
+
height.
|
33
|
+
|
34
|
+
For more information on which colors can be used, see the [paint
|
35
|
+
documentation](https://github.com/janlelis/paint).
|
36
|
+
|
37
|
+
|
38
|
+
## Troubleshooting
|
39
|
+
### Windows Support
|
40
|
+
You will need [ansicon](https://github.com/adoxa/ansicon) or [ConEmu](https://code.google.com/p/conemu-maximus5/).
|
41
|
+
|
42
|
+
### Wrong display widths?
|
43
|
+
When using double-width unicode chars, you should set `:east_asian_width` to
|
44
|
+
`true`. It is not activated by default, because of its performance impact.
|
45
|
+
|
46
|
+
### Known bugs
|
47
|
+
Not all stdin methods are patched properly to work with the rocket: The gems
|
48
|
+
focuses on the often used ones
|
49
|
+
|
50
|
+
|
51
|
+
## J-_-L
|
52
|
+
Inspired by the irb_rocket gem by genki.
|
53
|
+
|
54
|
+
Copyright (c) 2010-2012, 2015 Jan Lelis <http://janlelis.com> released under
|
55
|
+
the MIT license.
|
data/Rakefile
CHANGED
data/fancy_irb.gemspec
CHANGED
@@ -13,13 +13,15 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.required_ruby_version = '>= 1.9.3'
|
14
14
|
s.license = 'MIT'
|
15
15
|
s.requirements = ['Windows: ansicon <https://github.com/adoxa/ansicon>']
|
16
|
-
s.add_dependency 'paint', '>= 0.9.0'
|
16
|
+
s.add_dependency 'paint', '>= 0.9', '< 2.0'
|
17
17
|
s.add_dependency 'unicode-display_width', ">= 0.2.0"
|
18
|
+
s.add_development_dependency 'rspec', "~> 3.2"
|
19
|
+
s.add_development_dependency 'rake', "~> 10.4"
|
18
20
|
s.files = [
|
19
21
|
"MIT-LICENSE.txt",
|
20
|
-
"README.
|
22
|
+
"README.md",
|
21
23
|
"Rakefile",
|
22
|
-
"CHANGELOG.
|
24
|
+
"CHANGELOG.md",
|
23
25
|
"fancy_irb.gemspec",
|
24
26
|
"lib/fancy_irb.rb",
|
25
27
|
"lib/fancy_irb/irb_ext.rb",
|
@@ -30,6 +32,8 @@ Gem::Specification.new do |s|
|
|
30
32
|
"lib/fancy_irb/core_ext.rb",
|
31
33
|
"lib/fancy_irb/clean_up.rb",
|
32
34
|
"lib/fancy_irb/version.rb",
|
35
|
+
"spec/size_detector_spec.rb",
|
36
|
+
"spec/fixtures.rb",
|
33
37
|
]
|
34
38
|
end
|
35
39
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module FancyIrb
|
2
|
+
extend SizeDetector
|
3
|
+
|
4
|
+
@error_capturer = nil
|
5
|
+
|
2
6
|
class << self
|
3
|
-
attr_reader :options
|
4
7
|
attr_reader :error_capturer
|
5
8
|
attr_accessor :skip_next_rocket
|
6
9
|
|
@@ -9,7 +12,6 @@ module FancyIrb
|
|
9
12
|
apply_user_options(user_options)
|
10
13
|
reset_line!
|
11
14
|
extend!
|
12
|
-
|
13
15
|
true
|
14
16
|
end
|
15
17
|
|
@@ -23,7 +25,7 @@ module FancyIrb
|
|
23
25
|
|
24
26
|
def set_defaults
|
25
27
|
@skip_next_rocket = false
|
26
|
-
@
|
28
|
+
@current_indent = Float::INFINITY
|
27
29
|
|
28
30
|
@options = DEFAULT_OPTIONS.dup
|
29
31
|
@options[:colorize] = @options[:colorize].dup if @options[:colorize]
|
@@ -49,43 +51,24 @@ module FancyIrb
|
|
49
51
|
}
|
50
52
|
end
|
51
53
|
|
52
|
-
def
|
53
|
-
|
54
|
-
@options[key][key2]
|
55
|
-
else
|
56
|
-
@options[key]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def add_output_proc(prepend = false, &proc)
|
61
|
-
action = prepend ? :unshift : :push
|
62
|
-
@options[:output_procs].send action, proc
|
63
|
-
end
|
64
|
-
|
65
|
-
def set_result_proc(&proc)
|
66
|
-
@options[:result_proc] = proc
|
54
|
+
def east_asian_width?
|
55
|
+
@options[:east_asian_width]
|
67
56
|
end
|
68
57
|
|
69
58
|
def reset_line!
|
70
|
-
@
|
71
|
-
@
|
59
|
+
@tracked_height = 0
|
60
|
+
@tracked_indent = 0
|
72
61
|
end
|
73
62
|
|
74
|
-
def track_indent
|
75
|
-
@
|
76
|
-
|
63
|
+
def handle_prompt(prompt, scanner_indent, track_indent)
|
64
|
+
@tracked_indent = 2 if track_indent
|
65
|
+
@current_indent = width_of(prompt) + scanner_indent + @tracked_indent
|
77
66
|
|
78
|
-
|
79
|
-
@real_lengths[:input_prompt] =
|
80
|
-
prompt.size + irb_scanner.indent * 2 + ( @indent ? 2 : 0 )
|
67
|
+
append_input_color colorize(prompt, :input_prompt)
|
81
68
|
end
|
82
69
|
|
83
70
|
def track_height(data)
|
84
|
-
@
|
85
|
-
end
|
86
|
-
|
87
|
-
def get_height
|
88
|
-
1 + ( @height_counter == [0] ? 0 : @height_counter.reduce(:+) || 0 )
|
71
|
+
@tracked_height += height_of(data, TerminalInfo.cols)
|
89
72
|
end
|
90
73
|
|
91
74
|
def colorize(string, colorize_key)
|
@@ -101,24 +84,39 @@ module FancyIrb
|
|
101
84
|
end
|
102
85
|
end
|
103
86
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
87
|
+
def output_value(context, scanner)
|
88
|
+
show_output(context.inspect_last_value, scanner)
|
89
|
+
end
|
90
|
+
|
91
|
+
def show_output(output, scanner)
|
92
|
+
if @options[:rocket_mode] && !@skip_next_rocket && !output.include?("\n")
|
93
|
+
offset = get_offset_from_irb_scanner(scanner)
|
94
|
+
cols_to_show = get_cols_to_show_from_output_and_offset(output, offset)
|
95
|
+
lines_to_show = 1 + @tracked_height
|
96
|
+
|
97
|
+
if TerminalInfo.lines > lines_to_show && TerminalInfo.cols > cols_to_show
|
98
|
+
print \
|
99
|
+
Paint::NOTHING +
|
100
|
+
TerminalInfo::TPUT[:sc] + # save current cursor position
|
101
|
+
TerminalInfo::TPUT[:cuu1] * lines_to_show + # move cursor upwards to the original input line
|
102
|
+
TerminalInfo::TPUT[:cuf1] * offset + # move cursor rightwards to the original input offset
|
103
|
+
colorize(@options[:rocket_prompt], :rocket_prompt) + # draw rocket prompt
|
104
|
+
output + # draw output
|
105
|
+
TerminalInfo::TPUT[:rc] # return to normal cursor position
|
106
|
+
return
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@skip_next_rocket = false
|
110
|
+
puts colorize(@options[:result_prompt], :result_prompt) + output
|
113
111
|
end
|
114
112
|
|
115
113
|
def get_offset_from_irb_scanner(irb_scanner)
|
116
114
|
last_line = irb_scanner.instance_variable_get(:@line).split("\n").last
|
117
|
-
1 + @
|
115
|
+
1 + @current_indent + width_of(last_line)
|
118
116
|
end
|
119
117
|
|
120
|
-
def
|
121
|
-
offset + @options[:rocket_prompt]
|
118
|
+
def get_cols_to_show_from_output_and_offset(output, offset)
|
119
|
+
offset + width_of(@options[:rocket_prompt] + output)
|
122
120
|
end
|
123
121
|
|
124
122
|
# TODO testing and improving, e.g. getc does not contain "\n"
|
@@ -151,7 +149,7 @@ module FancyIrb
|
|
151
149
|
end
|
152
150
|
|
153
151
|
def register_error_capturer!
|
154
|
-
@error_capturer =
|
152
|
+
@error_capturer = ErrorCapturer.new
|
155
153
|
end
|
156
154
|
|
157
155
|
def present_and_clear_captured_error!
|
data/lib/fancy_irb/irb_ext.rb
CHANGED
@@ -1,42 +1,18 @@
|
|
1
1
|
module IRB
|
2
2
|
class Irb
|
3
3
|
def output_value
|
4
|
-
|
5
|
-
|
6
|
-
if FancyIrb[:rocket_mode] && !FancyIrb.skip_next_rocket
|
7
|
-
offset = FancyIrb.get_offset_from_irb_scanner(@scanner)
|
8
|
-
cols_to_show = FancyIrb.get_cols_to_show_from_offset(offset)
|
9
|
-
lines_to_show = FancyIrb.get_height
|
10
|
-
|
11
|
-
if FancyIrb::TerminalInfo.lines > lines_to_show &&
|
12
|
-
FancyIrb::TerminalInfo.cols > cols_to_show
|
13
|
-
print \
|
14
|
-
Paint::NOTHING +
|
15
|
-
FancyIrb::TerminalInfo::TPUT[:sc] + # save current cursor position
|
16
|
-
FancyIrb::TerminalInfo::TPUT[:cuu1] * lines_to_show + # move cursor upwards to the original input line
|
17
|
-
FancyIrb::TerminalInfo::TPUT[:cuf1] * offset + # move cursor rightwards to the original input offset
|
18
|
-
FancyIrb.colorize(FancyIrb[:rocket_prompt], :rocket_prompt) + # draw rocket prompt
|
19
|
-
output + # draw output
|
20
|
-
FancyIrb::TerminalInfo::TPUT[:rc] # return to normal cursor position
|
21
|
-
return
|
22
|
-
end
|
23
|
-
end
|
24
|
-
FancyIrb.skip_next_rocket = false
|
25
|
-
puts FancyIrb.colorize(FancyIrb[:result_prompt], :result_prompt) + output
|
4
|
+
FancyIrb.output_value(@context, @scanner)
|
26
5
|
end
|
27
6
|
|
28
|
-
# colorize prompt & input
|
29
7
|
alias prompt_non_fancy prompt
|
30
8
|
def prompt(*args, &block)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
FancyIrb.append_input_color(FancyIrb.colorize(prompt, :input_prompt))
|
9
|
+
FancyIrb.handle_prompt(
|
10
|
+
prompt_non_fancy(*args, &block),
|
11
|
+
IRB.conf[:AUTO_INDENT] ? @scanner.indent * 2 : 0,
|
12
|
+
IRB.conf[:AUTO_INDENT] && IRB.conf[:PROMPT][IRB.conf[:PROMPT_MODE]][:PROMPT_C] == args[0]
|
13
|
+
)
|
37
14
|
end
|
38
15
|
|
39
|
-
# reset line and capture IRB errors (part 2)
|
40
16
|
alias signal_status_non_fancy signal_status
|
41
17
|
def signal_status(name, *args, &block)
|
42
18
|
FancyIrb.reset_line!
|
@@ -51,7 +27,6 @@ module IRB
|
|
51
27
|
class Context
|
52
28
|
alias evaluate_non_fancy evaluate
|
53
29
|
|
54
|
-
# capture IRB errors (part 1)
|
55
30
|
def evaluate(*args)
|
56
31
|
evaluate_non_fancy(*args)
|
57
32
|
rescue Exception
|
@@ -1,20 +1,19 @@
|
|
1
1
|
module FancyIrb
|
2
2
|
module SizeDetector
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def width_of(data)
|
6
|
+
return 0 unless data
|
7
|
+
data = Paint.unpaint data.to_s
|
8
|
+
FancyIrb.east_asian_width? ? data.display_size : data.size
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
data
|
13
|
-
lines = data.count("\n")
|
11
|
+
def height_of(data, width)
|
12
|
+
data = data.to_s
|
14
13
|
long_lines = data.split("\n").inject(0){ |sum, line|
|
15
|
-
sum +
|
14
|
+
sum + width_of(line) / (width + 1)
|
16
15
|
}
|
17
|
-
|
16
|
+
data.count("\n") + long_lines
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
data/lib/fancy_irb/version.rb
CHANGED
data/lib/fancy_irb.rb
CHANGED
@@ -9,32 +9,10 @@ require_relative 'fancy_irb/error_capturer'
|
|
9
9
|
require_relative 'fancy_irb/implementation'
|
10
10
|
|
11
11
|
module FancyIrb
|
12
|
-
DEFAULT_RESULT_PROC = proc{ |context|
|
13
|
-
if context.inspect?
|
14
|
-
if defined?(context.last_value.inspect)
|
15
|
-
context.last_value.inspect
|
16
|
-
else
|
17
|
-
"(Object doesn't support #inspect)"
|
18
|
-
end
|
19
|
-
else
|
20
|
-
context.last_value
|
21
|
-
end
|
22
|
-
}
|
23
|
-
|
24
|
-
DEFAULT_COLORIZER_PROC = proc{ |value|
|
25
|
-
if defined?(Wirb)
|
26
|
-
Wirb.colorize_result value
|
27
|
-
else
|
28
|
-
value
|
29
|
-
end
|
30
|
-
}
|
31
|
-
|
32
12
|
DEFAULT_OPTIONS = {
|
33
13
|
:rocket_mode => true, # activate or deactivate #=> rocket output
|
34
14
|
:rocket_prompt => '#=> ', # prompt to use for the rocket
|
35
15
|
:result_prompt => '=> ', # prompt to use for normal output
|
36
|
-
:result_proc => DEFAULT_RESULT_PROC, # how to get the output result from IRB
|
37
|
-
:output_procs => [DEFAULT_COLORIZER_PROC], # output formatter procs
|
38
16
|
:east_asian_width => false, # set to true if you have double-width characters (slower)
|
39
17
|
:colorize => { # colors hash. Set to nil to deactivate colors
|
40
18
|
:rocket_prompt => [:blue],
|
data/spec/fixtures.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'paint'
|
2
|
+
|
3
|
+
EXAMPLE_HEIGHT_DATA = [
|
4
|
+
["bla", 10, 0],
|
5
|
+
["\n", 10, 1],
|
6
|
+
["bla\n", 10, 1],
|
7
|
+
["bla\nblubb", 10, 1],
|
8
|
+
["bla\n\nblubb", 10, 2],
|
9
|
+
["b"*10, 10, 0],
|
10
|
+
["b"*11, 10, 1],
|
11
|
+
[Paint["b"*10, :red], 10, 0],
|
12
|
+
[Paint["b"*11, :red], 10, 1],
|
13
|
+
]
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative "../lib/fancy_irb"
|
2
|
+
require_relative 'fixtures'
|
3
|
+
|
4
|
+
describe FancyIrb::SizeDetector do
|
5
|
+
include FancyIrb::SizeDetector
|
6
|
+
|
7
|
+
before do
|
8
|
+
FancyIrb.instance_variable_set(:@options, {east_asian_width: false})
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
describe ".width_of" do
|
13
|
+
it "returns 0 when no data given" do
|
14
|
+
expect( width_of(nil) ).to eq 0
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns string length for 'normal' data" do
|
18
|
+
expect( width_of("string") ).to eq 6
|
19
|
+
end
|
20
|
+
|
21
|
+
it "removes ansi escape chars" do
|
22
|
+
expect( width_of("\e[31mstring\e[0m") ).to eq 6
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does not respect double-width chars by default" do
|
26
|
+
expect( width_of('一') ).to eq 1
|
27
|
+
end
|
28
|
+
|
29
|
+
context "east_asian_width? true" do
|
30
|
+
before do
|
31
|
+
require 'unicode/display_size'
|
32
|
+
FancyIrb.instance_variable_set(:@options, {east_asian_width: true})
|
33
|
+
end
|
34
|
+
|
35
|
+
it "respects double-width chars" do
|
36
|
+
expect( width_of('一') ).to eq 2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".height_of" do
|
42
|
+
EXAMPLE_HEIGHT_DATA.each{ |data, terminal_cols, expected|
|
43
|
+
example "#{data[0...20]}#{'...' if data[20]}".inspect.ljust(28) +
|
44
|
+
"with terminal width #{terminal_cols} is #{expected}" do
|
45
|
+
expect( height_of(data, terminal_cols) ).to eq expected
|
46
|
+
end
|
47
|
+
}
|
48
|
+
|
49
|
+
it "can be accumulated" do
|
50
|
+
data_head = "head"
|
51
|
+
data_tail = "tail"
|
52
|
+
expect(
|
53
|
+
height_of(data_head, 80) + height_of(data_tail, 80)
|
54
|
+
).to eq height_of(data_head + data_tail, 80)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancy_irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paint
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9
|
19
|
+
version: '0.9'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9
|
29
|
+
version: '0.9'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: unicode-display_width
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,15 +44,43 @@ dependencies:
|
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: 0.2.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.2'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '10.4'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '10.4'
|
41
75
|
description: 'FancyIrb makes IRB # => friendly.'
|
42
76
|
email: mail@janlelis.de
|
43
77
|
executables: []
|
44
78
|
extensions: []
|
45
79
|
extra_rdoc_files: []
|
46
80
|
files:
|
47
|
-
- CHANGELOG.
|
81
|
+
- CHANGELOG.md
|
48
82
|
- MIT-LICENSE.txt
|
49
|
-
- README.
|
83
|
+
- README.md
|
50
84
|
- Rakefile
|
51
85
|
- fancy_irb.gemspec
|
52
86
|
- lib/fancy_irb.rb
|
@@ -58,6 +92,8 @@ files:
|
|
58
92
|
- lib/fancy_irb/size_detector.rb
|
59
93
|
- lib/fancy_irb/terminal_info.rb
|
60
94
|
- lib/fancy_irb/version.rb
|
95
|
+
- spec/fixtures.rb
|
96
|
+
- spec/size_detector_spec.rb
|
61
97
|
homepage: http://github.com/janlelis/fancy_irb
|
62
98
|
licenses:
|
63
99
|
- MIT
|
data/README.rdoc
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
= FancyIrb
|
2
|
-
|
3
|
-
* Colorizes prompts, errors, +stderr+ and +stdout+
|
4
|
-
* Uses Hash Rockets to display evaluation results
|
5
|
-
* Allows you to apply a proc before showing the result
|
6
|
-
|
7
|
-
|
8
|
-
== Usage
|
9
|
-
|
10
|
-
require 'fancy_irb'
|
11
|
-
FancyIrb.start
|
12
|
-
|
13
|
-
You can pass an options hash. These are the default values:
|
14
|
-
|
15
|
-
DEFAULT_OPTIONS = {
|
16
|
-
:rocket_mode => true, # activate or deactivate #=> rocket output
|
17
|
-
:rocket_prompt => '#=> ', # prompt to use for the rocket
|
18
|
-
:result_prompt => '=> ', # prompt to use for normal output
|
19
|
-
:result_proc => DEFAULT_RESULT_PROC, # how to get the output result from IRB
|
20
|
-
:output_procs => [DEFAULT_COLORIZER_PROC], # output formatter procs
|
21
|
-
:east_asian_width => false, # set to true if you have double-width characters (slower)
|
22
|
-
:colorize => { # colors hash. Set to nil to deactivate colors
|
23
|
-
:rocket_prompt => [:blue],
|
24
|
-
:result_prompt => [:blue],
|
25
|
-
:input_prompt => nil,
|
26
|
-
:irb_errors => [:red, :clean],
|
27
|
-
:stderr => [:red, :bright],
|
28
|
-
:stdout => nil,
|
29
|
-
:input => nil,
|
30
|
-
},
|
31
|
-
}
|
32
|
-
|
33
|
-
Rocket mode means: Output result as comment if there is enough space left on the terminal line and +stdout+ does not output more than the current terminal height.
|
34
|
-
|
35
|
-
For more information on which colors can be used, see the {paint documentation}[https://github.com/janlelis/paint].
|
36
|
-
|
37
|
-
|
38
|
-
== Example configurations
|
39
|
-
=== Default
|
40
|
-
FancyIrb.start
|
41
|
-
|
42
|
-
=== No colorization
|
43
|
-
FancyIrb.start :colorize => nil
|
44
|
-
|
45
|
-
=== Use awesome_print for inspecting
|
46
|
-
require 'ap'
|
47
|
-
FancyIrb.start :rocket_mode => false,
|
48
|
-
:colorize => { :output => false,
|
49
|
-
:result_prompt => :yellow },
|
50
|
-
:result_proc => proc{ |context|
|
51
|
-
context.last_value.awesome_inspect
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
== Advanced: Hook into IRB
|
56
|
-
You can modify how to get and display the input. The <tt>result_proc</tt> is a proc which takes the irb context object and should return the value. You can change it with <tt>FancyIrb.set_result_proc do (your code) end</tt>. After that, each proc in <tt>output_procs</tt> gets triggered. They take the value and can return a modified one. You can use the <tt>FancyIrb.add_output_proc</tt> method for adding new output filter procs.
|
57
|
-
|
58
|
-
=== Default result_proc
|
59
|
-
|
60
|
-
DEFAULT_RESULT_PROC = proc{ |context|
|
61
|
-
if context.inspect?
|
62
|
-
if defined?(context.last_value.inspect)
|
63
|
-
context.last_value.inspect
|
64
|
-
else
|
65
|
-
"(Object doesn't support #inspect)"
|
66
|
-
end
|
67
|
-
else
|
68
|
-
context.last_value
|
69
|
-
end
|
70
|
-
}
|
71
|
-
|
72
|
-
=== Default colorizer_proc
|
73
|
-
|
74
|
-
DEFAULT_COLORIZER_PROC = proc{ |value|
|
75
|
-
if defined?(Wirb)
|
76
|
-
Wirb.colorize_result value
|
77
|
-
else
|
78
|
-
value
|
79
|
-
end
|
80
|
-
}
|
81
|
-
|
82
|
-
== Troubleshooting
|
83
|
-
=== Windows Support
|
84
|
-
You will need ansicon[https://github.com/adoxa/ansicon].
|
85
|
-
|
86
|
-
=== Wrong display widths?
|
87
|
-
When using double-width unicode chars, you should set <tt>:east_asian_width</tt> to <tt>true</tt>. It is not activated by default, because of its performance impact.
|
88
|
-
|
89
|
-
=== Known bugs
|
90
|
-
Not all stdin methods are patched properly to work with the rocket: The gems focuses on the often used ones
|
91
|
-
|
92
|
-
|
93
|
-
== TODO
|
94
|
-
* Refactor to modern code
|
95
|
-
* Just count string lengths without ansi escape sequences (would be more flexible than remembering)
|
96
|
-
|
97
|
-
|
98
|
-
== J-_-L
|
99
|
-
Inspired by the irb_rocket gem by genki.
|
100
|
-
|
101
|
-
Copyright (c) 2010-2012, 2015 Jan Lelis <http://janlelis.com> released under the MIT license.
|