irt 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -12,7 +12,8 @@ that will make your life a lot easier.
12
12
 
13
13
  - clean colored output for easy reading
14
14
  - 3 types of sessions: interactive, inspecting and binding
15
- - irb opening from your code as binding session
15
+ - irb opening from your code (or erb templates) as binding session
16
+ - optional colored rails log in the console
16
17
  - contextual ri doc with completion
17
18
  - recording of session steps with filtering
18
19
  - easy testing based on recorded steps
@@ -474,7 +475,7 @@ IRT tries to load a ~/.irtrc file at startup, so you can customize a few options
474
475
  If you want to add your custom '~/.irbrc' file, try to load it at the top: if it doesn't
475
476
  play well with IRT, then copy and paste just part of it.
476
477
 
477
- You can also change a few configuration options in the ~/.irtrc file. The following are the defaults
478
+ You can also change the configuration options in the ~/.irtrc file. The following are the defaults
478
479
  which should work quite well without any change:
479
480
 
480
481
  # set this to true if your prompt get messed up when you use the history
@@ -523,6 +524,12 @@ which should work quite well without any change:
523
524
  # any command that will not set the last value (includes all the log-ignored commands)
524
525
  # IRT.log.non_setting_commands << %w[commandE commandF ...]
525
526
 
527
+ # shows the rails log in console
528
+ # IRT.rails_log = true
529
+
530
+ # colors with :log_color (default blue) the rails log for easy reading
531
+ # IRT.dye_rails_log = true
532
+
526
533
  ### Colors
527
534
 
528
535
  The default color styles of IRT should be OK in most situation, anyway, if you really don't like the colors,
@@ -572,11 +579,22 @@ irt_helper.rb #1, #2 and #3. If you are running the testA.irt and testB.irt, IRT
572
579
  require the irt_helper.rb #1, #2. But if you run the same from the first_level dir, the irt_helper.rb #1
573
580
  will not be loaded, so be careful to be in the right dir to make it work properly.
574
581
 
575
- ### Rails 3
582
+ ### Rails
583
+
584
+ You can use irt instead of the standard Rails console, by just calling the irt executable from
585
+ any Rails application dir. By default IRT will output the rails log (colored in blue) right in the console.
586
+
587
+ You can switch the rails log ON or OFF by using the 'rails\_log\_on' and 'rails\_log\_off' commands in any session,
588
+ besides you can set the option true or false in the ~/.irtrc file.
589
+
590
+ #### Rails 3
576
591
 
577
592
  You must add the gem to your Gemfile, to make the bundler happy:
578
593
 
579
- gem 'irt', :group => :console
594
+ gem 'irt'
595
+
596
+ eventually adding it only to the group that you prefer.
597
+
580
598
 
581
599
  ## Known Issue
582
600
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.1.4
data/bin/irt CHANGED
@@ -58,7 +58,7 @@ puts copy
58
58
 
59
59
  paths = if ARGV.empty?
60
60
  options[:interactive_eof] = true
61
- tmp_file = Tempfile.new(%w[tmp- .irt])
61
+ tmp_file = Tempfile.new(['', '.irt'])
62
62
  tmp_file << "\n" # one empty line makes irb of 1.9.2 happy
63
63
  tmp_file.flush
64
64
  [ tmp_file.path ]
@@ -86,7 +86,7 @@ cmd_format = if File.exists?('./config/environment.rb')
86
86
  if File.exists?('./script/rails')
87
87
  'rails c %s %s %s'
88
88
  elsif File.exists?('./script/console')
89
- 'ruby script/console --irb="irt_rails2"'
89
+ 'ruby script/console --irb="irt_rails2 %s"'
90
90
  end
91
91
  else
92
92
  'irt_irb %s %s'
data/bin/irt_rails2 CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  argv = ARGV.dup
4
- argv.pop
5
- argv << ENV['IRT_FILE']
4
+ argv.pop # remove --simple-prompt
5
+ argv.push argv.shift # move the irt file to the end
6
6
  exec "irt_irb #{argv.join(' ')}"
data/irt.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_runtime_dependency('dye', [">= 0.1.1"])
16
16
  s.add_runtime_dependency('prompter', [">= 0.1.2"])
17
17
  if IRT::RubyVersion >= '1.9.2'
18
- s.add_runtime_dependency('bri', [">= 0.1.4"])
18
+ s.add_runtime_dependency('bri', [">= 0.1.5"])
19
19
  else
20
20
  s.add_runtime_dependency('fastri', [">= 0.3.1.1"])
21
21
  end
data/irtrc CHANGED
@@ -47,4 +47,8 @@
47
47
  # any command that will not set the last value (includes all the log-ignored commands)
48
48
  # IRT.log.non_setting_commands << %w[commandE commandF ...]
49
49
 
50
- # add your stuff here
50
+ # shows the rails log in console
51
+ # IRT.rails_log = true
52
+
53
+ # colors with :log_color (default blue) the rails log for easy reading
54
+ # IRT.dye_rails_log = true
@@ -5,7 +5,7 @@ module IRB
5
5
 
6
6
  attr_accessor :parent_context, :current_line, :binding_file, :binding_line_no, :backtrace_map
7
7
  attr_reader :current_line_no, :last_line_no
8
- attr_writer :irt_mode
8
+ attr_writer :irt_mode, :return_ignored_echo_format
9
9
 
10
10
  def file_line_pointers
11
11
  file = line = nil
@@ -79,9 +79,18 @@ module IRB
79
79
  end
80
80
  end
81
81
 
