irt 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -506,7 +506,7 @@ which should work quite well without any change:
506
506
  # IRT.vi_command_format ="vi -c 'startinsert' %1$s +%2$d"
507
507
 
508
508
  # the format to build the command to launch the ri tool
509
- # IRT.ri_command_format = "qri -f #{Colorer.color? ? 'ansi' : 'plain'} %s"
509
+ # IRT.ri_command_format = "qri -f #{Dye.color? ? 'ansi' : 'plain'} %s"
510
510
 
511
511
  # add your command format if you want to use another editor than nano or vi
512
512
  # default 'open -t %1$s' on MacOX; 'kde-open %1$s' or 'gnome-open %1$s' un unix/linux; '%1$s' on windoze
@@ -527,25 +527,23 @@ The default color styles of IRT should be OK in most situation, anyway, if you r
527
527
  you can switch off the color completely (IRT.force_color = false) or you can also
528
528
  redefine the colors by redefining them in your .irtrc file.
529
529
 
530
- The following are the default Colorer styles, change them at will:
531
-
532
- Colorer.def_custom_styles({ :bold => :bold,
533
- :reversed => :reversed,
534
- :null => :clear,
535
-
536
- :log_color => :blue,
537
- :file_color => :cyan,
538
- :interactive_color => :magenta,
539
- :inspect_color => :clear,
540
- :binding_color => :yellow,
541
- :actual_color => :green,
542
- :ignored_color => :yellow,
543
-
544
- :error_color => :red,
545
- :ok_color => :green,
546
- :diff_color => :yellow,
547
- :diff_a_color => :cyan,
548
- :diff_b_color => :green } , true)
530
+ The following are the default Dye (gem) styles, change them at will:
531
+
532
+ IRT.dye_styles = { :null => :clear,
533
+
534
+ :log_color => :blue,
535
+ :file_color => :cyan,
536
+ :interactive_color => :magenta,
537
+ :inspect_color => :clear,
538
+ :binding_color => :yellow,
539
+ :actual_color => :green,
540
+ :ignored_color => :yellow,
541
+
542
+ :error_color => :red,
543
+ :ok_color => :green,
544
+ :diff_color => :yellow,
545
+ :diff_a_color => :cyan,
546
+ :diff_b_color => :green }
549
547
 
550
548
  ### Note about IRT.autoload_helper_files
551
549
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ task :install, :force do |t, args|
20
20
  File.open('VERSION', 'w') {|f| f.puts version }
21
21
  gem_name = "#{name}-#{version}.gem"
