fancy_irb 0.7.2 → 0.7.3

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.3
2
+ * Don't colorize stdout by default
3
+ * Deactivate rocket for common system commands
4
+
1
5
  == 0.7.2
2
6
  * Fix a small bug that happens if there was no last line
3
7
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2011 Jan Lelis
1
+ Copyright (c) 2010-2012 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -2,13 +2,13 @@ FancyIrb patches your IRB to create a smooth output experience.
2
2
 
3
3
  == Features
4
4
  * Use fancy colors! You can colorize the prompts, irb errors, +stderr+ and +stdout+
5
- * Output evaluation results as Ruby comments
6
- * Enhance your output value using procs
5
+ * Output evaluation results as Ruby comments (hash rocket)
6
+ * Filter 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 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.
9
+ I really like the {irb_rocket}[https://github.com/genki/irb_rocket] gem, which outputs Ruby results using a 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
- This plugin is compatible with other great gems like {hirb}[https://github.com/cldwalker/hirb], {interactive_editor}[https://github.com/jberkel/interactive_editor], etc.
11
+ This rubygem is compatible with other great irb gems like {hirb}[https://github.com/cldwalker/hirb], {interactive_editor}[https://github.com/jberkel/interactive_editor], etc.
12
12
 
13
13
  == Usage
14
14
 
@@ -27,7 +27,7 @@ You can pass an options hash. These are the default values:
27
27
  :input_prompt => nil,
28
28
  :irb_errors => [:red],
29
29
  :stderr => [:red, :bright],
30
- :stdout => [:black, :bright],
30
+ :stdout => nil,
31
31
  :input => nil,
32
32
  :output => true, # wirb's output colorization
33
33
  },
@@ -105,12 +105,10 @@ You need ansicon[https://github.com/adoxa/ansicon] and everything will be fine :
105
105
  * Count string lengths without ansi escape sequences (would be more flexible than remembering)
106
106
  * "Always rocket"-mode
107
107
 
108
- Feel free to fix a bug or implement a todo ;)
109
-
110
108
  == Copyright / Credits
111
109
 
112
110
  Inspired by the irb_rocket gem from genki.
113
111
 
114
- Copyright (c) 2010-2011 Jan Lelis <http://rbjl.net> released under the MIT license.
112
+ Copyright (c) 2010-2012 Jan Lelis <http://rbjl.net> released under the MIT license.
115
113
 
116
114
  J-_-L
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.3
data/lib/fancy_irb.rb CHANGED
@@ -2,12 +2,12 @@ require 'stringio'
2
2
  require 'paint'
3
3
 
4
4
  module FancyIrb
5
- VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp.freeze
5
+ VERSION = File.read( File.dirname(__FILE__) + '/../VERSION' ).chomp
6
6
  end
7
7
 
8
8
  class << FancyIrb
9
9
  # setup instance variable accessors
10
- attr_reader :options
10
+ attr_accessor :options
11
11
  def [](key, key2 = nil)
12
12
  if key2
13
13
  @options[key][key2]
@@ -21,13 +21,15 @@ class << FancyIrb
21
21
  attr_accessor :real_lengths
22
22
  attr_accessor :continue
23
23
  attr_accessor :stdout_colorful
24
+ attr_accessor :skip_next_rocket
24
25
 
25
26
  def start(user_options = {})
26
27
  # track some irb stuff
27
- @height_counter = []
28
- @real_lengths = { :output => 1, :input_prompt => 9999 } # or whatever
29
- @stdout_colorful = false
30
- @continue = false
28
+ @height_counter = []
29
+ @real_lengths = { :output => 1, :input_prompt => 9999 } # or whatever
30
+ @stdout_colorful = false
31
+ @continue = false
32
+ @skip_next_rocket = false
31
33
 
32
34
  # set defaults and parse user options
33
35
  default_result_proc = proc{ |context|
@@ -57,7 +59,7 @@ class << FancyIrb
57
59
  :input_prompt => nil,
58
60
  :irb_errors => [:red],
59
61
  :stderr => [:red, :bright],
60
- :stdout => [:black, :bright],
62
+ :stdout => nil,
61
63
  :input => nil,
62
64
  :output => true, # wirb's output colorization
63
65
  },
@@ -87,8 +89,7 @@ class << FancyIrb
87
89
 
88
90
  # hook code into IRB
89
91
  require 'fancy_irb/irb_ext'
90
-
91
- "Enjoy your FancyIrb :)"
92
+ true
92
93
  end
93
94
 
94
95
  def add_output_proc(prepend = false, &proc)
@@ -45,7 +45,7 @@ module IRB
45
45
  print Paint::NOTHING
46
46
 
47
47
  # try to output in rocket mode (depending on rocket_mode setting)
48
- if FancyIrb[:rocket_mode]
48
+ if FancyIrb[:rocket_mode] && !FancyIrb.skip_next_rocket
49
49
  # get lengths
50
50
  last_input = @scanner.instance_variable_get( :@line )
51
51
  last_line_without_prompt = last_input.split("\n").last
@@ -60,8 +60,7 @@ module IRB
60
60
  stdout_lines = FancyIrb.get_height
61
61
 
62
62
  # auto rocket mode
63
- if FancyIrb[:rocket_mode] &&
64
- screen_length > offset + rocket_length + output_length &&
63
+ if screen_length > offset + rocket_length + output_length &&
65
64
  stdout_lines < screen_lines
66
65
  print TPUT[:sc] + # save current cursor position
67
66
  TPUT[:cuu1]*stdout_lines + # move cursor upwards to the original input line
@@ -73,6 +72,7 @@ module IRB
73
72
  end
74
73
  end
75
74
  # normal output mode
75
+ FancyIrb.skip_next_rocket = false
76
76
  puts no_rocket + output
77
77
  end
78
78
 
@@ -155,6 +155,13 @@ class << $stderr
155
155
  end
156
156
  end
157
157
 
158
+ # deactivate rocket for common system commands
159
+ %w[system spawn].each{ |m|
160
+ Object.send(:define_method, m.to_sym, &lambda{ |*args, &block|
161
+ FancyIrb.skip_next_rocket = true
162
+ super(*args, &block)
163
+ })
164
+ }
158
165
 
159
166
  # patch some input methods to track height
160
167
  alias gets_non_fancy gets
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paint
16
- requirement: &21083360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21083360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: unicode-display_width
27
- requirement: &21081220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: 0.1.1
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *21081220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.1
36
46
  description: ! 'FancyIrb patches your IRB to create a smooth output experience. You
37
47
  can colorize the prompts, irb errors, stderr and stdout, output your result as #=>
38
48
  (hash rockets) and some other improvements.'
@@ -76,8 +86,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
86
  requirements:
77
87
  - ! 'On Windows, you need ansicon: https://github.com/adoxa/ansicon'
78
88
  rubyforge_project:
79
- rubygems_version: 1.8.11
89
+ rubygems_version: 1.8.24
80
90
  signing_key:
81
91
  specification_version: 3
82
92
  summary: FancyIrb patches your IRB to create a smooth output experience.
83
93
  test_files: []
94
+ has_rdoc: