irt 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -423,6 +423,13 @@ the wanted line. Example:
423
423
 
424
424
  ## General Tools
425
425
 
426
+ ### Permanent last value (_)
427
+
428
+ IRT tries to keep the relevant results from running code, separated from the results of the inspecting
429
+ and documentation commands. In practice all the IRT commands, and the inspecting commands (like 'p', 'pp', 'y' and 'ap')
430
+ don't set the last value, so you can mix them with your code and the '_' will remain set to your last relevant result.
431
+ That is specially useful when you want to add a test with the 'add_test' (or 'tt') command.
432
+
426
433
  ### Contextual ri doc with autocompletion
427
434
 
428
435
  IRT offers the 'ri' command implemented with fastri for RUBY_VERSION < 1.9.2, or 'bri' for RUBY_VERSION >= 1.9.2:
@@ -737,7 +744,30 @@ You must add the gem to your Gemfile, to make the bundler happy:
737
744
  eventually adding it only to the group that you prefer. Anyway, if the irt executable detects that you don't have it set,
738
745
  it will ask and eventually add it for you.
739
746
 
740
- ## Known Issues
747
+ ## Known Issues (and fixes)
748
+
749
+ ### Readline history
750
+
751
+ The ruby readline library may have a problem with the history when you use an ANSI colored prompt
752
+ (see this [readline bug](http://www.ruby-forum.com/topic/213807)).
753
+ If your prompt get messed up while you are navigating the history, you need to enable the 'fix\_readline\_prompt'
754
+ configuration option (see the Configuration session). That option fixes the prompt when it get messed, but messed
755
+ it if it doesn't, so if you switch among different ruby versions, you might need to make it conditional. For example:
756
+
757
+ if IRT::RubyVersion <= '1.8.7'
758
+ IRT.fix_readline_prompt = true
759
+ end
760
+
761
+ #### MacOS X and libedit
762
+
763
+ If you are on MacOS X, your ruby might use libedit instead of readline. In that case you are not affected
764
+ by the above readline bug, but you will be bothered by a few other problems, so you might want to link your ruby
765
+ to readline. Depending on your installation, you have a few different choices to avoid to reinstall ruby.
766
+
767
+ Useful links you can start with:
768
+
769
+ * [RVM-readline](http://rvm.beginrescueend.com/packages/readline/)
770
+ * [MacPort-readline](http://henrik.nyh.se/2008/03/irb-readline)
741
771
 
742
772
  ### Yaml serialization
743
773
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
data/irt.gemspec CHANGED
@@ -14,19 +14,31 @@ Gem::Specification.new do |s|
14
14
  s.add_runtime_dependency('differ', [">= 0.1.1"])
15
15
  s.add_runtime_dependency('dye', [">= 0.1.3"])
16
16
  s.add_runtime_dependency('prompter', [">= 0.1.4"])
17
- s.requirements << "In order to use the IRT contextual ri command you must install the gem 'bri' (ruby >=1.9.2) or 'fastri' (ruby < 1.9.2)"
18
17
 
19
18
  s.executables = ['irt', 'irt_irb', 'irt_rails2']
20
19
  s.files = `git ls-files -z`.split("\0") - %w[irt-tutorial.pdf]
21
20
  s.post_install_message = <<EOM
21
+ ________________________________________________________________________________
22
22
 
23
- ********************************************************************************
23
+ IMPORTANT NOTES
24
+ ________________________________________________________________________________
24
25
 
25
- In order to use the IRT contextual ri command you must also install the gem:
26
- "bri" if you run ruby >= 1.9.2
27
- "fastri" if you run ruby < 1.9.2
26
+ 1. If you notice a messed prompt while navigating the history, you must
27
+ enable the 'fix_readline_prompt' option in the ~/.irtrc file:
28
28
 
29
- ********************************************************************************
29
+ IRT.fix_readline_prompt = true
30
+
31
+ (see the README file for details)
32
+
33
+ ________________________________________________________________________________
34
+
35
+ 2. In order to use the IRT contextual ri command, one of the following gems
36
+ must be installed:
37
+
38
+ "bri" if you run ruby >= 1.9.2
39
+ "fastri" if you run ruby < 1.9.2
40
+
41
+ ________________________________________________________________________________
30
42
 
31
43
  EOM
32
44
  s.name = name
data/lib/irt.rb CHANGED
@@ -100,7 +100,7 @@ module IRT
100
100
  @vi_command_format = %(vi "%1$s" +%2$d)
101
101
  @nano_command_format = %(nano +%2$d "%1$s")
102
102
  @emacs_command_format = %(emacs +%2$d "%1$s")
103
- @ri_command_format = IRT::RubyVersion >= '1.9.2' ? %(bri "%s") : %(qri -f #{Dye.color? ? 'ansi' : 'plain'} "%s")
103
+ @ri_command_format = IRT::Commands::Ri::GEM == 'bri' ? %(bri "%s") : %(qri -f #{Dye.color? ? 'ansi' : 'plain'} "%s")
104
104
  @pager_command = 'less -R'
105
105
  @debug = false
106
106
  end
@@ -136,8 +136,6 @@ module IRT
136
136
  def start
137
137
  return if initialized
138
138
  puts copyright
139
- ARGV.clear
140
- ARGV.push create_tmp_file
141
139
  IRB.start
142
140
  end
143
141
 
@@ -43,11 +43,11 @@ module IRT
43
43
  c<editor> Like `copy_lines` and <editor> in just one step
44
44
 
45
45
  #{label(" Test Commands ", :interactive_color) + IRT.dye(" (only available in interactive sessions)", :interactive_color, :bold)}
46
- add_desc|dd desc Adds a description for the test in the log
47
- add_test|tt Adds a test in the log, checking the last value (_)
46
+ add_desc|ad|dd desc Adds a description for the test in the log
47
+ add_test|at|tt Adds a test in the log, checking the last value (_)
48
48
  by automatically choosing the :_eql?, or :_yaml_eql?
49
49
  method, depending on the type of the last value (_)
50
- add_test|tt desc Like add_test but adds a 'desc' directive first'
50
+ add_test|at|tt desc Like add_test but adds a 'desc' directive first'
51
51
  save_as|sa path Saves the current irt file as path
52
52
 
53
53
  #{label " FileUtils Commands ", :interactive_color}
@@ -117,8 +117,8 @@ module IRT
117
117
  the evaluated yaml file
118
118
  e.g.: {:a => 2}.vi #=> {:an_edited => 'value'}
119
119
  Method#location When possible, it returns file and line where the
120
- method is defined. It is uitable to be passed to the
121
- in place editing commands.
120
+ method is defined. It is suitable to be passed to
121
+ the in place editing commands.
122
122
  Method#info Returns useful info about the method. It is suitable
123
123
  to be passed to the in place editing commands.
124
124
  )
@@ -2,6 +2,7 @@ module IRT
2
2
  module Commands
3
3
  module Ri
4
4
 
5
+ GEM = IRT::RubyVersion >= '1.9.2' ? 'bri' : 'fastri'
5
6
  @@choices_map = {}
6
7
 
7
8
  def self.reset_choices_map
@@ -26,6 +27,9 @@ module IRT
26
27
  return
27
28
  end
28
29
 
30
+ when arg =~ /^[A-Z]\w+\#[^.]+/
31
+ to_search = arg
32
+
29
33
  when arg !~ /\./
30
34
  begin
31
35
  obj = eval arg, IRB.CurrentContext.workspace.binding
@@ -63,7 +67,13 @@ module IRT
63
67
  private
64
68
 
65
69
  def process_ri(to_search)
66
- ri = `#{sprintf(IRT.ri_command_format, to_search)}`
70
+ ri = if defined?(Bundler)
71
+ Bundler.with_clean_env do
72
+ `#{sprintf(IRT.ri_command_format, to_search)}`
73
+ end
74
+ else
75
+ `#{sprintf(IRT.ri_command_format, to_search)}`
76
+ end
67
77
  ri_problem unless $?.to_i == 0
68
78
  return if ri.match(/^(nil|No matching results found)$/)
69
79
  if m = ri.match(/^(-+.*Multiple choices:.*\n\n)(.+)/m)
@@ -82,10 +92,9 @@ module IRT
82
92
  end
83
93
 
84
94
  def ri_problem
85
- ri_gem = IRT::RubyVersion >= '1.9.2' ? 'bri' : 'fastri'
86
- message = system("#{required} -v") ?
87
- "Bad ri_command_format for this system." :
88
- %(You must install the "#{ri_gem}" gem to use this command with ruby #{RUBY_VERSION}.)
95
+ cmds = {'bri' => 'bri', 'fastri' => 'qri'}
96
+ message = `#{cmds[GEM]}` ? "Bad ri_command_format for this system." :
97
+ %(You must install the "#{GEM}" gem to use this command with ruby #{RUBY_VERSION}.)
89
98
  raise IRT::NotImplementedError, message
90
99
  end
91
100
 
@@ -14,6 +14,7 @@ module IRT
14
14
  puts
15
15
  end
16
16
  alias_method :dd, :add_desc
17
+ alias_method :ad, :add_desc
17
18
 
18
19
  def add_test(description='')
19
20
  mode = context.irt_mode
@@ -43,6 +44,7 @@ module IRT
43
44
  puts
44
45
  end
45
46
  alias_method :tt, :add_test
47
+ alias_method :at, :add_test
46
48
 
47
49
  def save_as(file_path)
48
50
  IRT.save_as(file_path)
@@ -46,10 +46,7 @@ module IRT
46
46
  down_path = IRT.irt_file.relative_path_from container_path
47
47
  down_path.dirname.descend do |p|
48
48
  helper_path = container_path.join(p, 'irt_helper.rb')
49
- begin
50
- require helper_path
51
- rescue LoadError
52
- end
49
+ require helper_path if File.exist?(helper_path)
53
50
  end
54
51
  end
55
52
 
@@ -8,6 +8,7 @@ module IRB #:nodoc:
8
8
  class << self
9
9
  alias_method :original_init_config, :init_config
10
10
  alias_method :original_setup, :setup
11
+ alias_method :original_parse_opts, :parse_opts
11
12
  end
12
13
 
13
14
  def IRB.setup(ap_path=nil)
@@ -38,6 +39,13 @@ module IRB #:nodoc:
38
39
  @CONF[:RC_NAME_GENERATOR] = proc {|rc| File.expand_path '~/.irtrc' }
39
40
  end
40
41
 
42
+ def IRB.parse_opts
43
+ IRB.original_parse_opts
44
+ unless @CONF[:SCRIPT]
45
+ @CONF[:SCRIPT] = IRT.create_tmp_file
46
+ $0 = @CONF[:SCRIPT]
47
+ end
48
+ end
41
49
 
42
50
  module HistorySavingAbility
43
51
  def HistorySavingAbility.extended(obj)
@@ -72,22 +72,6 @@ private
72
72
  IRT::Prompter.say_notice "Server resumed"
73
73
  end
74
74
 
75
-
76
- module Session
77
-
78
- alias_method :original_run_file, :run_file
79
- def run_file(*args)
80
- original_run_file *args
81
- ensure
82
- if IRT.rails_server
83
- IRB.irb_at_exit
84
- enter :interactive
85
- end
86
- end
87
-
88
- end
89
-
90
-
91
75
  module Utils
92
76
  alias_method :original_ask_run_new_file, :ask_run_new_file
93
77
  # skips asking to run the save file if it is a tmp file in a server session
@@ -109,10 +93,8 @@ private
109
93
  end
110
94
 
111
95
  end
112
- end
113
96
 
114
97
 
115
- module Commands
116
98
  module Rails
117
99
 
118
100
  extend self # ignored_echo_commands
data/lib/irt/session.rb CHANGED
@@ -36,7 +36,7 @@ module IRT
36
36
  IRT.log.print_status unless mode == :file
37
37
  old_trap = trap('SIGINT'){new_context.irb.signal_handle}
38
38
  catch(:IRB_EXIT) { new_context.irb.eval_input }
39
- begin throw(:IRB_EXIT) ; rescue ArgumentError ; end if @@exit_all
39
+ begin throw(:IRB_EXIT) ; rescue Exception ; end if @@exit_all
40
40
  ensure
41
41
  IRT::Session.exit unless @@exit_all
42
42
  trap 'SIGINT', old_trap if old_trap
@@ -75,6 +75,11 @@ module IRT
75
75
  IRB.conf[:AT_EXIT].push(openfile)
76
76
  @@exit_all = true
77
77
  throw(:IRB_EXIT)
78
+ ensure
79
+ unless IRT.cli?
80
+ IRB.irb_at_exit
81
+ enter :interactive
82
+ end
78
83
  end
79
84
 
80
85
 
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irt
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.2.2
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 3
10
+ version: 1.2.3
6
11
  platform: ruby
7
12
  authors:
8
13
  - Domizio Demichelis
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-14 00:00:00 -04:00
18
+ date: 2011-03-29 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,11 @@ dependencies:
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 1
24
34
  version: 0.1.1
25
35
  type: :runtime
26
36
  version_requirements: *id001
@@ -32,6 +42,11 @@ dependencies:
32
42
  requirements:
33
43
  - - ">="
34
44
  - !ruby/object:Gem::Version
45
+ hash: 29
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 3
35
50
  version: 0.1.3
36
51
  type: :runtime
37
52
  version_requirements: *id002
@@ -43,6 +58,11 @@ dependencies:
43
58
  requirements:
44
59
  - - ">="
45
60
  - !ruby/object:Gem::Version
61
+ hash: 19
62
+ segments:
63
+ - 0
64
+ - 1
65
+ - 4
46
66
  version: 0.1.4
47
67
  type: :runtime
48
68
  version_requirements: *id003
@@ -99,9 +119,29 @@ has_rdoc: true
99
119
  homepage: http://github.com/ddnexus/irt
100
120
  licenses: []
101
121
 
102
- post_install_message: "\n\
103
- ********************************************************************************\n\n In order to use the IRT contextual ri command you must also install the gem:\n \"bri\" if you run ruby >= 1.9.2\n \"fastri\" if you run ruby < 1.9.2\n\n\
104
- ********************************************************************************\n\n"
122
+ post_install_message: |+
123
+ ________________________________________________________________________________
124
+
125
+ IMPORTANT NOTES
126
+ ________________________________________________________________________________
127
+
128
+ 1. If you notice a messed prompt while navigating the history, you must
129
+ enable the 'fix_readline_prompt' option in the ~/.irtrc file:
130
+
131
+ IRT.fix_readline_prompt = true
132
+
133
+ (see the README file for details)
134
+
135
+ ________________________________________________________________________________
136
+
137
+ 2. In order to use the IRT contextual ri command, one of the following gems
138
+ must be installed:
139
+
140
+ "bri" if you run ruby >= 1.9.2
141
+ "fastri" if you run ruby < 1.9.2
142
+
143
+ ________________________________________________________________________________
144
+
105
145
  rdoc_options:
106
146
  - --charset=UTF-8
107
147
  require_paths:
@@ -111,17 +151,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
151
  requirements:
112
152
  - - ">="
113
153
  - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
114
157
  version: "0"
115
158
  required_rubygems_version: !ruby/object:Gem::Requirement
116
159
  none: false
117
160
  requirements:
118
161
  - - ">="
119
162
  - !ruby/object:Gem::Version
163
+ hash: 23
164
+ segments:
165
+ - 1
166
+ - 3
167
+ - 6
120
168
  version: 1.3.6
121
- requirements:
122
- - In order to use the IRT contextual ri command you must install the gem 'bri' (ruby >=1.9.2) or 'fastri' (ruby < 1.9.2)
169
+ requirements: []
170
+
123
171
  rubyforge_project:
124
- rubygems_version: 1.5.0
172
+ rubygems_version: 1.3.7
125
173
  signing_key:
126
174
  specification_version: 3
127
175
  summary: Interactive Ruby Tools - Very improved irb and Rails Console with a lot of cool features.