22
22
  sh %(gem build #{name}.gemspec)
23
- sh %(gem install #{gem_name} --local)
23
+ sh %(gem install #{gem_name} --local --no-rdoc --no-ri)
24
24
  puts <<-EOS.gsub(/^ {6}/, '')
25
25
 
26
26
  *******************************************************************************
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
data/bin/irt CHANGED
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'irt'
5
4
  require 'fileutils'
6
5
  require 'tempfile'
7
6
  require 'optparse'
7
+ require 'prompter'
8
+ require 'dye'
8
9
 
9
10
 
10
- copy = "irt #{IRT::VERSION} (c) 2010-2011 Domizio Demichelis".log_color.bold
11
+ version = File.read(File.expand_path('../../VERSION', __FILE__)).strip
12
+
13
+ copy = Dye.dye "irt #{version} (c) 2010-2011 Domizio Demichelis", :blue, :bold
11
14
 
12
15
  options = {}
13
16
 
@@ -37,7 +40,7 @@ EOB
37
40
  end
38
41
 
39
42
  opts.on( '-v', '--version', 'Shows the version and exits' ) do
40
- puts IRT::VERSION
43
+ puts version
41
44
  exit
42
45
  end
43
46
 
@@ -62,7 +65,7 @@ paths = if ARGV.empty?
62
65
 
63
66
  files = paths.map do |path|
64
67
  unless File.exists?(path)
65
- next if IRT.prompter.no? %(Do you want to create the file "#{path}"?), :hint => '[<enter=y|n]', :default => 'y'
68
+ next if Prompter.no? %(Do you want to create the file "#{path}"?), :hint => '[<enter=y|n]', :default => 'y'
66
69
  options[:interactive_eof] = true
67
70
  dirname = File.dirname(path)
68
71
  FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
@@ -72,7 +75,7 @@ files = paths.map do |path|
72
75
  end.flatten
73
76
 
74
77
  if files.empty?
75
- puts 'No *.irt files to run'
78
+ Prompter.say_notice 'No *.irt files to run'
76
79
  exit
77
80
  end
78
81
 
@@ -95,7 +98,7 @@ ENV['IRT_INTERACTIVE_EOF'] = options[:interactive_eof].inspect if options[:inter
95
98
  files.each do |file|
96
99
  ENV['IRT_COMMAND'] = sprintf cmd_format, file, options[:irb_options], options[:rails_env]
97
100
  unless system(ENV['IRT_COMMAND'])
98
- puts "\e[0m" if Colorer.color
101
+ puts "\e[0m" if Dye.color?
99
102
  exit(1)
100
103
  end
101
104
  end
data/irt.gemspec CHANGED
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.description = 'If you use IRT in place of irb or rails console, you will have more tools that will make your life a lot easier.'
12
12
 
13
13
  s.add_runtime_dependency('differ', [">= 0.1.1"])
14
- s.add_runtime_dependency('colorer', [">= 0.7.0"])
15
- s.add_runtime_dependency('prompter', [">= 0.1.1"])
14
+ s.add_runtime_dependency('dye', [">= 0.1.1"])
15
+ s.add_runtime_dependency('prompter', [">= 0.1.2"])
16
16
  s.add_runtime_dependency('fastri', [">= 0.3.1.1"])
17
17
 
18
18
  s.executables = ['irt', 'irt_irb', 'irt_rails2']
data/irtrc CHANGED
@@ -30,7 +30,7 @@
30
30
  # IRT.vi_command_format ="vi -c 'startinsert' %1$s +%2$d"
31
31
 
32
32
  # the format to build the command to launch the ri tool
33
- # IRT.ri_command_format = "qri -f #{Colorer.color? ? 'ansi' : 'plain'} %s"
33
+ # IRT.ri_command_format = "qri -f #{Dye.color? ? 'ansi' : 'plain'} %s"
34
34
 
35
35
  # add your command format if you want to use another editor than nano or vi
36
36
  # default 'open -t %1$s' on MacOX; 'kde-open %1$s' or 'gnome-open %1$s' un unix/linux; '%1$s' on windoze
@@ -41,7 +41,7 @@ module IRT
41
41
  IRB.irb_at_exit
42
42
  str = "Rerunning: `#{ENV['IRT_COMMAND']}`"
43
43
  puts
44
- puts " #{str} ".error_color.bold.reversed.or("*** #{str} ***")
44
+ puts IRT.dye(" #{str} ", "*** #{str} ***", :error_color, :bold, :reversed)
45
45
  puts
46
46
  exec ENV["IRT_COMMAND"]
47
47
  end
@@ -5,25 +5,25 @@ module IRT
5
5
  def irt_help
6
6
  ensure_session
7
7
  puts %(
8
- #{" NOTICE ".log_color.reversed.bold}
9
- - The #{"Commands".interactive_color.bold} are methods generally available in any IRT session
10
- - The #{"Directives".file_color.bold} are methods available in any file but not in IRT sessions
11
- - The #{"Extensions".log_color.bold} are methods available anywhere
8
+ #{label " NOTICE ", :log_color}
9
+ - The #{IRT.dye "Commands", :interactive_color, :bold} are methods generally available in any IRT session
10
+ - The #{IRT.dye "Directives", :file_color, :bold} are methods available in any file but not in IRT sessions
11
+ - The #{IRT.dye "Extensions", :log_color, :bold} are methods available anywhere
12
12
 
13
- #{" Inspecting Commands ".interactive_color.reversed.bold}
13
+ #{label " Inspecting Commands ", :interactive_color}
14
14
  irt object Opens an inspecting session into object
15
15
  vdiff|vd obj_a, obj_b Prints the visual diff of the yaml dump of 2 objects
16
16
  cat args Similar to system cat
17
17
  ls args Similar to system ls
18
18
 
19
- #{" Log Commands ".interactive_color.reversed.bold}
19
+ #{label " Log Commands ", :interactive_color}
20
20
  log|l [limit] Prints limit or 'tail_size' lines of the virtual log
21
21
  full_log|ll Prints all the lines in the virtual log
22
22
  print_lines|pl Prints the last lines of the current session
23
23
  without numbers (for easy copying)
24
24
  print_all_lines|pll Like print_line but prints all the sessions lines
25
25
 
26
- #{" In Place Editing Commands ".interactive_color.reversed.bold}
26
+ #{label " In Place Editing Commands ", :interactive_color}
27
27
  (<editor> can be 'vi', 'nano|nn', 'edit|ed')
28
28
  <editor> Uses <editor> to open the current evalued file at
29
29
  the current evalued line for in place edit
@@ -37,14 +37,14 @@ module IRT
37
37
  <editor> n Uses <editor> to open the backtraced file [n] at
38
38
  the backtraced line
39
39
 
40
- #{" Copy-Edit Commands ".interactive_color.reversed.bold + " (use copy_to_clipboard_command)".interactive_color.bold}
40
+ #{label( " Copy-Edit Commands ", :interactive_color ) + IRT.dye(" (use copy_to_clipboard_command)", :interactive_color, :bold)}
41
41
  copy_lines|cl Copy the last session lines
42
42
  copy_all_lines|cll Copy the lines of all the sessions
43
43
  cnano|cnn Like nano, but copy the last session lines first
44
44
  cvi Like vi, but copy the last session lines first
45
45
  cedit|ced Like edit, but copy the last session lines first
46
46
 
47
- #{" Test Commands ".interactive_color.reversed.bold + " (only available in interactive sessions)".interactive_color.bold}
47
+ #{label(" Test Commands ", :interactive_color) + IRT.dye(" (only available in interactive sessions)", :interactive_color, :bold)}
48
48
  add_desc|dd desc Adds a description for the test in the log
49
49
  add_test|tt Adds a test in the log, checking the last value (_)
50
50
  by automatically choosing the :_eql?, or :_yaml_eql?
@@ -52,15 +52,15 @@ module IRT
52
52
  add_test|tt desc Like add_test but adds a 'desc' directive first'
53
53
  save_as|sa path Saves the current irt file as path and runs it
54
54
 
55
- #{" FileUtils Commands ".interactive_color.reversed.bold}
55
+ #{label " FileUtils Commands ", :interactive_color}
56
56
  All the FileUtils methods are availabe as IRT Commands
57
57
  (e.g. pwd, touch, mkdir, mv, cp, rm, rm_rf, compare_files, ...)
58
58
 
59
- #{" Enhanced Commands ".interactive_color.reversed.bold}
59
+ #{label " Enhanced Commands ", :interactive_color}
60
60
  p, pp, ap, y When invoked with no arguments print the last_value
61
61
  (e.g. just type 'y' instead 'y _')
62
62
 
63
- #{" Documentation Commands ".interactive_color.reversed.bold}
63
+ #{label " Documentation Commands ", :interactive_color}
64
64
  ri to_search Search the ri doc for to_search (no quotes needed)
65
65
  ri obj.any_method Search the method.owner ri doc for of any_method
66
66
  (no quotes needed, and completion available)
@@ -69,30 +69,30 @@ module IRT
69
69
  ri n Search the ri doc for the method n in a multiple
70
70
  choices list
71
71
 
72
- #{" Misc Commands ".interactive_color.reversed.bold}
72
+ #{label " Misc Commands ", :interactive_color}
73
73
  x|q Aliases for exit (from the current session)
74
74
  xx|qq Aliases for abort (abort the irt process)
75
75
  status|ss Prints the session status line
76
76
  rerun|rr Reruns the same file
77
77
  irt_help|hh Shows this screen
78
78
 
79
- #{" Session Directives ".file_color.reversed.bold}
79
+ #{label " Session Directives ", :file_color}
80
80
  irt Opens an interactive session which retains the
81
81
  current variables and the last value (_)
82
82
  irt binding Opens a binding session at the line of the call
83
83
 
84
- #{" Test Directives ".file_color.reversed.bold + " (auto added by the Test Commands)".file_color.bold}
84
+ #{label(" Test Directives ", :file_color) + IRT.dye(" (auto added by the Test Commands)", :file_color, :bold)}
85
85
  desc description Adds a description to the next test
86
86
  _eql? val Runs a test checking _ == val
87
87
  _yaml_eql? yaml_dump Runs a test checking y _ == yaml_dump
88
88
 
89
- #{" Helper Directives ".file_color.reversed.bold}
89
+ #{label " Helper Directives ", :file_color}
90
90
  insert_file file Evaluates file as it were inserted at that line
91
91
  eval_file Alias for eval_file
92
92
  irt_at_exit block Ensures execution of block at exit (useful for
93
93
  cleanup of test env)
94
94
 
95
- #{" Extensions ".log_color.reversed.bold}
95
+ #{label " Extensions ", :log_color}
96
96
  Kernel#capture block Executes block and returns a string containing the
97
97
  captured stdout
98
98
  Object#own_methods Returns the methods implemented by the receiver
@@ -106,6 +106,11 @@ module IRT
106
106
  end
107
107
  alias_method :hh, :irt_help
108
108
 
109
+ private
110
+ def label(string, color)
111
+ IRT.dye string, color, :reversed, :bold
112
+ end
113
+
109
114
  end
110
115
  end
111
116
  end
@@ -10,7 +10,7 @@ module IRT
10
10
  desc_str = %(desc "#{description}")
11
11
  context.current_line = desc_str
12
12
  puts
13
- puts desc_str.interactive_color
13
+ puts IRT.dye(desc_str, :interactive_color)
14
14
  puts
15
15
  end
16
16
  alias_method :dd, :add_desc
@@ -39,7 +39,7 @@ module IRT
39
39
  str = desc_str + test_str
40
40
  context.current_line = str
41
41
  puts
42
- puts str.interactive_color
42
+ puts IRT.dye(str, :interactive_color)
43
43
  puts
44
44
  end
45
45
  alias_method :tt, :add_test
data/lib/irt/differ.rb CHANGED
@@ -19,11 +19,11 @@ module IRT
19
19
 
20
20
  def output
21
21
  out = "\n"
22
- out << " = same ".reversed.bold.or('***** diff ')
23
- out << " #{@options[:a_marker]} #{@options[:a_label]} ".diff_a_color.reversed.bold.
24
- or(" (#{@options[:a_marker]} #{@options[:a_label]}) ")
25
- out << " #{@options[:b_marker]} #{@options[:b_label]} ".diff_b_color.reversed.bold.
26
- or(" (#{@options[:b_marker]} #{@options[:b_label]}) ")
22
+ out << IRT.dye(' = same ', :reversed, :bold)
23
+ a = "#{@options[:a_marker]} #{@options[:a_label]}"
24
+ out << IRT.dye(" #{a} ", " (#{a}) ", :diff_a_color, :reversed, :bold)
25
+ b = "#{@options[:b_marker]} #{@options[:b_label]}"
26
+ out << IRT.dye(" #{b} ", " (#{b}) ", :diff_b_color, :reversed, :bold)
27
27
  out << "\n"
28
28
  diff = @diff.format_as(IRT::Differ::Format)
29
29
  out << diff.sub(/^\n/,'')
@@ -48,7 +48,7 @@ module IRT
48
48
 
49
49
  def process(string, mark='=', color=:null, bold=:null)
50
50
  string.sub(/^\n/,'').split("\n").map do |s|
51
- " #{mark} ".send(color).send(bold).reversed.or(" #{mark} ") + ' ' + s.send(color)
51
+ IRT.dye(" #{mark} ", " #{mark} |", color, :bold, :reversed) + ' ' + IRT.dye(s, color)
52
52
  end.join("\n") + "\n"
53
53
  end
54
54
 
@@ -31,12 +31,12 @@ module IRT
31
31
  return unless @@tests > 0
32
32
  if @@tests == @@oks
33
33
  str = @@tests == 1 ? " The TEST is OK! " : " All #{@@tests} TESTs are OK! "
34
- puts str.ok_color.bold
34
+ puts IRT.dye(str, :ok_color, :bold)
35
35
  else
36
- puts "#{@@tests} TEST#{'s' unless @@tests == 1}: ".bold +
37
- "#{@@oks} OK#{'s' unless @@oks == 1}, ".ok_color.bold +
38
- "#{@@diffs} DIFF#{'s' unless @@diffs == 1}, ".diff_color.bold +
39
- "#{@@errors} ERROR#{'s' unless @@errors == 1}.".error_color.bold
36
+ puts IRT.dye("#{@@tests} TEST#{'s' unless @@tests == 1}: ", :bold) +
37
+ IRT.dye("#{@@oks} OK#{'s' unless @@oks == 1}, ", :ok_color, :bold) +
38
+ IRT.dye("#{@@diffs} DIFF#{'s' unless @@diffs == 1}, ", :diff_color, :bold) +
39
+ IRT.dye("#{@@errors} ERROR#{'s' unless @@errors == 1}.", :error_color, :bold)
40
40
  end
41
41
  end
42
42
 
@@ -64,17 +64,17 @@ module IRT
64
64
  begin
65
65
  if saved == actual
66
66
  @@oks += 1
67
- puts "#{tno}. OK!".ok_color.bold + " #{d}".ok_color
67
+ puts IRT.dye("#{tno}. OK!", :ok_color, :bold) + IRT.dye(" #{d}", :ok_color)
68
68
  else
69
69
  @@diffs += 1
70
- puts "#{tno}. DIFFS!".diff_color.bold + %( #{d}\n ).diff_color +
71
- %( at #{context.irb_path}: #{context.last_line_no} ).file_color.reversed.bold
70
+ puts IRT.dye("#{tno}. DIFFS!", :diff_color, :bold) + IRT.dye(" #{d}\n ", :diff_color) +
71
+ IRT.dye(" at #{context.irb_path}: #{context.last_line_no} ", :file_color, :reversed, :bold)
72
72
  puts IRT.differ.new(saved, actual, kind).output
73
73
  IRT::Session.enter(:interactive) if IRT.irt_on_diffs
74
74
  end
75
75
  rescue Exception
76
76
  @@errors += 1
77
- puts "#{tno}. ERROR! ".error_color.bold + d.error_color
77
+ puts IRT.dye("#{tno}. ERROR! ", :error_color, :bold) + IRT.dye(d, :error_color)
78
78
  raise
79
79
  end
80
80
  end
@@ -59,7 +59,7 @@ module IRB
59
59
  rescue Exception => e
60
60
  @exception_raised = true
61
61
  process_exception(e)
62
- print "\e[31m" if Colorer.color?
62
+ print "\e[31m" if Dye.color?
63
63
  raise
64
64
  else
65
65
  log_session_line(line, line_no) unless irt_mode == :file
@@ -69,7 +69,7 @@ module IRB
69
69
  %w[prompt_i prompt_s prompt_c prompt_n].each do |m|
70
70
  define_method(m) do
71
71
  pr = instance_variable_get("@#{m}")
72
- col_pr = pr.send "#{irt_mode}_color"
72
+ col_pr = IRT.dye pr, "#{irt_mode}_color".to_sym
73
73
  # workaround for Readline bug see http://www.ruby-forum.com/topic/213807
74
74
  if IRT.fix_readline_prompt
75
75
  col_pr.gsub(/^(.*)#{pr}(.*)$/, "\001\\1\002#{pr}\001\\2\002")
@@ -81,7 +81,7 @@ module IRB
81
81
 
82
82
  def return_format(color=:actual_color, ignored=false)
83
83
  ret = ignored ? @return_format.sub(/=/,'#') : @return_format
84
- ret.send color
84
+ IRT.dye ret, color
85
85
  end
86
86
 
87
87
  private
@@ -95,7 +95,7 @@ private
95
95
  def map_backtrace(bktr)
96
96
  @backtrace_map = {}
97
97
  mapped_bktr = []
98
- reverted_error_colors = 'xxx'.error_color.match(/^(.*)xxx(.*)$/).captures.reverse
98
+ reverted_error_colors = IRT.dye('xxx', :error_color).match(/^(.*)xxx(.*)$/).captures.reverse
99
99
  index_format = sprintf '%s%%s%s', *reverted_error_colors
100
100
  bktr.each_with_index do |m, i|
101
101
  unless i + 1 > back_trace_limit || m.match(/^\(.*\)/)
@@ -31,7 +31,7 @@ module IRB #:nodoc:
31
31
  @CONF[:AT_EXIT] ||= []
32
32
  @CONF[:AT_EXIT] << proc{ IRT::Session.enter(:interactive) if IRB.CurrentContext.irt_mode == :file } if !!ENV['IRT_INTERACTIVE_EOF']
33
33
  @CONF[:AT_EXIT] << proc{ IRT::Directives.test_summary }
34
- @CONF[:AT_EXIT] << proc{ print "\e[0m" if Colorer.color? } # reset colors
34
+ @CONF[:AT_EXIT] << proc{ print "\e[0m" if Dye.color? } # reset colors
35
35
  @CONF[:RC_NAME_GENERATOR] = proc {|rc| File.expand_path '~/.irtrc' }
36
36
 
37
37
  IRT.init
data/lib/irt/hunks.rb CHANGED
@@ -37,12 +37,12 @@ module IRT
37
37
  end
38
38
 
39
39
  def render_header
40
- puts " #{header_name} ".send(color).bold.reversed.or("***** #{header_name} *****")
40
+ puts IRT.dye(" #{header_name} ", "***** #{header_name} *****", color, :bold, :reversed)
41
41
  end
42
42
 
43
43
  def render_line(content, line_no)
44
- lcontent = content.send(color)
45
- lno = ('%3d ' % line_no).send(color).reversed
44
+ lcontent = IRT.dye content, color
45
+ lno = IRT.dye(('%3d ' % line_no), color, :reversed)
46
46
  puts "#{lno} #{lcontent}"
47
47
  end
48
48
 
data/lib/irt/log.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module IRT
2
2
  class Log < Array
3
3
 
4
- attr_accessor :ignored_commands, :ignored_echo_commands, :non_setting_commands, :tail_size, :status
4
+ attr_accessor :ignored_commands, :ignored_echo_commands, :non_setting_commands, :tail_size
5
+ attr_reader :status
5
6
 
6
7
  def initialize
7
8
  @ignored_echo_commands = FileUtils.own_methods
@@ -24,7 +25,7 @@ module IRT
24
25
  end
25
26
 
26
27
  def self.print_border
27
- print ' '.log_color.reversed.or('')
28
+ print IRT.dye(' ','', :log_color, :reversed)
28
29
  end
29
30
 
30
31
  def print(limit=nil) # nil prints all
@@ -66,29 +67,31 @@ module IRT
66
67
 
67
68
  def print_status
68
69
  segments = status.map {|name,mode| status_segment(name,mode)}
69
- puts segments.join(">>".log_color.bold)
70
+ puts segments.join(IRT.dye(">>", :log_color, :bold))
70
71
  end
71
72
 
72
73
  def pop_status
73
74
  name, mode = status.pop
74
75
  return if mode == :file
75
- puts " <<".log_color.bold + status_segment(name, mode)
76
+ puts IRT.dye(" <<", :log_color, :bold) + status_segment(name, mode)
76
77
  puts
77
78
  end
78
79
 
79
80
  def print_running_file
80
- puts " Running: #{IRT.irt_file} ".file_color.reversed.bold.or("*** Runing: #{IRT.irt_file} ***")
81
+ run_str = "Running: #{IRT.irt_file}"
82
+ puts IRT.dye(" #{run_str} ", "*** #{run_str} ***", :file_color, :bold, :reversed)
81
83
  end
82
84
 
83
85
  private
84
86
 
85
87
  def print_header(tail_str='')
86
88
  puts
87
- puts " Virtual Log#{' '+ tail_str unless tail_str.empty?} ".log_color.bold.reversed.or('***** IRT Log *****')
89
+ log_head = "Virtual Log#{' '+ tail_str unless tail_str.empty?}"
90
+ puts IRT.dye(" #{log_head} ", '***** #{log_head} *****', :log_color, :bold, :reversed)
88
91
  end
89
92
 
90
93
  def status_segment(name, mode)
91
- " #{name} ".send("#{mode}_color".to_sym).bold.reversed.or("[#{name}]")
94
+ IRT.dye(" #{name} ", "[#{name}]", "#{mode}_color".to_sym, :bold, :reversed)
92
95
  end
93
96
  end
94
97
  end
data/lib/irt.rb CHANGED
@@ -13,7 +13,7 @@ require 'irt/extensions/object'
13
13
  require 'irt/extensions/method'
14
14
  require 'irt/extensions/irb'
15
15
  require 'irb/completion'
16
- require 'colorer'
16
+ require 'dye'
17
17
  require 'irt/log'
18
18
  require 'irt/hunks'
19
19
  require 'irt/differ'
@@ -24,6 +24,19 @@ module IRT
24
24
 
25
25
  VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
26
26
 
27
+ OS = case RbConfig::CONFIG['host_os']
28
+ when /mswin|msys|mingw32|windows/i
29
+ :windows
30
+ when /darwin|mac os/i
31
+ :macosx
32
+ when /linux/i
33
+ :linux
34
+ when /(solaris|bsd)/i
35
+ :unix
36
+ else
37
+ :unknown
38
+ end
39
+
27
40
  class IndexError < RuntimeError ; end
28
41
  class SessionModeError < RuntimeError ; end
29
42
  class ArgumentTypeError < RuntimeError ; end
@@ -32,30 +45,12 @@ module IRT
32
45
  extend self
33
46
 
34
47
  attr_accessor :irt_on_diffs, :tail_on_irt, :fix_readline_prompt, :debug,
35
- :full_exit, :exception_raised, :session_no, :autoload_helper_files,
48
+ :full_exit, :exception_raised, :session_no, :autoload_helper_files, :dye_styles,
36
49
  :copy_to_clipboard_command, :nano_command_format, :vi_command_format, :edit_command_format, :ri_command_format
37
- attr_reader :log, :irt_file, :differ, :os
38
-
39
- Colorer.def_custom_styles :bold => :bold,
40
- :reversed => :reversed,
41
- :null => :clear,
42
-
43
- :log_color => :blue,
44
- :file_color => :cyan,
45
- :interactive_color => :magenta,
46
- :inspect_color => :clear,
47
- :binding_color => :yellow,
48
- :actual_color => :green,
49
- :ignored_color => :yellow,
50
-
51
- :error_color => :red,
52
- :ok_color => :green,
53
- :diff_color => :yellow,
54
- :diff_a_color => :cyan,
55
- :diff_b_color => :green
50
+ attr_reader :log, :irt_file, :differ
56
51
 
57
52
  def force_color=(bool)
58
- Colorer.color = bool
53
+ Dye.color = bool
59
54
  end
60
55
 
61
56
  def init
@@ -65,31 +60,41 @@ module IRT
65
60
  @tail_on_irt = false
66
61
  @fix_readline_prompt = false
67
62
  @autoload_helper_files = true
68
- @os = get_os
69
- @copy_to_clipboard_command = case @os
70
- when :windows
71
- 'clip'
72
- when :macosx
73
- 'pbcopy'
74
- when :linux, :unix
75
- 'xclip -selection c'
76
- end
77
- @edit_command_format = case @os
78
- when :windows
79
- '%1$s'
80
- when :macosx
81
- 'open -t %1$s'
82
- when :linux, :unix
83
- case ENV['DESKTOP_SESSION']
63
+ @dye_styles = { :null => :clear,
64
+
65
+ :log_color => :blue,
66
+ :file_color => :cyan,
67
+ :interactive_color => :magenta,
68
+ :inspect_color => :clear,
69
+ :binding_color => :yellow,
70
+ :actual_color => :green,
71
+ :ignored_color => :yellow,
72
+
73
+ :error_color => :red,
74
+ :ok_color => :green,
75
+ :diff_color => :yellow,
76
+ :diff_a_color => :cyan,
77
+ :diff_b_color => :green }
78
+ define_dye_method @dye_styles
79
+ case OS
80
+ when :windows
81
+ @copy_to_clipboard_command = 'clip'
82
+ @edit_command_format = '%1$s'
83
+ when :macosx
84
+ @copy_to_clipboard_command = 'pbcopy'
85
+ @edit_command_format = 'open -t %1$s'
86
+ when :linux, :unix
87
+ @copy_to_clipboard_command = 'xclip -selection c'
88
+ @edit_command_format = case ENV['DESKTOP_SESSION']
84
89
  when /kde/i
85
90
  'kde-open %1$s'
86
91
  when /gnome/i
87
92
  'gnome-open %1$s'
88
93
  end
89
- end
94
+ end
90
95
  @vi_command_format = "vi -c 'startinsert' %1$s +%2$d"
91
96
  @nano_command_format = 'nano +%2$d %1$s'
92
- @ri_command_format = "qri -f #{Colorer.color? ? 'ansi' : 'plain'} %s"
97
+ @ri_command_format = "qri -f #{Dye.color? ? 'ansi' : 'plain'} %s"
93
98
  @debug = false
94
99
  end
95
100
 
@@ -114,30 +119,13 @@ module IRT
114
119
  def prompter
115
120
  @prompter ||= begin
116
121
  require 'prompter'
117
- pr = Prompter.new
118
- def pr.say_echo(result, opts={})
119
- opts = {:style => :ignored_color}.merge opts
120
- say ' #> ' + result.inspect, opts
122
+ Prompter.new do |pr|
123
+ def pr.say_echo(result, opts={})
124
+ opts = {:style => IRT.dye_styles[:ignored_color]}.merge opts
125
+ say ' #> ' + result.inspect, opts
126
+ end
121
127
  end
122
- pr
123
128
  end
124
129
  end
125
130
 
126
- private
127
-
128
- def get_os
129
- case RbConfig::CONFIG['host_os']
130
- when /mswin|msys|mingw32|windows/i
131
- :windows
132
- when /darwin|mac os/i
133
- :macosx
134
- when /linux/i
135
- :linux
136
- when /solaris|bsd/i
137
- :unix
138
- else
139
- :unknown
140
- end
141
- end
142
-
143
131
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Domizio Demichelis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-29 00:00:00 -04:00
18
+ date: 2011-02-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,19 +35,19 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: colorer
38
+ name: dye
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 25
46
46
  segments:
47
47
  - 0
48
- - 7
49
- - 0
50
- version: 0.7.0
48
+ - 1
49
+ - 1
50
+ version: 0.1.1
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -58,12 +58,12 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: 25
61
+ hash: 31
62
62
  segments:
63
63
  - 0
64
64
  - 1
65
- - 1
66
- version: 0.1.1
65
+ - 2
66
+ version: 0.1.2
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency