wirb 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest DELETED
File without changes
data/README.rdoc DELETED
@@ -1,79 +0,0 @@
1
- == Wirb Interactive Ruby {<img src="https://travis-ci.org/janlelis/wirb.png" />}[https://travis-ci.org/janlelis/wirb]
2
-
3
- *Wirb* colorizes your inspected Ruby objects. It is based on Wirble[http://pablotron.org/software/wirble/], but only provides and improves result highlighting. It also provides a colorization engine abstraction layer and offers flexible schemas using yaml. Wirb is part of the {irbtools suite}[https://github.com/janlelis/irbtools].
4
-
5
- Supported Rubies: 2.1, 2.0, 1.9, 1.8, jruby, rubinius
6
-
7
- == Install
8
-
9
- Install the gem with:
10
-
11
- gem install wirb
12
-
13
- == Usage
14
-
15
- Add to your <tt>~/.irbrc</tt>
16
-
17
- require 'wirb'
18
- Wirb.start
19
-
20
- == Features
21
-
22
- * Syntax highlighting for Ruby objects
23
- * Does not change the inspect method
24
- * Support for generic objects, especially sets and enumerators and nesting more generic objects
25
- * Funny looking test suite
26
- * Can be used without irb
27
- * Limited stdlib/gem objects support (e.g. Set, Gem::Requirement)
28
- * Usable with any supported terminal colors engine
29
- * Color schemas in yaml files
30
-
31
- == wp
32
- You can colorize any object with <tt>wp</tt> (wavy_print):
33
- require 'wirb/wp'
34
- wp some_object
35
-
36
- == Colors
37
-
38
- To only tweak some colors, take a look at the <tt>Wirb.schema</tt> hash. To use a custom schema, inspect the yaml files in the <tt>data/wirb/</tt> directory. You can create your own schema and load it using <tt>Wirb.load_schema(path_to_yaml_file)</tt>. Alternatively, you can use one of the bundled ones by passing a symbol instead of a path.
39
-
40
- === Colorizer
41
-
42
- Wirb supports multiple colorization engines. Available engines can be found in <tt>lib/wirb/colorizer/*</tt>. Some of them require external gems as dependencies (e.g. HighLine). The current default engine is <em>Paint</em>. You can change the colorizer using:
43
-
44
- Wirb.load_colorizer :Paint # or :HighLine or whatever
45
-
46
- Be careful, though! You also need to select a color schema that supports your colorizer (Schemas define supported colorizers using the <tt>:colorizer</tt> key). Load a schema with:
47
-
48
- Wirb.load_schema! :classic_paint # make sure your colorizer is paint
49
-
50
- You can automatically use the first colorizer of the schema by using the non-exclamation mark version:
51
-
52
- Wirb.load_schema :classic_paint # will fail if paint is not installed
53
-
54
- Color schemas wanted! You've got a good looking alternative color schema? Please fork and add it to <tt>data/wirb/*</tt> :)
55
-
56
- Colorizers wanted! Your favorite terminal colors gem is not supported yet? Please fork and add it to <tt>lib/wirb/colorizer/*</tt> :D
57
-
58
- === Bundled schemas
59
-
60
- The following schemas are bundled (load with <tt>Wirb.load_schema :name</tt> and make sure the used colorizer is available).
61
-
62
- * <tt>:classic_paint</tt> (paint implementation of default)
63
- * <tt>:colorless</tt> (only uses :bright, :underline and :inverse effect)
64
- * <tt>:classic_wirb0</tt> (default implemented with wirb0)
65
-
66
- == Also see
67
-
68
- * Configure views for specific objects: hirb[https://github.com/cldwalker/hirb]
69
- * Wirb is part of: irbtools[https://github.com/janlelis/irbtools]
70
- * ripl is an irb alternative, syntax highlighting plugin (uses wirb by default): ripl-color_result[https://github.com/janlelis/ripl-color_result]
71
- * Advanced terminal color gems: Paint[https://github.com/janlelis/paint], HighLine[https://github.com/JEG2/highline]
72
-
73
- == Credits
74
-
75
- Copyright (c) 2011-2014 Jan Lelis <http://janlelis.de>, see COPYING for details.
76
-
77
- Influenced by code from and thanks to: Copyright (C) 2006-2009 Paul Duncan <pabs@pablotron.org>
78
-
79
- Contributions[https://github.com/janlelis/wirb/contributors] by and thanks to: {Richard LeBer}[https://github.com/rleber]
@@ -1,72 +0,0 @@
1
- colorizer:
2
- - Wirb0
3
- - Wirb0_Paint
4
- - Wirb0_HighLine
5
-
6
- # container
7
- open_hash: light_green
8
- close_hash: light_green
9
- open_array: light_green
10
- close_array: light_green
11
- open_set: green
12
- close_set: green
13
-
14
- # delimiter
15
- comma: green
16
- refers: green
17
-
18
- # class
19
- class: light_green
20
- class_separator: green
21
- object_class: light_green
22
-
23
- # object
24
- open_object: green
25
- object_description_prefix: green
26
- object_description: brown
27
- object_address_prefix: brown_underline
28
- object_address: brown_underline
29
- object_line_prefix: brown_underline
30
- object_line: brown_underline
31
- object_line_number: brown_underline
32
- object_variable_prefix: light_purple
33
- object_variable: light_purple
34
- close_object: green
35
-
36
- # symbol
37
- symbol_prefix: yellow
38
- symbol: yellow
39
- open_symbol_string: brown
40
- symbol_string: yellow
41
- close_symbol_string: brown
42
-
43
- # string
44
- open_string: light_gray
45
- string: purple
46
- close_string: light_gray
47
-
48
- # regexp
49
- open_regexp: light_blue
50
- regexp: purple
51
- close_regexp: light_blue
52
- regexp_flags: light_red
53
-
54
- # number
55
- number: cyan
56
- special_number: cyan
57
- range: red
58
- open_rational: light_cyan
59
- rational_separator: light_cyan
60
- close_rational: light_cyan
61
- open_complex: cyan
62
- close_complex: cyan
63
-
64
- # misc
65
- #default:
66
- #keyword:
67
- time: purple
68
- nil: light_red
69
- false: red
70
- true: green
71
- gem_requirement_condition: cyan
72
- gem_requirement_version: light_cyan
@@ -1,26 +0,0 @@
1
- # Jan:
2
- # General philosophical question: Would it be more flexible to have @colorizer point
3
- # to an _instance_ of a Colorizer object, rather than a Colorizer class? (And therefore
4
- # to have run and color be instance methods of Colorizer, rather than class methods.)
5
- # In certain circumstances this could give greater flexibility, for instance to set
6
- # colorizer options...
7
-
8
- module Wirb
9
- module Colorizer
10
- class << self
11
- def const_missing(colorizer)
12
- path = File.dirname(__FILE__) + '/colorizer/' + colorizer.to_s.downcase
13
-
14
- begin
15
- require path
16
- rescue LoadError => e
17
- raise LoadError, "Could not load colorizer #{colorizer} at #{path}: #{e}"
18
- end
19
-
20
- raise LoadError, "Colorizer definition at #{path} does not appear to define #{self}::#{colorizer}" \
21
- unless const_defined?(colorizer)
22
- const_get colorizer
23
- end
24
- end
25
- end
26
- end
@@ -1,16 +0,0 @@
1
- require 'highline'
2
-
3
- module Wirb::Colorizer::HighLine
4
- @highline = ::HighLine.new
5
-
6
- class << self
7
-
8
- def run(string, *color_args)
9
- @highline.color(string, *color_args.flatten)
10
- end
11
-
12
- def color(*color_args)
13
- @highline.color_code(*color_args.flatten)
14
- end
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- require 'paint'
2
-
3
- module Wirb::Colorizer::Paint
4
- def self.run(string, *color_args)
5
- ::Paint[string, *color_args]
6
- end
7
-
8
- def self.color(*color_args)
9
- ::Paint.color(*color_args)
10
- end
11
- end
@@ -1,53 +0,0 @@
1
- module Wirb::Colorizer::Wirb0
2
- COLORS = {
3
- :nothing => '0;0',
4
-
5
- # light
6
- :black => '0;30',
7
- :red => '0;31',
8
- :green => '0;32',
9
- :brown => '0;33',
10
- :blue => '0;34',
11
- :purple => '0;35',
12
- :cyan => '0;36',
13
- :light_gray => '0;37',
14
-
15
- # bold
16
- :dark_gray => '1;30',
17
- :light_red => '1;31',
18
- :light_green => '1;32',
19
- :yellow => '1;33',
20
- :light_blue => '1;34',
21
- :light_purple => '1;35',
22
- :light_cyan => '1;36',
23
- :white => '1;37',
24
-
25
- # underline
26
- :black_underline => '4;30',
27
- :red_underline => '4;31',
28
- :green_underline => '4;32',
29
- :brown_underline => '4;33',
30
- :blue_underline => '4;34',
31
- :purple_underline => '4;35',
32
- :cyan_underline => '4;36',
33
- :white_underline => '4;37',
34
-
35
- # background
36
- :black_background => '7;30',
37
- :red_background => '7;31',
38
- :green_background => '7;32',
39
- :brown_background => '7;33',
40
- :blue_background => '7;34',
41
- :purple_background => '7;35',
42
- :cyan_background => '7;36',
43
- :white_background => '7;37',
44
- }
45
-
46
- def self.run(string, *color_args)
47
- color(*color_args) + string.to_s + color(:nothing)
48
- end
49
-
50
- def self.color(*color_args)
51
- color_args.first && COLORS[color_args.first.to_sym] ? "\e[#{COLORS[color_args.first.to_sym]}m" : ''
52
- end
53
- end
@@ -1,73 +0,0 @@
1
- # Colorizer for using HighLine colors with Wirb
2
- #
3
- # Automatically translates Wirb color to Highline colors:
4
- # HighLineConnector.color(s, :brown_underline) #=> calls HighLine.color(s, :yellow, :underline)
5
- #
6
- # You can mix and match using HighLine color names and Wirb color names. Prefix HighLine color names
7
- # with :highline. For instance:
8
- #
9
- # Wirb.colorizer.run(s, :highline, :yellow) #=> calls HighLine.color(s, :yellow)
10
- # Wirb.colorizer.run(s, :yellow) #=> calls HighLine.color(s, :bold, :yellow) because
11
- # # Wirb uses :yellow to mean bold yellow
12
-
13
- require 'highline'
14
-
15
- module Wirb::Colorizer::Wirb0_HighLine
16
- def self.color(*colors)
17
- ::HighLine.color_code(*color_name(*colors))
18
- end
19
-
20
- def self.run(s, *colors)
21
- ::HighLine.color(s, *color_name(*colors))
22
- end
23
-
24
-
25
- def self.color_name(*colors)
26
- colors = colors.flatten.compact
27
- if colors.first == :highline # In this case, colors already use HighLine's names
28
- colors[1..-1]
29
- else
30
- translated_colors = colors.map do |color|
31
- color = color.to_s
32
- case color
33
- when "nothing"
34
- color = "clear"
35
- when /light_gray/
36
- color = color.sub("light_gray", "white")
37
- when /dark_gray/
38
- color = color.sub("dark_gray", "light_black") # Changed to [:bold, :black] below
39
- when /yellow/
40
- color = color.sub("yellow", "light_yellow") # Changed to [:bold, :yellow] below
41
- when /white/
42
- color = color.sub("white", "light_white") # Changed to [:bold, :white] below
43
- when /brown/
44
- color = color.sub("brown", "yellow")
45
- when /purple/
46
- color = color.sub("purple", "magenta")
47
- end
48
- color_set = [color.to_sym]
49
- if color_set.first.to_s =~ /^light_(.*)/
50
- color_set[0] = $1.to_sym
51
- color_set << :bold
52
- end
53
- case color_set.first.to_s
54
- when /(.*)_underline$/
55
- color_set[0] = [$1.to_sym]
56
- color_set << :underline
57
- when /(.*)_background$/
58
- color_set[0] = [('on_'+$1).to_sym]
59
- end
60
- color_set
61
- end
62
- translated_colors.flatten
63
- end
64
- end
65
-
66
- def color_code(*args)
67
- self.class.color_code(*args)
68
- end
69
-
70
- def color(*args)
71
- self.class.color(*args)
72
- end
73
- end
@@ -1,71 +0,0 @@
1
- require 'paint'
2
-
3
- Paint::SHORTCUTS[:wirb] = {
4
- :nothing => Paint::NOTHING,
5
-
6
- # light
7
- :black => Paint.color(:black),
8
- :red => Paint.color(:red),
9
- :green => Paint.color(:green),
10
- :brown => Paint.color(:yellow),
11
- :blue => Paint.color(:blue),
12
- :purple => Paint.color(:magenta),
13
- :cyan => Paint.color(:cyan),
14
- :light_gray => Paint.color(:white),
15
-
16
- # bold
17
- :dark_gray => Paint.color(:black, :bold),
18
- :light_red => Paint.color(:red, :bold),
19
- :light_green => Paint.color(:green, :bold),
20
- :yellow => Paint.color(:yellow, :bold),
21
- :light_blue => Paint.color(:blue, :bold),
22
- :light_purple => Paint.color(:magenta, :bold),
23
- :light_cyan => Paint.color(:cyan, :bold),
24
- :white => Paint.color(:white, :bold),
25
-
26
- # underline
27
- :black_underline => Paint.color(:black, :underline),
28
- :red_underline => Paint.color(:red, :underline),
29
- :green_underline => Paint.color(:green, :underline),
30
- :brown_underline => Paint.color(:yellow, :underline),
31
- :blue_underline => Paint.color(:blue, :underline),
32
- :purple_underline => Paint.color(:magenta, :underline),
33
- :cyan_underline => Paint.color(:cyan, :underline),
34
- :white_underline => Paint.color(:white, :underline),
35
-
36
- # background
37
- :black_background => Paint.color(nil, :black), # first color passed is foreground, second one is background
38
- :red_background => Paint.color(nil, :red),
39
- :green_background => Paint.color(nil, :green),
40
- :brown_background => Paint.color(nil, :yellow),
41
- :blue_background => Paint.color(nil, :blue),
42
- :purple_background => Paint.color(nil, :magenta),
43
- :cyan_background => Paint.color(nil, :cyan),
44
- :white_background => Paint.color(nil, :white),
45
- }
46
-
47
- module Wirb::Colorizer::Wirb0_Paint
48
- def self.run(string, *color_args)
49
- if color_args.first && color_args.size == 1 && color_args.first.is_a?(Symbol)
50
- if color_args.first == :paint # force usage of paint colors
51
- Paint[string, *color_args[1..-1]]
52
- else
53
- Paint::Wirb.send(color_args.first, string)
54
- end
55
- else
56
- Paint[string, *color_args]
57
- end
58
- end
59
-
60
- def self.color(*color_args)
61
- if color_args.first && color_args.size == 1 && color_args.first.is_a?(Symbol)
62
- if color_args.first == :paint # force usage of paint colors
63
- Paint[string, *color_args[1..-1]]
64
- else
65
- Paint::Wirb.send(color_args.first)
66
- end
67
- else
68
- Paint.color(*color_args)
69
- end
70
- end
71
- end
@@ -1,30 +0,0 @@
1
- module Wirb::Colorizer::Wirble
2
- COLORS = {
3
- :nothing => '0;0',
4
- :black => '0;30',
5
- :red => '0;31',
6
- :green => '0;32',
7
- :brown => '0;33',
8
- :blue => '0;34',
9
- :cyan => '0;36',
10
- :purple => '0;35',
11
- :light_gray => '0;37',
12
- :dark_gray => '1;30',
13
- :light_red => '1;31',
14
- :light_green => '1;32',
15
- :yellow => '1;33',
16
- :light_blue => '1;34',
17
- :light_cyan => '1;36',
18
- :light_purple => '1;35',
19
- :white => '1;37',
20
- }
21
-
22
-
23
- def self.run(string, *color_args)
24
- color(*color_args) + string.to_s + color(:nothing)
25
- end
26
-
27
- def self.color(*color_args)
28
- color_args.first && COLORS[color_args.first.to_sym] ? "\e[#{COLORS[color_args.first.to_sym]}m" : ''
29
- end
30
- end