fancy_irb 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.7.0
2
+ * Use paint gem for terminal colors
3
+ * Fix some rocket issues (when using with colored content)
4
+
1
5
  == 0.6.5
2
6
  * Windows support
3
7
 
data/README.rdoc CHANGED
@@ -6,7 +6,7 @@ FancyIrb patches your IRB to create a smooth output experience.
6
6
  * Enhance your output value using procs
7
7
 
8
8
  == Motivation
9
- I really like the {irb_rocket}[https://github.com/genki/irb_rocket] gem, which outputs the evaluation result as comment and colorizes errors. Unfortunately, the implementation leads to bugs, because it tries to run the whole command before printing anything to +stdout+. For this reason, I've rewritten (and extended) it.
9
+ I really like the {irb_rocket}[https://github.com/genki/irb_rocket] gem, which outputs Ruby results as hash rocket and colorizes errors. Unfortunately, the implementation leads to bugs, because it tries to run the whole command before printing anything to +stdout+. For this reason, I've rewritten (and extended) it.
10
10
 
11
11
  This plugin is compatible with other great gems like {hirb}[https://github.com/cldwalker/hirb], {interactive_editor}[https://github.com/jberkel/interactive_editor], etc.
12
12
 
@@ -22,12 +22,12 @@ You can pass an options hash. These are the default values:
22
22
  :rocket_prompt => '#=> ', # prompt to use for the rocket
23
23
  :result_prompt => '=> ', # prompt to use for normal output
24
24
  :colorize => { # colors hash. Set to nil to deactivate colorizing
25
- :rocket_prompt => :blue,
26
- :result_prompt => :blue,
25
+ :rocket_prompt => [:blue],
26
+ :result_prompt => [:blue],
27
27
  :input_prompt => nil,
28
- :irb_errors => :red,
29
- :stderr => :light_red,
30
- :stdout => :dark_gray,
28
+ :irb_errors => [:red],
29
+ :stderr => [:red, :bright],
30
+ :stdout => [:black, :bright],
31
31
  :input => nil,
32
32
  :output => true, # wirb's output colorization
33
33
  },
@@ -42,11 +42,10 @@ Rocket mode means: Output result as comment if there is enough space left on the
42
42
  === Wrong display widths?
43
43
  When using double-width unicode chars, you should set <tt>:east_asian_width</tt> to <tt>true</tt>. It is deactivated because of performance issues.
44
44
 
45
- === Available colors
46
- See <tt>Wirb::COLORS.keys</tt>
47
-
48
- === Modify your output
45
+ === Customize colors
46
+ See paint[https://github.com/janlelis/paint]
49
47
 
48
+ === Modify your IRB output
50
49
  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.
51
50
 
52
51
  ===== default_result_proc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.7.0
data/fancy_irb.gemspec CHANGED
@@ -3,19 +3,18 @@ require 'rubygems' unless defined? Gem
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fancy_irb"
6
- s.version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
6
+ s.version = File.read('VERSION').chomp
7
7
  s.authors = ["Jan Lelis"]
8
8
  s.email = "mail@janlelis.de"
9
9
  s.homepage = "http://github.com/janlelis/fancy_irb"
10
10
  s.summary = "FancyIrb patches your IRB to create a smooth output experience."
11
- s.description = "FancyIrb patches your IRB to create a smooth output experience. You can colorize the prompts, irb errors, stderr and stdout. Results can be putted as #=> (rocket). Furthermore, it's possible to apply filter procs to your output value."
11
+ s.description = "FancyIrb patches your IRB to create a smooth output experience. You can colorize the prompts, irb errors, stderr and stdout, output your result as #=> (hash rockets) and some other improvements."
12
12
  s.required_rubygems_version = '>= 1.3.6'
13
13
  s.required_ruby_version = '>= 1.8.7'
14
- #s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
15
14
  s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
16
15
  s.license = 'MIT'
17
16
  s.requirements = ['On Windows, you need ansicon: https://github.com/adoxa/ansicon']
18
- s.add_dependency('wirb', '>= 0.2.4')
17
+ s.add_dependency('paint', '>= 0.8.1')
19
18
  s.add_dependency('unicode-display_width', ">= 0.1.1")
20
19
  s.files = [
21
20
  "LICENSE",
@@ -27,5 +26,14 @@ Gem::Specification.new do |s|
27
26
  "lib/fancy_irb.rb",
28
27
  "lib/fancy_irb/irb_ext.rb"
29
28
  ]
29
+
30
+ len = s.homepage.size
31
+ s.post_install_message = \
32
+ (" ┌── " + "info ".ljust(len-2,'%') + "─┐\n" +
33
+ " J-_-L │ " + s.homepage + " │\n" +
34
+ " ├── " + "usage ".ljust(len-2,'%') + "─┤\n" +
35
+ " │ " + "require 'fancy_irb'".ljust(len,' ') + " │\n" +
36
+ " │ " + "FancyIrb.start".ljust(len,' ') + " │\n" +
37
+ " └─" + '─'*len + "─┘").gsub('%', '─') # 1.8 workaround
30
38
  end
31
39
 
@@ -25,15 +25,7 @@ module IRB
25
25
  end
26
26
 
27
27
  def colorize(string, color)
28
- if defined?(::Wirb) && color
29
- ::Wirb.colorize_string string.to_s, color.to_sym
30
- else
31
- # if defined? Wirble
32
- # Wirble::Colorize::Color.escape( :nothing ) + string.to_s
33
- # else
34
- string.to_s
35
- # end
36
- end
28
+ Paint[string, *Array(color)]
37
29
  end
38
30
 
39
31
  def output_value
@@ -50,7 +42,7 @@ module IRB
50
42
  }
51
43
 
52
44
  # reset color
53
- print ::Wirb.get_color( :nothing )
45
+ print Paint::NOTHING
54
46
 
55
47
  # try to output in rocket mode (depending on rocket_mode setting)
56
48
  if FancyIrb[:rocket_mode]
@@ -84,7 +76,7 @@ module IRB
84
76
  # colorize prompt & input
85
77
  alias prompt_non_fancy prompt
86
78
  def prompt(*args, &block)
87
- print ::Wirb.get_color(:nothing)
79
+ print Paint::NOTHING
88
80
  prompt = prompt_non_fancy(*args, &block)
89
81
 
90
82
  # this is kinda hacky... but that's irb °_°
@@ -92,11 +84,10 @@ module IRB
92
84
  FancyIrb.continue = true if args[0] == IRB.conf[:PROMPT][IRB.conf[:PROMPT_MODE]][:PROMPT_C]
93
85
  indents += 2 if FancyIrb.continue
94
86
  FancyIrb.real_lengths[:input_prompt] = prompt.size + indents
95
-
87
+
96
88
  colorized_prompt = colorize prompt, FancyIrb[:colorize, :input_prompt]
97
89
  if input_color = FancyIrb[:colorize, :input]
98
- colorized_prompt + ::Wirb.get_color( input_color ) # NOTE: No reset, relies on next one
99
- # TODO buggy
90
+ colorized_prompt + Paint.color(*Array(input_color)) # NOTE: No reset, relies on next one
100
91
  else
101
92
  colorized_prompt
102
93
  end
@@ -190,6 +181,6 @@ class << $stdin
190
181
  }
191
182
  end
192
183
 
193
- END{ print "\e[0;0m" } # reset colors when exiting
184
+ END{ print "\e[0m" } # reset colors when exiting
194
185
 
195
186
  # J-_-L
data/lib/fancy_irb.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'stringio'
2
- require 'wirb'
2
+ require 'paint'
3
3
 
4
4
  module FancyIrb
5
- VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp
5
+ VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp.freeze
6
6
  end
7
7
 
8
8
  class << FancyIrb
@@ -52,13 +52,13 @@ class << FancyIrb
52
52
  :rocket_prompt => '#=> ', # prompt to use for the rocket
53
53
  :result_prompt => '=> ', # prompt to use for normal output
54
54
  :colorize => { # colors hash. Set to nil to deactivate colorizing
55
- :rocket_prompt => :blue,
56
- :result_prompt => :blue,
57
- :input_prompt => nil,
58
- :irb_errors => :red,
59
- :stderr => :light_red,
60
- :stdout => :dark_gray,
61
- :input => nil,
55
+ :rocket_prompt => [:blue],
56
+ :result_prompt => [:blue],
57
+ :input_prompt => :nothing,
58
+ :irb_errors => [:red],
59
+ :stderr => [:red, :bright],
60
+ :stdout => [:black, :bright],
61
+ :input => :nothing,
62
62
  :output => true, # wirb's output colorization
63
63
  },
64
64
  :result_proc => default_result_proc, # how to get the output result
@@ -105,8 +105,9 @@ class << FancyIrb
105
105
  end
106
106
 
107
107
  def track_height(data)
108
- lines = data.to_s.count("\n")
109
- long_lines = data.to_s.split("\n").inject(0){ |sum, line|
108
+ data = Paint.unpaint(data.to_s)
109
+ lines = data.count("\n")
110
+ long_lines = data.split("\n").inject(0){ |sum, line|
110
111
  sum + (line.display_size / current_length)
111
112
  }
112
113
  @height_counter << lines + long_lines
@@ -117,13 +118,7 @@ class << FancyIrb
117
118
  end
118
119
 
119
120
  def write_stream(stream, data, color = nil)
120
- stream.write_non_fancy(
121
- if defined?(Wirb) && FancyIrb.stdout_colorful && color
122
- Wirb.colorize_string data.to_s, color
123
- else
124
- data.to_s
125
- end
126
- )
121
+ stream.write_non_fancy( FancyIrb.stdout_colorful ? Paint[data, *Array(color)] : data.to_s )
127
122
  end
128
123
 
129
124
  def win?
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_irb
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 3
4
5
  prerelease:
5
- version: 0.6.5
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Jan Lelis
@@ -10,18 +15,22 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-02-24 00:00:00 +01:00
14
- default_executable:
18
+ date: 2011-07-07 00:00:00 Z
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
17
- name: wirb
21
+ name: paint
18
22
  prerelease: false
19
23
  requirement: &id001 !ruby/object:Gem::Requirement
20
24
  none: false
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
24
- version: 0.2.4
28
+ hash: 61
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 1
33
+ version: 0.8.1
25
34
  type: :runtime
26
35
  version_requirements: *id001
27
36
  - !ruby/object:Gem::Dependency
@@ -32,10 +41,15 @@ dependencies:
32
41
  requirements:
33
42
  - - ">="
34
43
  - !ruby/object:Gem::Version
44
+ hash: 25
45
+ segments:
46
+ - 0
47
+ - 1
48
+ - 1
35
49
  version: 0.1.1
36
50
  type: :runtime
37
51
  version_requirements: *id002
38
- description: "FancyIrb patches your IRB to create a smooth output experience. You can colorize the prompts, irb errors, stderr and stdout. Results can be putted as #=> (rocket). Furthermore, it's possible to apply filter procs to your output value."
52
+ description: "FancyIrb patches your IRB to create a smooth output experience. You can colorize the prompts, irb errors, stderr and stdout, output your result as #=> (hash rockets) and some other improvements."
39
53
  email: mail@janlelis.de
40
54
  executables: []
41
55
 
@@ -53,11 +67,23 @@ files:
53
67
  - fancy_irb.gemspec
54
68
  - lib/fancy_irb.rb
55
69
  - lib/fancy_irb/irb_ext.rb
56
- has_rdoc: true
57
70
  homepage: http://github.com/janlelis/fancy_irb
58
71
  licenses:
59
72
  - MIT
60
- post_install_message:
73
+ post_install_message: !binary |
74
+ ICAgICAgIOKUjOKUgOKUgCBpbmZvIOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKU
75
+ gOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKU
76
+ gOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUkAogSi1fLUwg4pSCIGh0dHA6Ly9n
77
+ aXRodWIuY29tL2phbmxlbGlzL2ZhbmN5X2lyYiDilIIKICAgICAgIOKUnOKU
78
+ gOKUgCB1c2FnZSDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDi
79
+ lIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDi
80
+ lIDilIDilIDilKQKICAgICAgIOKUgiByZXF1aXJlICdmYW5jeV9pcmInICAg
81
+ ICAgICAgICAgICAgICAg4pSCCiAgICAgICDilIIgRmFuY3lJcmIuc3RhcnQg
82
+ ICAgICAgICAgICAgICAgICAgICAgIOKUggogICAgICAg4pSU4pSA4pSA4pSA
83
+ 4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA
84
+ 4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA
85
+ 4pSA4pSA4pSA4pSA4pSA4pSY
86
+
61
87
  rdoc_options: []
62
88
 
63
89
  require_paths:
@@ -67,17 +93,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
93
  requirements:
68
94
  - - ">="
69
95
  - !ruby/object:Gem::Version
96
+ hash: 57
97
+ segments:
98
+ - 1
99
+ - 8
100
+ - 7
70
101
  version: 1.8.7
71
102
  required_rubygems_version: !ruby/object:Gem::Requirement
72
103
  none: false
73
104
  requirements:
74
105
  - - ">="
75
106
  - !ruby/object:Gem::Version
107
+ hash: 23
108
+ segments:
109
+ - 1
110
+ - 3
111
+ - 6
76
112
  version: 1.3.6
77
113
  requirements:
78
114
  - "On Windows, you need ansicon: https://github.com/adoxa/ansicon"
79
115
  rubyforge_project:
80
- rubygems_version: 1.5.2
116
+ rubygems_version: 1.8.5
81
117
  signing_key:
82
118
  specification_version: 3
83
119
  summary: FancyIrb patches your IRB to create a smooth output experience.