fancy_irb 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -29,19 +29,21 @@ You can pass an options hash. These are the default values:
29
29
  :stderr => :light_red,
30
30
  :stdout => :dark_gray,
31
31
  :input => nil,
32
- :output => true, # wirble's output colorization
32
+ :output => true, # wirb's output colorization
33
33
  },
34
34
  :result_proc => default_result_proc, # how to get the output result (see below)
35
35
  :output_procs => [default_colorizer_proc], # you can modify/enhance/log your output
36
+ :east_asian_width => false, # set to true if you have double-width characters (slower)
36
37
  }
37
38
 
38
39
  === Rocket mode
39
-
40
40
  Rocket mode means: Output result as comment if there is enough space left on the terminal line and +stdout+ does not output more than the current terminal height.
41
41
 
42
+ === Wrong display widths?
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
+
42
45
  === Available colors
43
- >> Wirble::Colorize::Color::COLORS.keys
44
- => [:light_purple, :yellow, :light_gray, :white, :black, :dark_gray, :red, :green, :light_green, :brown, :light_blue, :light_red, :cyan, :blue, :light_cyan, :purple, :nothing]
46
+ See <tt>Wirb::COLORS.keys</tt>
45
47
 
46
48
  === Modify your output
47
49
 
@@ -61,8 +63,8 @@ You can modify how to get and display the input. The <tt>result_proc</tt> is a p
61
63
 
62
64
  default_colorizer_proc = proc{ |value|
63
65
  FancyIrb.real_lengths[:output] = value.size
64
- if defined?(Wirble) && FancyIrb[:colorize, :output]
65
- Wirble::Colorize.colorize value
66
+ if defined?(Wirb) && FancyIrb[:colorize, :output]
67
+ Wirb.colorize_result value
66
68
  else
67
69
  value
68
70
  end
@@ -82,7 +84,7 @@ You can modify how to get and display the input. The <tt>result_proc</tt> is a p
82
84
  :colorize => { :output => false,
83
85
  :result_prompt => :yellow },
84
86
  :result_proc => proc{ |context|
85
- context.last_value.awesome_inspect
87
+ context.last_value.awesome_inspect
86
88
  }
87
89
 
88
90
  === Smileyfy output
@@ -99,8 +101,6 @@ You can modify how to get and display the input. The <tt>result_proc</tt> is a p
99
101
  === Features, maybe
100
102
  * Count string lengths without ansi escape sequences (would be more flexible than remembering)
101
103
  * "Always rocket"-mode
102
- * Allow custom ansi escape strings instead of wirble's colors
103
- * Refactor some code duplications
104
104
 
105
105
  Feel free to fix a bug or implement a todo ;)
106
106
 
@@ -108,6 +108,6 @@ Feel free to fix a bug or implement a todo ;)
108
108
 
109
109
  Inspired by the irb_rocket gem from genki.
110
110
 
111
- Copyright (c) 2010-2011 Jan Lelis, http://rbjl.net, released under the MIT license.
111
+ Copyright (c) 2010-2011 Jan Lelis <http://rbjl.net> released under the MIT license.
112
112
 
113
113
  J-_-L
data/Rakefile CHANGED
@@ -1,26 +1,35 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'rake/rdoctask'
4
+ require 'fileutils'
5
+
6
+ def gemspec
7
+ @gemspec ||= eval(File.read('fancy_irb.gemspec'), binding, 'fancy_irb.gemspec')
8
+ end
9
+
10
+ desc "Build the gem"
11
+ task :gem => :gemspec do
12
+ sh "gem build fancy_irb.gemspec"
13
+ FileUtils.mkdir_p 'pkg'
14
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
15
+ end
3
16
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "fancy_irb"
8
- gem.summary = %q{FancyIrb patches your IRB to create a smooth output experience.}
9
- gem.description = %q{FancyIrb patches your IRB to create a smooth output experience.
10
- * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
11
- * Output results as Ruby comment #=> (rocket)
12
- * Enhance your output value, using procs}
13
- gem.email = "mail@janlelis.de"
14
- gem.homepage = "http://github.com/janlelis/fancy_irb"
15
- gem.authors = ["Jan Lelis"]
16
- gem.add_dependency 'wirble'
17
- gem.add_dependency 'unicode-display_width'
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
17
+ desc "Install the gem locally (without docs)"
18
+ task :install => :gem do
19
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version} --no-rdoc --no-ri}
22
20
  end
23
21
 
22
+ desc "Generate the gemspec"
23
+ task :generate do
24
+ puts gemspec.to_ruby
25
+ end
26
+
27
+ desc "Validate the gemspec"
28
+ task :gemspec do
29
+ gemspec.validate
30
+ end
31
+
32
+
24
33
  require 'rake/rdoctask'
25
34
  Rake::RDocTask.new do |rdoc|
26
35
  version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.6.4
data/fancy_irb.gemspec CHANGED
@@ -1,24 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
-
2
+ require 'rubygems' unless defined? Gem
3
+
6
4
  Gem::Specification.new do |s|
7
- s.name = %q{fancy_irb}
8
- s.version = "0.6.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jan Lelis"]
12
- s.date = %q{2011-01-03}
13
- s.description = %q{FancyIrb patches your IRB to create a smooth output experience.
14
- * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
15
- * Output results as Ruby comment #=> (rocket)
16
- * Enhance your output value, using procs}
17
- s.email = %q{mail@janlelis.de}
18
- s.extra_rdoc_files = [
19
- "LICENSE",
20
- "README.rdoc"
21
- ]
5
+ s.name = "fancy_irb"
6
+ s.version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
7
+ s.authors = ["Jan Lelis"]
8
+ s.email = "mail@janlelis.de"
9
+ s.homepage = "http://github.com/janlelis/fancy_irb"
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."
12
+ s.required_rubygems_version = '>= 1.3.6'
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
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
16
+ s.license = 'MIT'
17
+ s.add_dependency('wirb', '>= 0')
18
+ s.add_dependency('unicode-display_width', ">= 0")
22
19
  s.files = [
23
20
  "LICENSE",
24
21
  "README.rdoc",
@@ -28,25 +25,5 @@ Gem::Specification.new do |s|
28
25
  "lib/fancy_irb.rb",
29
26
  "lib/fancy_irb/irb_ext.rb"
30
27
  ]
31
- s.homepage = %q{http://github.com/janlelis/fancy_irb}
32
- s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.7}
34
- s.summary = %q{FancyIrb patches your IRB to create a smooth output experience.}
35
-
36
- if s.respond_to? :specification_version then
37
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
- s.specification_version = 3
39
-
40
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- s.add_runtime_dependency(%q<wirble>, [">= 0"])
42
- s.add_runtime_dependency(%q<unicode-display_width>, [">= 0"])
43
- else
44
- s.add_dependency(%q<wirble>, [">= 0"])
45
- s.add_dependency(%q<unicode-display_width>, [">= 0"])
46
- end
47
- else
48
- s.add_dependency(%q<wirble>, [">= 0"])
49
- s.add_dependency(%q<unicode-display_width>, [">= 0"])
50
- end
51
28
  end
52
29
 
@@ -1,3 +1,11 @@
1
+ if FancyIrb[:east_asian_width]
2
+ require 'unicode/display_size'
3
+ else
4
+ class String
5
+ alias display_size size
6
+ end
7
+ end
8
+
1
9
  module IRB
2
10
  class Irb
3
11
  TPUT = {
@@ -8,8 +16,8 @@ module IRB
8
16
  }
9
17
 
10
18
  def colorize(string, color)
11
- if defined?(Wirble) && color && color_string = Wirble::Colorize::Color.escape( color.to_sym )
12
- color_string + string.to_s + Wirble::Colorize::Color.escape( :nothing )
19
+ if defined?(::Wirb) && color
20
+ ::Wirb.colorize_string string.to_s, color.to_sym
13
21
  else
14
22
  # if defined? Wirble
15
23
  # Wirble::Colorize::Color.escape( :nothing ) + string.to_s
@@ -33,7 +41,7 @@ module IRB
33
41
  }
34
42
 
35
43
  # reset color
36
- print Wirble::Colorize::Color.escape( :nothing )
44
+ print ::Wirb.get_color( :nothing )
37
45
 
38
46
  # try to output in rocket mode (depending on rocket_mode setting)
39
47
  if FancyIrb[:rocket_mode]
@@ -67,7 +75,7 @@ module IRB
67
75
  # colorize prompt & input
68
76
  alias prompt_non_fancy prompt
69
77
  def prompt(*args, &block)
70
- print Wirble::Colorize::Color.escape(:nothing)
78
+ print ::Wirb.get_color(:nothing)
71
79
  prompt = prompt_non_fancy(*args, &block)
72
80
 
73
81
  # this is kinda hacky... but that's irb °_°
@@ -78,8 +86,8 @@ module IRB
78
86
 
79
87
  colorized_prompt = colorize prompt, FancyIrb[:colorize, :input_prompt]
80
88
  if input_color = FancyIrb[:colorize, :input]
81
- colorized_prompt + Wirble::Colorize::Color.escape( input_color ) # NOTE: No reset, relies on next one
82
- # TODO buggy
89
+ colorized_prompt + ::Wirb.get_color( input_color ) # NOTE: No reset, relies on next one
90
+ # TODO buggy
83
91
  else
84
92
  colorized_prompt
85
93
  end
@@ -177,3 +185,5 @@ end
177
185
  END{
178
186
  print `tput sgr0`
179
187
  }
188
+
189
+ # J-_-L
data/lib/fancy_irb.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'stringio'
2
- require 'wirble'
3
- require 'unicode/display_width'
2
+ require 'wirb'
4
3
 
5
4
  module FancyIrb
6
5
  VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp
@@ -41,8 +40,8 @@ class << FancyIrb
41
40
 
42
41
  default_colorizer_proc = proc{ |value|
43
42
  FancyIrb.real_lengths[:output] = value.size
44
- if defined?(Wirble) && FancyIrb[:colorize, :output]
45
- Wirble::Colorize.colorize value
43
+ if defined?(Wirb) && FancyIrb[:colorize, :output]
44
+ Wirb.colorize_result value
46
45
  else
47
46
  value
48
47
  end
@@ -60,10 +59,11 @@ class << FancyIrb
60
59
  :stderr => :light_red,
61
60
  :stdout => :dark_gray,
62
61
  :input => nil,
63
- :output => true, # wirble's output colorization
62
+ :output => true, # wirb's output colorization
64
63
  },
65
64
  :result_proc => default_result_proc, # how to get the output result
66
65
  :output_procs => [default_colorizer_proc], # you can modify/enhance/log your output
66
+ :east_asian_width => false, # set to true if you have double-width characters (slower)
67
67
  }
68
68
 
69
69
  @options = default_options
@@ -118,8 +118,8 @@ class << FancyIrb
118
118
 
119
119
  def write_stream(stream, data, color = nil)
120
120
  stream.write_non_fancy(
121
- if defined?(Wirble) && FancyIrb.stdout_colorful && color
122
- Wirble::Colorize::Color.escape( color ) + data.to_s + Wirble::Colorize::Color.escape(:nothing)
121
+ if defined?(Wirb) && FancyIrb.stdout_colorful && color
122
+ Wirb.colorize_string data.to_s, color
123
123
  else
124
124
  data.to_s
125
125
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_irb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 6
9
- - 3
10
- version: 0.6.3
8
+ - 4
9
+ version: 0.6.4
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jan Lelis
@@ -15,18 +14,17 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-03 00:00:00 +01:00
17
+ date: 2011-01-27 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: wirble
21
+ name: wirb
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
@@ -40,25 +38,20 @@ dependencies:
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- hash: 3
44
41
  segments:
45
42
  - 0
46
43
  version: "0"
47
44
  type: :runtime
48
45
  version_requirements: *id002
49
- description: |-
50
- FancyIrb patches your IRB to create a smooth output experience.
51
- * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
52
- * Output results as Ruby comment #=> (rocket)
53
- * Enhance your output value, using procs
46
+ 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."
54
47
  email: mail@janlelis.de
55
48
  executables: []
56
49
 
57
50
  extensions: []
58
51
 
59
52
  extra_rdoc_files:
60
- - LICENSE
61
53
  - README.rdoc
54
+ - LICENSE
62
55
  files:
63
56
  - LICENSE
64
57
  - README.rdoc
@@ -69,8 +62,8 @@ files:
69
62
  - lib/fancy_irb/irb_ext.rb
70
63
  has_rdoc: true
71
64
  homepage: http://github.com/janlelis/fancy_irb
72
- licenses: []
73
-
65
+ licenses:
66
+ - MIT
74
67
  post_install_message:
75
68
  rdoc_options: []
76
69
 
@@ -81,19 +74,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
74
  requirements:
82
75
  - - ">="
83
76
  - !ruby/object:Gem::Version
84
- hash: 3
85
77
  segments:
86
- - 0
87
- version: "0"
78
+ - 1
79
+ - 8
80
+ - 7
81
+ version: 1.8.7
88
82
  required_rubygems_version: !ruby/object:Gem::Requirement
89
83
  none: false
90
84
  requirements:
91
85
  - - ">="
92
86
  - !ruby/object:Gem::Version
93
- hash: 3
94
87
  segments:
95
- - 0
96
- version: "0"
88
+ - 1
89
+ - 3
90
+ - 6
91
+ version: 1.3.6
97
92
  requirements: []
98
93
 
99
94
  rubyforge_project: