wirb 1.0.3 → 2.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.
- checksums.yaml +4 -4
- data/{CHANGELOG.rdoc → CHANGELOG.md} +51 -25
- data/COPYING.txt +5 -5
- data/README.md +75 -0
- data/data/wirb/{classic_paint.yml → classic.yml} +11 -42
- data/data/wirb/colorless.yml +10 -27
- data/data/wirb/gray.yml +103 -0
- data/lib/wirb.rb +69 -114
- data/lib/wirb/inspector.rb +10 -0
- data/lib/wirb/irb.rb +3 -12
- data/lib/wirb/schema_builder.rb +44 -0
- data/lib/wirb/tokenizer.rb +404 -430
- data/lib/wirb/version.rb +1 -1
- data/lib/wirb/wp.rb +3 -7
- data/spec/spec_helper.rb +5 -122
- data/spec/tokenizer_enumerator_spec.rb +580 -37
- data/spec/tokenizer_misc_spec.rb +55 -53
- data/spec/tokenizer_number_spec.rb +30 -28
- data/spec/tokenizer_object_spec.rb +67 -31
- data/wirb.gemspec +8 -20
- metadata +33 -48
- data/.gemtest +0 -0
- data/README.rdoc +0 -79
- data/data/wirb/classic_wirb0.yml +0 -72
- data/lib/wirb/colorizer.rb +0 -26
- data/lib/wirb/colorizer/highline.rb +0 -16
- data/lib/wirb/colorizer/paint.rb +0 -11
- data/lib/wirb/colorizer/wirb0.rb +0 -53
- data/lib/wirb/colorizer/wirb0_highline.rb +0 -73
- data/lib/wirb/colorizer/wirb0_paint.rb +0 -71
- data/lib/wirb/colorizer/wirble.rb +0 -30
- data/spec/colorizer_highline_spec.rb +0 -23
- data/spec/colorizer_paint_spec.rb +0 -33
- data/spec/colorizer_spec.rb +0 -67
- data/spec/colorizer_wirb0_highline_spec.rb +0 -78
- data/spec/colorizer_wirb0_paint_spec.rb +0 -35
- data/spec/colorizer_wirb0_spec.rb +0 -11
- data/spec/colorizer_wirble_spec.rb +0 -24
- data/spec/tokenizer_rubygems_spec.rb +0 -84
@@ -1,23 +0,0 @@
|
|
1
|
-
begin # only test if highline is available
|
2
|
-
require 'highline'
|
3
|
-
|
4
|
-
describe Wirb::Colorizer::HighLine do
|
5
|
-
before :each do
|
6
|
-
Wirb.colorizer = Wirb::Colorizer::HighLine
|
7
|
-
end
|
8
|
-
|
9
|
-
it "creates good color codes based on Highline color symbols" do
|
10
|
-
Wirb.get_color(:reverse, :underline, :magenta).should match_colors(4,7,35)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "colorizes strings based on Highline color symbols" do
|
14
|
-
Wirb.colorize_string('Dantooine', :blink, :on_red).should match_colored_string('Dantooine', 5,41)
|
15
|
-
end
|
16
|
-
|
17
|
-
after :each do
|
18
|
-
Wirb.colorizer = nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
rescue LoadError
|
23
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
begin # only test if paint is available
|
2
|
-
require 'paint'
|
3
|
-
|
4
|
-
describe Wirb::Colorizer::Paint do
|
5
|
-
before :each do
|
6
|
-
Wirb.colorizer = Wirb::Colorizer::Paint
|
7
|
-
end
|
8
|
-
|
9
|
-
it "creates good color codes based on Paint color symbols" do
|
10
|
-
Wirb.get_color(:red).should match_colors(31)
|
11
|
-
Wirb.get_color(:red, :bright).should match_colors(1,31)
|
12
|
-
Wirb.get_color(:bright, :red).should match_colors(1,31)
|
13
|
-
Wirb.get_color(:red, :bright, :underline).should match_colors(1,4,31)
|
14
|
-
Wirb.get_color(:red, :blue).should match_colors(31,44)
|
15
|
-
Wirb.get_color(nil, :blue).should match_colors(44)
|
16
|
-
Wirb.get_color([43,86,129]).should match_colors('38;5;'+(16 + 1*36 + 2*6 + 3*1).to_s)
|
17
|
-
Wirb.get_color("medium sea green").should match_colors('38;5;78')
|
18
|
-
Wirb.get_color("#81562b").should match_colors('38;5;' + (16 + 3*36 + 2*6 + 1*1).to_s)
|
19
|
-
Wirb.get_color("#863").should match_colors('38;5;' + (16 + 3*36 + 2*6 + 1*1).to_s)
|
20
|
-
Wirb.get_color(:red, :encircle).should match_colors(52,31)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "colorizes strings based on Paint color symbols" do
|
24
|
-
Wirb.colorize_string('Dantooine', :red, :bright, :underline).should match_colored_string('Dantooine', 1,4,31)
|
25
|
-
end
|
26
|
-
|
27
|
-
after :each do
|
28
|
-
Wirb.colorizer = nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
rescue LoadError
|
33
|
-
end
|
data/spec/colorizer_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
describe "Colorizer interface" do
|
2
|
-
before(:each) { Wirb.colorizer = @colorizer = double() }
|
3
|
-
|
4
|
-
it "invokes Colorizer.color to get color codes" do
|
5
|
-
@colorizer.should_receive(:color).with(:c3po)
|
6
|
-
wirb = Wirb.get_color(:c3po)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "invokes Colorizer.run to colorize strings" do
|
10
|
-
@colorizer.should_receive(:run).with('chewbacca', 'r2d2')
|
11
|
-
wirb = Wirb.colorize_string('chewbacca', 'r2d2')
|
12
|
-
end
|
13
|
-
|
14
|
-
after(:each) {Wirb.colorizer = nil}
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "Colorizer loading" do
|
18
|
-
before(:each) {Wirb.colorizer = nil}
|
19
|
-
|
20
|
-
it "defaults to using the Paint colorizer" do
|
21
|
-
Wirb.colorizer = nil
|
22
|
-
Wirb.instance_variable_get(:@colorizer).should be_nil
|
23
|
-
foo = Wirb.colorizer # Force a colorizer to be loaded
|
24
|
-
Wirb.colorizer.should == Wirb::Colorizer::Paint
|
25
|
-
end
|
26
|
-
|
27
|
-
it "attempts to load the appropriate colorizer" do
|
28
|
-
Wirb.colorizer = nil
|
29
|
-
Wirb.instance_variable_get(:@colorizer).should be_nil
|
30
|
-
Wirb::Colorizer.should_receive(:require).
|
31
|
-
with(File.dirname(File.dirname(__FILE__)) + '/lib/wirb/colorizer/notloaded').
|
32
|
-
and_return(true)
|
33
|
-
expect {
|
34
|
-
Wirb.colorizer = Wirb::Colorizer::NotLoaded
|
35
|
-
}.to raise_error(LoadError) # Because the Colorizer doesn't actually exist, wasn't loaded
|
36
|
-
# and didn't define Wirb::Colorizer::NotLoaded
|
37
|
-
end
|
38
|
-
|
39
|
-
it "fails if the colorizer is not found" do
|
40
|
-
expect {
|
41
|
-
Wirb.colorizer = Wirb::Colorizer::DoesntExist
|
42
|
-
}.to raise_error(LoadError)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "fails if the colorizer definition doesn't define the colorizer class" do
|
46
|
-
Wirb::Colorizer.should_receive(:require).
|
47
|
-
with(File.dirname(File.dirname(__FILE__)) + '/lib/wirb/colorizer/badcolorizer').
|
48
|
-
and_return(true)
|
49
|
-
expect {
|
50
|
-
Wirb.colorizer = Wirb::Colorizer::BadColorizer
|
51
|
-
}.to raise_error(LoadError)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "sets the Colorizer object" do
|
55
|
-
Wirb.colorizer = nil
|
56
|
-
Wirb.instance_variable_get(:@colorizer).should be_nil
|
57
|
-
Wirb.colorizer = Wirb::Colorizer::Wirble
|
58
|
-
Wirb::Colorizer.const_defined?(:Wirble).should be_true
|
59
|
-
Wirb.colorizer.should == Wirb::Colorizer::Wirble
|
60
|
-
end
|
61
|
-
|
62
|
-
it "doesn't load Colorizers until they are referenced" do
|
63
|
-
# Can't figure out how to test for this, actually
|
64
|
-
end
|
65
|
-
|
66
|
-
after(:each) {Wirb.colorizer = nil}
|
67
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
begin # only test if highline is available
|
2
|
-
require 'highline'
|
3
|
-
|
4
|
-
describe Wirb::Colorizer::Wirb0_HighLine do
|
5
|
-
before :each do
|
6
|
-
Wirb.colorizer = Wirb::Colorizer::Wirb0_HighLine
|
7
|
-
end
|
8
|
-
|
9
|
-
it "creates good color codes based on Highline color symbols" do
|
10
|
-
Wirb.get_color(:highline, :reverse, :underline, :magenta).should == "\e[7m\e[4m\e[35m"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "colorizes strings based on Highline color symbols" do
|
14
|
-
Wirb.colorize_string('Dantooine', :highline, :blink, :on_red).should == "\e[5m\e[41mDantooine\e[0m"
|
15
|
-
end
|
16
|
-
|
17
|
-
it_behaves_like "a Wirb0 colorizer"
|
18
|
-
|
19
|
-
context "when using basic color names" do
|
20
|
-
it "understands the differences between HighLine and Wirb0" do
|
21
|
-
Wirb.get_color(:nothing).should match_colors(0) # Wirb0 calls this nothing
|
22
|
-
Wirb.get_color(:highline, :clear).should match_colors(0) # HighLine calls it clear
|
23
|
-
|
24
|
-
Wirb.get_color(:brown).should match_colors(0,33) # Wirb0 calls this brown
|
25
|
-
Wirb.get_color(:highline, :yellow).should match_colors(0,33) # HighLine calls it yellow
|
26
|
-
|
27
|
-
Wirb.get_color(:purple).should match_colors(0,35) # Wirb0 calls this purple
|
28
|
-
Wirb.get_color(:highline, :magenta).should match_colors(0,35) # HighLine calls it magenta
|
29
|
-
|
30
|
-
Wirb.get_color(:light_gray).should match_colors(0,37) # Wirb0 calls this light_gray
|
31
|
-
Wirb.get_color(:highline, :white).should match_colors(0,37) # HighLine calls it white
|
32
|
-
|
33
|
-
Wirb.get_color(:light_black).should match_colors(1,30) # Wirb0 calls this light_black
|
34
|
-
Wirb.get_color(:highline, :bold, :black).should match_colors(1,30) # HighLine calls it bold black
|
35
|
-
|
36
|
-
Wirb.get_color(:yellow).should match_colors(1,33) # Wirb0 calls this yellow
|
37
|
-
Wirb.get_color(:highline, :bold, :yellow).should match_colors(1,33) # HighLine calls it bold yellow
|
38
|
-
|
39
|
-
Wirb.get_color(:white).should match_colors(1,37) # Wirb0 calls this white
|
40
|
-
Wirb.get_color(:highline, :bold, :white).should match_colors(1,37) # HighLine calls it bold white
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "when using light/bold colors" do
|
45
|
-
it "understands the differences between HighLine and Wirb0" do
|
46
|
-
Wirb.get_color(:light_purple).should match_colors(1,35) # Wirb0 says :light_<color>
|
47
|
-
Wirb.get_color(:highline, :magenta, :bold).should match_colors(1,35) # HighLine says :bold, :<color>
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when using underlined colors" do
|
52
|
-
it "understands the differences between HighLine and Wirb0" do
|
53
|
-
Wirb.get_color(:light_gray_underline).should match_colors(4,37) # Wirb0 says :<color>_underline
|
54
|
-
Wirb.get_color(:highline, :underline, :white).should match_colors(4,37) # HighLine says :underline, :<color>
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when using background colors" do
|
59
|
-
it "understands the differences between HighLine and Wirb0" do
|
60
|
-
Wirb.get_color(:brown_background).should match_colors(43) # Wirb0 says :<color>_background
|
61
|
-
Wirb.get_color(:highline, :on_yellow).should match_colors(43) # HighLine says :on_<color>
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when encoding strings" do
|
66
|
-
it "understands the differences between HighLine and Wirb0" do
|
67
|
-
Wirb.colorize_string('Alderaan', :purple).should match_colored_string('Alderaan', 35) # Wirb0 calls this purple
|
68
|
-
Wirb.colorize_string('Alderaan', :highline, :magenta).should match_colored_string('Alderaan', 35) # HighLine calls it magenta
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
after :each do
|
73
|
-
Wirb.colorizer = nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
rescue LoadError
|
78
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
begin # only test if paint is available
|
2
|
-
require 'paint'
|
3
|
-
|
4
|
-
describe Wirb::Colorizer::Wirb0_Paint do
|
5
|
-
before :each do
|
6
|
-
Wirb.colorizer = Wirb::Colorizer::Wirb0_Paint
|
7
|
-
end
|
8
|
-
|
9
|
-
it "creates good color codes based on Paint color symbols" do
|
10
|
-
Wirb.get_color(:red).should match_colors(31)
|
11
|
-
Wirb.get_color(:red, :bright).should match_colors(1,31)
|
12
|
-
Wirb.get_color(:bright, :red).should match_colors(1,31)
|
13
|
-
Wirb.get_color(:red, :bright, :underline).should match_colors(1,4,31)
|
14
|
-
Wirb.get_color(:red, :blue).should match_colors(31,44)
|
15
|
-
Wirb.get_color(nil, :blue).should match_colors(44)
|
16
|
-
Wirb.get_color([43,86,129]).should match_colors('38;5;'+(16 + 1*36 + 2*6 + 3*1).to_s)
|
17
|
-
Wirb.get_color("medium sea green").should match_colors('38;5;78')
|
18
|
-
Wirb.get_color("#81562b").should match_colors('38;5;' + (16 + 3*36 + 2*6 + 1*1).to_s)
|
19
|
-
Wirb.get_color("#863").should match_colors('38;5;' + (16 + 3*36 + 2*6 + 1*1).to_s)
|
20
|
-
Wirb.get_color(:red, :encircle).should match_colors(52,31)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "colorizes strings based on Paint color symbols" do
|
24
|
-
Wirb.colorize_string('Dantooine', :red, :bright, :underline).should match_colored_string('Dantooine', 1,4,31)
|
25
|
-
end
|
26
|
-
|
27
|
-
it_behaves_like "a Wirb0 colorizer"
|
28
|
-
|
29
|
-
after :each do
|
30
|
-
Wirb.colorizer = nil
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
rescue LoadError
|
35
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
describe Wirb::Colorizer::Wirble do
|
2
|
-
before :each do
|
3
|
-
Wirb.colorizer = Wirb::Colorizer::Wirble
|
4
|
-
end
|
5
|
-
|
6
|
-
it "creates good color codes based on Wirble color symbols" do
|
7
|
-
Wirb.get_color(:nothing).should match_colors(0)
|
8
|
-
Wirb.get_color(:purple).should match_colors(35)
|
9
|
-
Wirb.get_color(:light_gray).should match_colors(37)
|
10
|
-
Wirb.get_color(:dark_gray).should match_colors(1,30)
|
11
|
-
Wirb.get_color(:yellow).should match_colors(1,33)
|
12
|
-
Wirb.get_color(:light_green).should match_colors(1,32)
|
13
|
-
Wirb.get_color(:white).should match_colors(1,37)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "colorizes strings based on Wirble color symbols" do
|
17
|
-
Wirb.colorize_string('Dantooine', :cyan).should match_colored_string('Dantooine', 36)
|
18
|
-
Wirb.colorize_string('Dantooine', :light_red).should match_colored_string('Dantooine', 1,31)
|
19
|
-
end
|
20
|
-
|
21
|
-
after :each do
|
22
|
-
Wirb.colorizer = nil
|
23
|
-
end
|
24
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
describe tokenizer(__FILE__) do
|
2
|
-
after :each do check_value end
|
3
|
-
|
4
|
-
unless RubyEngine.jruby?
|
5
|
-
please do check_inspected "> 3.0.0.beta.4"
|
6
|
-
tokens.should == [
|
7
|
-
[:gem_requirement_condition, ">"],
|
8
|
-
[:whitespace, " "],
|
9
|
-
[:gem_requirement_version, "3.0.0.beta.4"],
|
10
|
-
]
|
11
|
-
end
|
12
|
-
|
13
|
-
please do check_inspected "< 3"
|
14
|
-
tokens.should == [
|
15
|
-
[:gem_requirement_condition, "<"],
|
16
|
-
[:whitespace, " "],
|
17
|
-
[:gem_requirement_version, "3"],
|
18
|
-
]
|
19
|
-
end
|
20
|
-
|
21
|
-
please do check_inspected "<= 3"
|
22
|
-
tokens.should == [
|
23
|
-
[:gem_requirement_condition, "<="],
|
24
|
-
[:whitespace, " "],
|
25
|
-
[:gem_requirement_version, "3"],
|
26
|
-
]
|
27
|
-
end
|
28
|
-
|
29
|
-
please do check_inspected "{1=>>= 0}"
|
30
|
-
tokens.should == [
|
31
|
-
[:open_hash, '{'],
|
32
|
-
[:number, '1'],
|
33
|
-
[:refers, '=>'],
|
34
|
-
[:gem_requirement_condition, ">="],
|
35
|
-
[:whitespace, " "],
|
36
|
-
[:gem_requirement_version, "0"],
|
37
|
-
[:close_hash, '}'],
|
38
|
-
]
|
39
|
-
end
|
40
|
-
|
41
|
-
if Gem::Specification.respond_to? :find_by_name
|
42
|
-
only19 do
|
43
|
-
please do
|
44
|
-
require 'rspec'
|
45
|
-
rspec_version = Gem::Specification.find_by_name('rspec').dependencies.first.requirement
|
46
|
-
only_version_number = rspec_version.requirements[0][1].to_s
|
47
|
-
check [rspec_version]*2
|
48
|
-
tokens.should == [
|
49
|
-
[:open_array, '['],
|
50
|
-
[:gem_requirement_condition, "~>"],
|
51
|
-
[:whitespace, " "],
|
52
|
-
[:gem_requirement_version, only_version_number],
|
53
|
-
[:comma, ","],
|
54
|
-
[:whitespace, " "],
|
55
|
-
[:gem_requirement_condition, "~>"],
|
56
|
-
[:whitespace, " "],
|
57
|
-
[:gem_requirement_version, only_version_number],
|
58
|
-
[:close_array, ']'],
|
59
|
-
]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
please do
|
64
|
-
check Gem::Specification.find_by_name('wirb').dependencies.first
|
65
|
-
tokens.should == [ # <Gem::Dependency type=:development name="rspec" requirements=">= 0">
|
66
|
-
[:open_object, "<"],
|
67
|
-
[:object_class, "Gem"],
|
68
|
-
[:class_separator, "::"],
|
69
|
-
[:object_class, "Dependency"],
|
70
|
-
[:object_description_prefix, " "],
|
71
|
-
[:object_description, "type=:runtime name="],
|
72
|
-
[:open_string, "\""],
|
73
|
-
[:string, "paint"],
|
74
|
-
[:close_string, "\""],
|
75
|
-
[:object_description, " requirements="],
|
76
|
-
[:open_string, "\""],
|
77
|
-
[:string, "~> 0.8"],
|
78
|
-
[:close_string, "\""],
|
79
|
-
[:close_object, ">"],
|
80
|
-
]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|