fancy_irb 1.0.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +16 -9
- data/MIT-LICENSE.txt +1 -1
- data/README.md +14 -16
- data/Rakefile +1 -1
- data/fancy_irb.gemspec +6 -7
- data/lib/fancy_irb.rb +7 -5
- data/lib/fancy_irb/implementation.rb +3 -3
- data/lib/fancy_irb/irb_ext.rb +3 -3
- data/lib/fancy_irb/size_detector.rb +1 -1
- data/lib/fancy_irb/terminal_info.rb +7 -0
- data/lib/fancy_irb/version.rb +3 -1
- data/spec/size_detector_spec.rb +7 -9
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 739bfe501631f6fd5f4a78e6f92dda52bb41a8ac989d769a70cbdac26f6b547c
|
4
|
+
data.tar.gz: eb804f9241bd2c9e7c63e1e71b4e0aa518b0498b8d090d86977870e8502136c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3f99a944370418ab561de7ca337fde9cf1384cd7b7041a7f6342175c1b732934e09f46ebe5d0bc43984b0f3909d7e0c6f9cabbf83abe5c7228af8758d4f5ce2
|
7
|
+
data.tar.gz: d60a4522e55035980b9f50fc6d0bdd36d66fc7177ad23051803a69e9f7cf38a2e4000c12f733722c2b706a699e3297e6e18f56e6efc93c0ab8800f85446c81b3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.3.0
|
4
|
+
* Use `script` wrapper on linux in case we are not on a tty
|
5
|
+
|
6
|
+
## 1.2.1
|
7
|
+
* Fix 2.7 keyword warning
|
8
|
+
|
9
|
+
## 1.2.0
|
10
|
+
* Read indentation level directly so it won't fail on newer Rubies
|
11
|
+
|
12
|
+
## 1.1.0
|
13
|
+
* Rename `east_asian_width` option to `unicode_display_width` and activate by default
|
14
|
+
* Relax paint dependency
|
15
|
+
|
16
|
+
## 1.0.2
|
17
|
+
* Bump unicode-display_width to 1.0
|
18
|
+
|
3
19
|
## 1.0.1
|
4
20
|
* Fix that unicode-display_width was not used properly
|
5
21
|
|
@@ -9,15 +25,12 @@
|
|
9
25
|
* Recognize multi-line regexes
|
10
26
|
* Improve size detector (-> less wrongly placed rockets)
|
11
27
|
|
12
|
-
|
13
28
|
## 0.8.2
|
14
29
|
* Support objects that don't support #inspect
|
15
30
|
|
16
|
-
|
17
31
|
## 0.8.1
|
18
32
|
* Use io/console correctly, fixes bug on mingw
|
19
33
|
|
20
|
-
|
21
34
|
## 0.8.0
|
22
35
|
* Internals partly refactored
|
23
36
|
* Bump paint and unicode-display_width dependencies
|
@@ -29,28 +42,22 @@
|
|
29
42
|
* Not patching Kernel anymore
|
30
43
|
* Only path String if east_asian_width option is used
|
31
44
|
|
32
|
-
|
33
45
|
## 0.7.3
|
34
46
|
* Don't colorize stdout by default
|
35
47
|
* Deactivate rocket for common system commands
|
36
48
|
|
37
|
-
|
38
49
|
## 0.7.2
|
39
50
|
* Fix a small bug that happens if there was no last line
|
40
51
|
|
41
|
-
|
42
52
|
## 0.7.1
|
43
53
|
* Deactivate buggy input coloring :/
|
44
54
|
|
45
|
-
|
46
55
|
## 0.7.0
|
47
56
|
* Use paint gem for terminal colors
|
48
57
|
* Fix some rocket issues (when using with colored content)
|
49
58
|
|
50
|
-
|
51
59
|
## 0.6.5
|
52
60
|
* Windows support
|
53
61
|
|
54
|
-
|
55
62
|
## < 0.6.5
|
56
63
|
See https://github.com/janlelis/fancy_irb/commits/0.6.4
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# FancyIrb [![version](https://badge.fury.io/rb/fancy_irb.svg)](
|
1
|
+
# FancyIrb [![version](https://badge.fury.io/rb/fancy_irb.svg)](https://badge.fury.io/rb/fancy_irb) [![[ci]](https://github.com/janlelis/fancy_irb/workflows/Test/badge.svg)](https://github.com/janlelis/fancy_irb/actions?query=workflow%3ATest)
|
2
2
|
|
3
3
|
* Colorizes IRB prompts, errors, `$stderr` and `$stdout`
|
4
4
|
* Uses "Hash Rockets" (# =>) to display IRB results
|
5
5
|
|
6
|
-
|
7
6
|
## Usage
|
8
7
|
|
9
8
|
require 'fancy_irb'
|
@@ -12,11 +11,12 @@
|
|
12
11
|
You can pass an options hash. These are the default values:
|
13
12
|
|
14
13
|
DEFAULT_OPTIONS = {
|
15
|
-
:rocket_mode => true,
|
16
|
-
:rocket_prompt => '#=> ',
|
17
|
-
:result_prompt => '=> ',
|
18
|
-
:
|
19
|
-
|
14
|
+
:rocket_mode => true, # activate or deactivate #=> rocket
|
15
|
+
:rocket_prompt => '#=> ', # prompt to use for the rocket
|
16
|
+
:result_prompt => '=> ', # prompt to use for normal output
|
17
|
+
:unicode_display_width => true, # set to false if you don't want to check for proper
|
18
|
+
# string width for better performance
|
19
|
+
:colorize => { # colors hash. Set to nil to deactivate colors
|
20
20
|
:rocket_prompt => [:blue],
|
21
21
|
:result_prompt => [:blue],
|
22
22
|
:input_prompt => nil,
|
@@ -31,25 +31,23 @@ Rocket mode means: Output result as comment if there is enough space left on
|
|
31
31
|
the terminal line and `stdout` does not output more than the current terminal
|
32
32
|
height.
|
33
33
|
|
34
|
-
For more information on which colors can be used, see the [paint
|
35
|
-
documentation](https://github.com/janlelis/paint).
|
36
|
-
|
34
|
+
For more information on which colors can be used, see the [paint documentation](https://github.com/janlelis/paint).
|
37
35
|
|
38
36
|
## Troubleshooting
|
39
37
|
### Windows Support
|
40
38
|
You will need [ansicon](https://github.com/adoxa/ansicon) or [ConEmu](https://code.google.com/p/conemu-maximus5/).
|
41
39
|
|
42
|
-
###
|
43
|
-
|
44
|
-
|
40
|
+
### Need More Performance?
|
41
|
+
The gem checks for the Unicode display width of characters, which requires a
|
42
|
+
lookup of every character. You can deactivate this check by setting
|
43
|
+
`:unicode_display_width` to `false`.
|
45
44
|
|
46
|
-
### Known
|
45
|
+
### Known Bugs
|
47
46
|
Not all stdin methods are patched properly to work with the rocket: The gems
|
48
47
|
focuses on the often used ones
|
49
48
|
|
50
|
-
|
51
49
|
## J-_-L
|
52
50
|
Inspired by the irb_rocket gem by genki.
|
53
51
|
|
54
|
-
Copyright (c) 2010-2012, 2015 Jan Lelis <
|
52
|
+
Copyright (c) 2010-2012, 2015-2020 Jan Lelis <https://janlelis.com> released under
|
55
53
|
the MIT license.
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
desc "Install the gem locally (without docs)"
|
17
17
|
task :install => :gem do
|
18
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}.gem --no-
|
18
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}.gem --no-doc --local}
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Generate the gemspec"
|
data/fancy_irb.gemspec
CHANGED
@@ -6,15 +6,15 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "fancy_irb"
|
7
7
|
s.version = FancyIrb::VERSION
|
8
8
|
s.authors = ["Jan Lelis"]
|
9
|
-
s.email = "
|
10
|
-
s.homepage = "
|
11
|
-
s.summary = "FancyIrb makes IRB friendly."
|
12
|
-
s.description = "
|
9
|
+
s.email = ["hi@ruby.consulting"]
|
10
|
+
s.homepage = "https://github.com/janlelis/fancy_irb"
|
11
|
+
s.summary = "FancyIrb makes IRB # => friendly."
|
12
|
+
s.description = "A fancy IRB has a colorful input prompt and profiles rocket-style #=> return values"
|
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', '<
|
17
|
-
s.add_dependency 'unicode-display_width', "~>
|
16
|
+
s.add_dependency 'paint', '>= 0.9', '< 3.0'
|
17
|
+
s.add_dependency 'unicode-display_width', "~> 1.1"
|
18
18
|
s.add_development_dependency 'rspec', "~> 3.2"
|
19
19
|
s.add_development_dependency 'rake', "~> 10.4"
|
20
20
|
s.files = [
|
@@ -37,4 +37,3 @@ Gem::Specification.new do |s|
|
|
37
37
|
"spec/fixtures.rb",
|
38
38
|
]
|
39
39
|
end
|
40
|
-
|
data/lib/fancy_irb.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'fancy_irb/version'
|
|
2
2
|
|
3
3
|
require 'stringio'
|
4
4
|
require 'paint'
|
5
|
+
require 'unicode/display_width'
|
5
6
|
|
6
7
|
require_relative 'fancy_irb/terminal_info'
|
7
8
|
require_relative 'fancy_irb/size_detector'
|
@@ -10,11 +11,12 @@ require_relative 'fancy_irb/implementation'
|
|
10
11
|
|
11
12
|
module FancyIrb
|
12
13
|
DEFAULT_OPTIONS = {
|
13
|
-
:rocket_mode => true,
|
14
|
-
:rocket_prompt => '#=> ',
|
15
|
-
:result_prompt => '=> ',
|
16
|
-
:
|
17
|
-
|
14
|
+
:rocket_mode => true, # activate or deactivate #=> rocket output
|
15
|
+
:rocket_prompt => '#=> ', # prompt to use for the rocket
|
16
|
+
:result_prompt => '=> ', # prompt to use for normal output
|
17
|
+
:unicode_display_width => true, # set to false if you don't want to check for proper
|
18
|
+
# string width for better performance
|
19
|
+
:colorize => { # colors hash. Set to nil to deactivate colors
|
18
20
|
:rocket_prompt => [:blue],
|
19
21
|
:result_prompt => [:blue],
|
20
22
|
:input_prompt => nil,
|
@@ -17,7 +17,6 @@ module FancyIrb
|
|
17
17
|
|
18
18
|
# hook into IRB
|
19
19
|
def extend!
|
20
|
-
require 'unicode/display_width' if @options[:east_asian_width]
|
21
20
|
require_relative 'irb_ext'
|
22
21
|
require_relative 'core_ext'
|
23
22
|
require_relative 'clean_up'
|
@@ -51,9 +50,10 @@ module FancyIrb
|
|
51
50
|
}
|
52
51
|
end
|
53
52
|
|
54
|
-
def
|
55
|
-
@options[:east_asian_width]
|
53
|
+
def unicode_display_width?
|
54
|
+
@options[:unicode_display_width] || @options[:east_asian_width]
|
56
55
|
end
|
56
|
+
alias east_asian_width? unicode_display_width?
|
57
57
|
|
58
58
|
def reset_line!
|
59
59
|
@tracked_height = 0
|
data/lib/fancy_irb/irb_ext.rb
CHANGED
@@ -8,7 +8,7 @@ module IRB
|
|
8
8
|
def prompt(*args, &block)
|
9
9
|
FancyIrb.handle_prompt(
|
10
10
|
prompt_non_fancy(*args, &block),
|
11
|
-
IRB.conf[:AUTO_INDENT] ? @scanner.indent * 2 : 0,
|
11
|
+
IRB.conf[:AUTO_INDENT] ? @scanner.instance_variable_get(:@indent) * 2 : 0,
|
12
12
|
IRB.conf[:AUTO_INDENT] && IRB.conf[:PROMPT][IRB.conf[:PROMPT_MODE]][:PROMPT_C] == args[0]
|
13
13
|
)
|
14
14
|
end
|
@@ -27,8 +27,8 @@ module IRB
|
|
27
27
|
class Context
|
28
28
|
alias evaluate_non_fancy evaluate
|
29
29
|
|
30
|
-
def evaluate(*args)
|
31
|
-
evaluate_non_fancy(*args)
|
30
|
+
def evaluate(*args, **kwargs)
|
31
|
+
evaluate_non_fancy(*args, **kwargs)
|
32
32
|
rescue Exception
|
33
33
|
FancyIrb.register_error_capturer!
|
34
34
|
raise
|
@@ -5,7 +5,7 @@ module FancyIrb
|
|
5
5
|
def width_of(data)
|
6
6
|
return 0 unless data
|
7
7
|
data = Paint.unpaint data.to_s
|
8
|
-
FancyIrb.
|
8
|
+
FancyIrb.unicode_display_width? ? Unicode::DisplayWidth.of(data) : data.length
|
9
9
|
end
|
10
10
|
|
11
11
|
def height_of(data, width)
|
@@ -17,6 +17,13 @@ module FancyIrb
|
|
17
17
|
:cuu1 => "\e[1A",
|
18
18
|
:cuf1 => "\e[1C",
|
19
19
|
}
|
20
|
+
elsif RbConfig::CONFIG['host_os'] =~ /linux/
|
21
|
+
TPUT = {
|
22
|
+
:sc => `script -q -e -t /dev/null -c 'tput sc'`,
|
23
|
+
:rc => `script -q -e -t /dev/null -c 'tput rc'`,
|
24
|
+
:cuu1 => `script -q -e -t /dev/null -c 'tput cuu1'`,
|
25
|
+
:cuf1 => `script -q -e -t /dev/null -c 'tput cuf1'`,
|
26
|
+
}
|
20
27
|
else
|
21
28
|
TPUT = {
|
22
29
|
:sc => `tput sc`,
|
data/lib/fancy_irb/version.rb
CHANGED
data/spec/size_detector_spec.rb
CHANGED
@@ -5,10 +5,9 @@ describe FancyIrb::SizeDetector do
|
|
5
5
|
include FancyIrb::SizeDetector
|
6
6
|
|
7
7
|
before do
|
8
|
-
FancyIrb.instance_variable_set(:@options, {
|
8
|
+
FancyIrb.instance_variable_set(:@options, { unicode_display_width: true })
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
describe ".width_of" do
|
13
12
|
it "returns 0 when no data given" do
|
14
13
|
expect( width_of(nil) ).to eq 0
|
@@ -22,18 +21,17 @@ describe FancyIrb::SizeDetector do
|
|
22
21
|
expect( width_of("\e[31mstring\e[0m") ).to eq 6
|
23
22
|
end
|
24
23
|
|
25
|
-
it "
|
26
|
-
expect( width_of('一') ).to eq
|
24
|
+
it "respects double-width chars by default" do
|
25
|
+
expect( width_of('一') ).to eq 2
|
27
26
|
end
|
28
27
|
|
29
|
-
context "
|
28
|
+
context "unicode_display_width? false" do
|
30
29
|
before do
|
31
|
-
|
32
|
-
FancyIrb.instance_variable_set(:@options, {east_asian_width: true})
|
30
|
+
FancyIrb.instance_variable_set(:@options, { unicode_display_width: false })
|
33
31
|
end
|
34
32
|
|
35
|
-
it "
|
36
|
-
expect( width_of('一') ).to eq
|
33
|
+
it "does not respect double-width chars" do
|
34
|
+
expect( width_of('一') ).to eq 1
|
37
35
|
end
|
38
36
|
end
|
39
37
|
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: 1.0
|
4
|
+
version: 1.3.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:
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paint
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.9'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,21 +29,21 @@ dependencies:
|
|
29
29
|
version: '0.9'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: unicode-display_width
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: '1.1'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: '1.1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,8 +72,10 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '10.4'
|
75
|
-
description: '
|
76
|
-
|
75
|
+
description: 'A fancy IRB has a colorful input prompt and profiles rocket-style #=>
|
76
|
+
return values'
|
77
|
+
email:
|
78
|
+
- hi@ruby.consulting
|
77
79
|
executables: []
|
78
80
|
extensions: []
|
79
81
|
extra_rdoc_files: []
|
@@ -95,7 +97,7 @@ files:
|
|
95
97
|
- lib/fancy_irb/version.rb
|
96
98
|
- spec/fixtures.rb
|
97
99
|
- spec/size_detector_spec.rb
|
98
|
-
homepage:
|
100
|
+
homepage: https://github.com/janlelis/fancy_irb
|
99
101
|
licenses:
|
100
102
|
- MIT
|
101
103
|
metadata: {}
|
@@ -115,9 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
117
|
version: '0'
|
116
118
|
requirements:
|
117
119
|
- 'Windows: ansicon <https://github.com/adoxa/ansicon>'
|
118
|
-
|
119
|
-
rubygems_version: 2.5.1
|
120
|
+
rubygems_version: 3.1.2
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
|
-
summary: FancyIrb makes IRB friendly.
|
123
|
+
summary: 'FancyIrb makes IRB # => friendly.'
|
123
124
|
test_files: []
|