82
- def return_format(color=:actual_color, ignored=false)
83
- ret = ignored ? @return_format.sub(/=/,'#') : @return_format
84
- IRT.dye ret, color
82
+ def return_format
83
+ IRT.dye @return_format, :actual_color
84
+ end
85
+
86
+ def return_ignored_echo_format
87
+ IRT.dye @return_ignored_echo_format, :ignored_color
88
+ end
89
+
90
+ alias_method :original_prompt_mode, :prompt_mode=
91
+ def prompt_mode=(mode)
92
+ original_prompt_mode(mode)
93
+ @return_ignored_echo_format = IRB.conf[:PROMPT][mode][:RETURN_I] || " #> %s\n"
85
94
  end
86
95
 
87
96
  private
@@ -138,9 +147,9 @@ private
138
147
 
139
148
  def output_ignored_echo_value(value)
140
149
  if inspect?
141
- printf return_format(:ignored_color,false), value.inspect
150
+ printf return_ignored_echo_format, value.inspect
142
151
  else
143
- printf return_format(:ignored_color,false), value
152
+ printf return_ignored_echo_format, value
144
153
  end
145
154
  end
146
155
 
@@ -22,7 +22,8 @@ module IRB #:nodoc:
22
22
  :PROMPT_S => ' "> ',
23
23
  :PROMPT_C => "%02n ?> ",
24
24
  :PROMPT_N => "%02n -> ",
25
- :RETURN => " => %s\n" }
25
+ :RETURN => " => %s\n",
26
+ :RETURN_I => " #> %s\n" }
26
27
  @CONF[:PROMPT_MODE] = :IRT
27
28
  @CONF[:ECHO] = false
28
29
  @CONF[:VERBOSE] = false
@@ -26,11 +26,11 @@ class Method
26
26
 
27
27
  def info
28
28
  file, line = location
29
- { :name => name,
30
- :class_name => owner.name,
31
- :file => file,
32
- :line => line,
33
- :arity => arity }
29
+ { :name => name,
30
+ :owner => owner.name,
31
+ :file => file,
32
+ :line => line,
33
+ :arity => arity }
34
34
  end
35
35
 
36
36
  end
@@ -0,0 +1,31 @@
1
+ class ActiveSupport::BufferedLogger
2
+
3
+ alias_method :original_add, :add
4
+
5
+ def add(*args)
6
+ message = original_add(*args)
7
+ if IRT.rails_log
8
+ if IRT.dye_rails_log
9
+ plain_message = Dye.strip_ansi(message).chomp
10
+ irt_message = IRT.dye(plain_message, :log_color) + "\n"
11
+ end
12
+ puts irt_message || message
13
+ end
14
+ message
15
+ end
16
+
17
+ end
18
+
19
+ module IRB
20
+ module ExtendCommandBundle #:nodoc:
21
+
22
+ def rails_log_on
23
+ IRT.rails_log = true
24
+ end
25
+
26
+ def rails_log_off
27
+ IRT.rails_log = false
28
+ end
29
+
30
+ end
31
+ end
data/lib/irt.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  require 'rubygems'
2
- begin
3
- require 'ap'
4
- rescue LoadError
5
- end
6
2
 
7
3
  require 'pp'
8
4
  require 'yaml'
@@ -45,7 +41,7 @@ module IRT
45
41
 
46
42
  extend self
47
43
 
48
- attr_accessor :irt_on_diffs, :tail_on_irt, :fix_readline_prompt, :debug,
44
+ attr_accessor :irt_on_diffs, :tail_on_irt, :fix_readline_prompt, :debug, :rails_log, :dye_rails_log,
49
45
  :full_exit, :exception_raised, :session_no, :autoload_helper_files, :dye_styles,
50
46
  :copy_to_clipboard_command, :nano_command_format, :vi_command_format, :edit_command_format, :ri_command_format
51
47
  attr_reader :log, :irt_file, :differ
@@ -60,6 +56,8 @@ module IRT
60
56
  @irt_on_diffs = true
61
57
  @tail_on_irt = false
62
58
  @fix_readline_prompt = false
59
+ @rails_log = true
60
+ @dye_rails_log = true
63
61
  @autoload_helper_files = true
64
62
  @dye_styles = { :null => :clear,
65
63
 
@@ -103,6 +101,7 @@ module IRT
103
101
  @irt_file = IRB.conf[:SCRIPT]
104
102
  @log = Log.new
105
103
  @log.print_running_file
104
+ require 'irt/extensions/rails' if defined?(ActiveSupport::BufferedLogger)
106
105
  IRT::Directives.load_helper_files
107
106
  end
108
107
 
@@ -122,8 +121,7 @@ module IRT
122
121
  require 'prompter'
123
122
  Prompter.new do |pr|
124
123
  def pr.say_echo(result, opts={})
125
- opts = {:style => IRT.dye_styles[:ignored_color]}.merge opts
126
- say ' #> ' + result.inspect, opts
124
+ IRB.CurrentContext.send :output_ignored_echo_value, result
127
125
  end
128
126
  end
129
127
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: irt
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.3
5
+ version: 1.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Domizio Demichelis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-02 00:00:00 -04:00
13
+ date: 2011-02-05 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -54,7 +54,7 @@ dependencies:
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: 0.1.4
57
+ version: 0.1.5
58
58
  type: :runtime
59
59
  version_requirements: *id004
60
60
  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.
@@ -97,6 +97,7 @@ files:
97
97
  - lib/irt/extensions/kernel.rb
98
98
  - lib/irt/extensions/method.rb
99
99
  - lib/irt/extensions/object.rb
100
+ - lib/irt/extensions/rails.rb
100
101
  - lib/irt/hunks.rb
101
102
  - lib/irt/init.rb
102
103
  - lib/irt/log.rb