rib 0.9.9 → 1.0.0
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.
- data/.travis.yml +2 -1
- data/CHANGES.md +7 -1
- data/TODO.md +1 -1
- data/lib/rib/more/color.rb +11 -7
- data/lib/rib/version.rb +1 -1
- data/rib.gemspec +2 -2
- data/test/more/test_color.rb +12 -3
- metadata +2 -2
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/TODO.md
CHANGED
data/lib/rib/more/color.rb
CHANGED
@@ -62,18 +62,22 @@ module Rib::Color
|
|
62
62
|
def get_error err, backtrace=err.backtrace
|
63
63
|
return super if Color.disabled?
|
64
64
|
[format_color(err, "#{err.class.to_s}: #{err.message}"),
|
65
|
-
backtrace
|
66
|
-
path, rest = ::File.split(b)
|
67
|
-
name, msgs = rest.split(':', 2)
|
68
|
-
msg = msgs.sub(/(\d+):/){red{$1}+':'}.sub(/`.+?'/){green{$&}}
|
69
|
-
|
70
|
-
"#{path+'/'}#{yellow{name}}:#{msg}"
|
71
|
-
}]
|
65
|
+
colorize_backtrace(backtrace)]
|
72
66
|
end
|
73
67
|
|
74
68
|
|
75
69
|
|
76
70
|
module_function
|
71
|
+
def colorize_backtrace backtrace
|
72
|
+
backtrace.map{ |b|
|
73
|
+
path, msgs = b.split(':', 2)
|
74
|
+
dir , file = ::File.split(path)
|
75
|
+
msg = msgs.sub(/(\d+):/){red{$1}+':'}.sub(/`.+?'/){green{$&}}
|
76
|
+
|
77
|
+
"#{dir+'/'}#{yellow{file}}:#{msg}"
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
77
81
|
def find_color colors, value
|
78
82
|
(colors.sort{ |(k1, v1), (k2, v2)|
|
79
83
|
# Class <=> Class
|
data/lib/rib/version.rb
CHANGED
data/rib.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rib"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "1.0.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
9
|
-
s.date = "2011-
|
9
|
+
s.date = "2011-11-05"
|
10
10
|
s.description = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell\n\nRib is based on the design of [ripl][] and the work of [ripl-rc][], some of\nthe features are also inspired by [pry][]. The aim of Rib is to be fully\nfeatured and yet very easy to opt-out or opt-in other features. It shall\nbe simple, lightweight and modular so that everyone could customize Rib.\n\n[ripl]: https://github.com/cldwalker/ripl\n[ripl-rc]: https://github.com/godfat/ripl-rc\n[pry]: https://github.com/pry/pry"
|
11
11
|
s.email = ["godfat (XD) godfat.org"]
|
12
12
|
s.executables = [
|
data/test/more/test_color.rb
CHANGED
@@ -5,16 +5,14 @@ require 'rib/more/color'
|
|
5
5
|
describe Rib::Color do
|
6
6
|
behaves_like :rib
|
7
7
|
|
8
|
-
|
8
|
+
should 'give correct color' do
|
9
9
|
@color = Class.new do
|
10
10
|
include Rib::Color
|
11
11
|
def colors
|
12
12
|
@colors ||= Rib::Shell.new.before_loop.config[:color]
|
13
13
|
end
|
14
14
|
end.new
|
15
|
-
end
|
16
15
|
|
17
|
-
should 'give correct color' do
|
18
16
|
@color.send(:format_color,
|
19
17
|
[{0 => :a}, 'b', [nil, {false => Object}], {true => Exception.new}]).
|
20
18
|
should.eq \
|
@@ -25,4 +23,15 @@ describe Rib::Color do
|
|
25
23
|
"{\e[0m\e[35mtrue\e[0m\e[34m=>\e[0m\e[35m#<Exception: Exception>" \
|
26
24
|
"\e[0m\e[34m}\e[0m\e[34m]\e[0m"
|
27
25
|
end
|
26
|
+
|
27
|
+
# regression test
|
28
|
+
should "colorize errors with `/' inside" do
|
29
|
+
begin
|
30
|
+
line = __LINE__; 1/0
|
31
|
+
rescue ZeroDivisionError => e
|
32
|
+
Rib::Color.colorize_backtrace(e.backtrace).first.should.end_with? \
|
33
|
+
"test/more/#{Rib::Color.yellow{'test_color.rb'}}:" \
|
34
|
+
"#{Rib::Color.red{line}}:in #{Rib::Color.green{"`/'"}}"
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
|
15
15
|
|