irt 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.5
1
+ 1.2.6
@@ -1,8 +1,10 @@
1
1
  module IRT
2
2
  module Commands
3
3
  module Core
4
+ extend self
4
5
 
5
6
  def irt(obj=nil)
7
+ context ||= IRB.CurrentContext
6
8
  irt_mode = context.irt_mode
7
9
  to_mode = case obj
8
10
  when nil
@@ -11,116 +11,117 @@ module IRT
11
11
  - The #{IRT.dye "Extensions", :log_color, :bold} are methods available anywhere
12
12
 
13
13
  #{label " Inspecting Commands ", :interactive_color}
14
- irt object Opens an inspecting session into object
15
- vdiff|vd obj_a, obj_b Prints the visual diff of the yaml dump of 2 objects
16
- p, pp, ap, y When invoked with no arguments print the last_value
17
- (e.g. just type 'y' instead 'y _')
14
+ irt object Opens an inspecting session into object
15
+ vdiff|vd obj_a, obj_b Prints the visual diff of the yaml dump of 2 objects
16
+ p, pp, ap, y When invoked with no arguments print the last_value
17
+ (e.g. just type 'y' instead 'y _')
18
18
 
19
19
  #{label " Log Commands ", :interactive_color}
20
- log|l [limit] Prints limit or 'tail_size' lines of the virtual log
21
- full_log|ll Prints all the lines in the virtual log
22
- print_lines|pl Prints the last lines of the current session
23
- without numbers (for easy copying)
24
- print_all_lines|pll Like print_line but prints all the sessions lines
20
+ log|l [limit] Prints limit or 'tail_size' lines of the virtual log
21
+ full_log|ll Prints all the lines in the virtual log
22
+ print_lines|pl Prints the last lines of the current session
23
+ without numbers (for easy copying)
24
+ print_all_lines|pll Like print_line but prints all the sessions lines
25
25
 
26
26
  #{label " In Place Editing Commands ", :interactive_color}
27
27
  (<editor> can be 'vi', 'nano|nn', 'emacs|em', 'edit|ed')
28
- <editor> Uses <editor> to open the current evalued file at
29
- the current evalued line for in place edit
30
- <editor> file[, line] Uses <editor> to open file [at line] for in place
31
- editing
32
- <editor> hash Uses <editor> to open hash[:file] at the hash[:line]
33
- <editor> array Uses <editor> to open array[0] at the array[1] line
34
- <editor> traceline Uses <editor> to open the file at line in traceline
35
- e.g.: nn "from /path/to/file.rb:34:in 'any_method'"
36
- nn "a_gem (1.2.3) lib/file.rb:13:in 'a_meth'"
37
- <editor> n Uses <editor> to open the backtraced file [n] at
38
- the backtraced line
28
+ <editor> Uses <editor> to open the current evalued file at
29
+ the current evalued line for in place edit
30
+ <editor> file[, line] Uses <editor> to open file [at line] for in place
31
+ editing
32
+ <editor> hash Uses <editor> to open hash[:file] at the hash[:line]
33
+ <editor> array Uses <editor> to open array[0] at the array[1] line
34
+ <editor> traceline Uses <editor> to open the file at line in traceline
35
+ e.g.: nn "from /path/to/file.rb:34:in 'any_method'"
36
+ nn "a_gem (1.2.3) lib/file.rb:13:in 'a_meth'"
37
+ <editor> n Uses <editor> to open the backtraced file [n] at
38
+ the backtraced line
39
39
 
40
40
  #{label( " Copy-Edit Commands ", :interactive_color ) + IRT.dye(" (use copy_to_clipboard_command)", :interactive_color, :bold)}
41
- copy_lines|cl Copies the last session lines to the clipboard
42
- copy_all_lines|cll Copies all the sessions' lines to the clipboard
43
- c<editor> Like `copy_lines` and <editor> in just one step
41
+ copy_lines|cl Copies the last session lines to the clipboard
42
+ copy_all_lines|cll Copies all the sessions' lines to the clipboard
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|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
- by automatically choosing the :_eql?, or :_yaml_eql?
49
- method, depending on the type of the last value (_)
50
- add_test|at|tt desc Like add_test but adds a 'desc' directive first'
51
- save_as|sa path Saves the current irt file as path
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
+ by automatically choosing the :_eql?, or :_yaml_eql?
49
+ method, depending on the type of the last value (_)
50
+ add_test|at|tt desc Like add_test but adds a 'desc' directive first'
51
+ save_as|sa path Saves the current irt file as path
52
52
 
53
53
  #{label " FileUtils Commands ", :interactive_color}
54
54
  All the FileUtils methods are availabe as IRT Commands
55
55
  (e.g. pwd, touch, mkdir, mv, cp, rm, rm_rf, compare_files, ...)
56
56
 
57
57
  #{label " Documentation Commands ", :interactive_color}
58
- ri "string_to_search" Search the ri doc for the literal string_to_search
59
- ri to_search Search the ri doc for to_search (without quote)
60
- If to_search represents any object in your code
61
- it looks for the obj.class documentation
62
- e.g.: ri arr #=> (where arr=[]) ri doc for Array
63
- ri "" #=> ri doc for String
64
- ri obj.any_method Search the method.owner ri doc for of any_method
65
- (no quotes needed, and completion available)
66
- e.g.: ri "".eql? #=> ri doc for String#eql?
67
- ri [].eql? #=> ri doc for Array#eql?
68
- ri n Search the ri doc for the method n in a multiple
69
- choices list
70
- pri ... Like the above commands for `ri ...` but uses the
71
- pager to show the result
58
+ ri "string_to_search" Search the ri doc for the literal string_to_search
59
+ ri to_search Search the ri doc for to_search (without quote)
60
+ If to_search represents any object in your code
61
+ it looks for the obj.class documentation
62
+ e.g.: ri arr #=> (where arr=[]) ri doc for Array
63
+ ri "" #=> ri doc for String
64
+ ri obj.any_method Search the method.owner ri doc for of any_method
65
+ (no quotes needed, and completion available)
66
+ e.g.: ri "".eql? #=> ri doc for String#eql?
67
+ ri [].eql? #=> ri doc for Array#eql?
68
+ ri n Search the ri doc for the method n in a multiple
69
+ choices list
70
+ pri ... Like the above commands for `ri ...` but uses the
71
+ pager to show the result
72
72
 
73
73
  #{label(" Rails Commands ", :interactive_color) + IRT.dye(" (only available for Rails Apps)", :interactive_color, :bold)}
74
- rails_log_on Turn the rails log-in-console ON
75
- rlon|rlo Aliases for rails_log_on
76
- rails_log_off Turn the rails log-in-console OFF
77
- rloff|rlf Aliases for rails_log_off
74
+ rails_log_on Turn the rails log-in-console ON
75
+ rlon|rlo Aliases for rails_log_on
76
+ rails_log_off Turn the rails log-in-console OFF
77
+ rloff|rlf Aliases for rails_log_off
78
78
 
79
79
  #{label " Misc Commands ", :interactive_color}
80
- x|q Aliases for exit (from the current session)
81
- xx|qq Aliases for abort (abort the irt process)
82
- status|ss Prints the session status line
83
- run file Run an irt file (exiting from the current sessions)
84
- rerun|rr Reruns the current irt file (exiting from the
85
- current sessions)
86
- restart|rs Restart the executable, reload IRT (and Rails) and
87
- rerun the current file
88
- irt_help|hh Shows this screen
89
- sh command Alias for system("command") (no quotes needed)
90
- pager|pg string|block Uses the pager to show a long string or executes
91
- block and shows its captured stdout
80
+ x|q Aliases for exit (from the current session)
81
+ xx|qq Aliases for abort (abort the irt process)
82
+ status|ss Prints the session status line
83
+ run file Run an irt file (exiting from the current sessions)
84
+ rerun|rr Reruns the current irt file (exiting from the
85
+ current sessions)
86
+ restart|rs Restart the executable, reload IRT (and Rails) and
87
+ rerun the current file
88
+ irt_help|hh Shows this screen
89
+ sh command Alias for system("command") (no quotes needed)
90
+ pager|pg string|block Uses the pager to show a long string or executes
91
+ block and shows its captured stdout
92
92
 
93
93
  #{label " Session Directives ", :file_color}
94
- irt Opens an interactive session which retains the
95
- current variables and the last value (_)
96
- irt binding Opens a binding session at the line of the call
94
+ irt Opens an interactive session which retains the
95
+ current variables and the last value (_)
96
+ irt binding Opens a binding session at the line of the call
97
97
 
98
98
  #{label(" Test Directives ", :file_color) + IRT.dye(" (auto added by the Test Commands)", :file_color, :bold)}
99
- desc description Adds a description to the next test
100
- _eql? val Runs a test checking _ == val
101
- _yaml_eql? yaml_dump Runs a test checking y _ == yaml_dump
99
+ desc description Adds a description to the next test
100
+ _eql? val Runs a test checking _ == val
101
+ _yaml_eql? yaml_dump Runs a test checking y _ == yaml_dump
102
102
 
103
103
  #{label " Helper Directives ", :file_color}
104
- insert_file file Evaluates file as it were inserted at that line
105
- eval_file Alias for eval_file
106
- irt_at_exit block Ensures execution of block at exit (useful for
107
- cleanup of test env)
104
+ insert_file file Evaluates file as it were inserted at that line
105
+ eval_file Alias for eval_file
106
+ irt_at_exit block Ensures execution of block at exit (useful for
107
+ cleanup of test env)
108
108
 
109
109
  #{label " Extensions ", :log_color}
110
- Kernel#capture block Executes block and returns a string containing the
111
- captured stdout
112
- Object#own_methods Returns the methods implemented by the receiver
113
- itself (not inherited)
114
- Object#<editor> (<editor> can be 'vi', 'nano|nn', 'emacs|em')
115
- Yaml-dump the object in a tmp.yml file and opens it
116
- with <editor>. After your editing and save returns
117
- the evaluated yaml file
118
- e.g.: {:a => 2}.vi #=> {:an_edited => 'value'}
119
- Method#location When possible, it returns file and line where the
120
- method is defined. It is suitable to be passed to
121
- the in place editing commands.
122
- Method#info Returns useful info about the method. It is suitable
123
- to be passed to the in place editing commands.
110
+ Kernel#capture stream {} Executes block and returns a string containing the
111
+ captured str(eam).
112
+ Kernel#silence stream {} Alias for capture
113
+ Object#own_methods Returns the methods implemented by the receiver
114
+ itself (not inherited)
115
+ Object#<editor> (<editor> can be 'vi', 'nano|nn', 'emacs|em')
116
+ Yaml-dump the object in a tmp.yml file and opens it
117
+ with <editor>. After your editing and save returns
118
+ the evaluated yaml file
119
+ e.g.: {:a => 2}.vi #=> {:an_edited => 'value'}
120
+ Method#location When possible, it returns file and line where the
121
+ method is defined. It is suitable to be passed to
122
+ the in place editing commands.
123
+ Method#info Returns useful info about the method. It is suitable
124
+ to be passed to the in place editing commands.
124
125
  )
125
126
  end
126
127
  alias_method :hh, :irt_help
@@ -0,0 +1,39 @@
1
+ module IRB
2
+
3
+ def self.start_session(bind)
4
+ IRT.start
5
+ IRT::Session.enter :binding, bind
6
+ end
7
+
8
+ class Context
9
+ alias_method :evaluate_without_debugger, :evaluate
10
+ def evaluate(line, line_no)
11
+ $rdebug_irb_statements = line
12
+ evaluate_without_debugger line, line_no
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ module Kernel
19
+ alias_method :original_irt, :irt
20
+ def irt(bind=nil)
21
+ IRT.start
22
+ IRT::Commands::Core.irt(bind)
23
+ end
24
+ end
25
+
26
+ module IRT
27
+ module Session
28
+
29
+ private
30
+
31
+ def set_binding_file_pointers(context)
32
+ context.binding_file = Debugger.current_context.frame_file
33
+ context.binding_line_no = Debugger.current_context.frame_line
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+
@@ -1,14 +1,21 @@
1
1
  require 'stringio'
2
2
  module Kernel
3
3
 
4
- def capture
5
- out = StringIO.new
6
- $stdout = out
7
- yield
8
- return out.string
9
- ensure
10
- $stdout = STDOUT
4
+ # copied from ActiveRecord 3.1 because of conflicting name with previous IRT implementation
5
+ # modified in the argument default in order to be used by both AR and IRT
6
+ def capture(stream=:stdout)
7
+ begin
8
+ stream = stream.to_s
9
+ eval "$#{stream} = StringIO.new"
10
+ yield
11
+ result = eval("$#{stream}").string
12
+ ensure
13
+ eval("$#{stream} = #{stream.upcase}")
14
+ end
15
+
16
+ result
11
17
  end
18
+ alias :silence :capture
12
19
 
13
20
  def irt(bind)
14
21
  raise IRT::ArgumentTypeError, "You must pass binding instead of #{bind.class.name} object" unless bind.is_a?(Binding)
data/lib/irt.rb CHANGED
@@ -153,6 +153,12 @@ module IRT
153
153
 
154
154
  end
155
155
 
156
+ # before we patch irb
157
+ if defined?(Debugger)
158
+ require 'ruby-debug/command'
159
+ require 'ruby-debug/commands/irb'
160
+ end
161
+
156
162
  require 'irt/extensions/irb'
157
163
  require 'irb/completion'
158
164
  IRT.init_config
@@ -161,5 +167,6 @@ require 'irt/extensions/object'
161
167
  require 'irt/extensions/method'
162
168
  require 'irt/prompter'
163
169
  require 'irt/extensions/rails' if defined?(ActiveSupport::BufferedLogger)
170
+ require 'irt/extensions/debugger' if defined?(Debugger)
164
171
 
165
172
  end
metadata CHANGED
@@ -2,98 +2,101 @@
2
2
  name: irt
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.5
5
+ version: 1.2.6
6
6
  platform: ruby
7
7
  authors:
8
- - Domizio Demichelis
8
+ - Domizio Demichelis
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-27 00:00:00 Z
13
+ date: 2011-08-02 00:00:00 -04:00
14
+ default_executable:
14
15
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: differ
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.1.1
24
- type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: dye
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 0.1.3
35
- type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: prompter
39
- prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 0.1.4
46
- type: :runtime
47
- version_requirements: *id003
16
+ - !ruby/object:Gem::Dependency
17
+ name: differ
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.1.1
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: dye
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.1.3
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: prompter
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.1.4
47
+ type: :runtime
48
+ version_requirements: *id003
48
49
  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.
49
50
  email: dd.nexus@gmail.com
50
51
  executables:
51
- - irt
52
- - irt_irb
53
- - irt_rails2
52
+ - irt
53
+ - irt_irb
54
+ - irt_rails2
54
55
  extensions: []
55
56
 
56
57
  extra_rdoc_files:
57
- - README.markdown
58
+ - README.markdown
58
59
  files:
59
- - .gitignore
60
- - LICENSE
61
- - README.markdown
62
- - Rakefile
63
- - VERSION
64
- - bin/irt
65
- - bin/irt_irb
66
- - bin/irt_rails2
67
- - goodies/nano/README
68
- - goodies/nano/irt.nanorc
69
- - goodies/vi/README
70
- - irt.gemspec
71
- - irtrc
72
- - lib/irt.rb
73
- - lib/irt/commands/core.rb
74
- - lib/irt/commands/edit.rb
75
- - lib/irt/commands/help.rb
76
- - lib/irt/commands/log.rb
77
- - lib/irt/commands/ri.rb
78
- - lib/irt/commands/test.rb
79
- - lib/irt/differ.rb
80
- - lib/irt/directives.rb
81
- - lib/irt/directives/test.rb
82
- - lib/irt/extensions/irb.rb
83
- - lib/irt/extensions/irb/commands.rb
84
- - lib/irt/extensions/irb/context.rb
85
- - lib/irt/extensions/kernel.rb
86
- - lib/irt/extensions/method.rb
87
- - lib/irt/extensions/object.rb
88
- - lib/irt/extensions/rails.rb
89
- - lib/irt/history.rb
90
- - lib/irt/hunks.rb
91
- - lib/irt/init.rb
92
- - lib/irt/log.rb
93
- - lib/irt/prompter.rb
94
- - lib/irt/ruby_version.rb
95
- - lib/irt/session.rb
96
- - lib/irt/utils.rb
60
+ - .gitignore
61
+ - LICENSE
62
+ - README.markdown
63
+ - Rakefile
64
+ - VERSION
65
+ - bin/irt
66
+ - bin/irt_irb
67
+ - bin/irt_rails2
68
+ - goodies/nano/README
69
+ - goodies/nano/irt.nanorc
70
+ - goodies/vi/README
71
+ - irt.gemspec
72
+ - irtrc
73
+ - lib/irt.rb
74
+ - lib/irt/commands/core.rb
75
+ - lib/irt/commands/edit.rb
76
+ - lib/irt/commands/help.rb
77
+ - lib/irt/commands/log.rb
78
+ - lib/irt/commands/ri.rb
79
+ - lib/irt/commands/test.rb
80
+ - lib/irt/differ.rb
81
+ - lib/irt/directives.rb
82
+ - lib/irt/directives/test.rb
83
+ - lib/irt/extensions/debugger.rb
84
+ - lib/irt/extensions/irb.rb
85
+ - lib/irt/extensions/irb/commands.rb
86
+ - lib/irt/extensions/irb/context.rb
87
+ - lib/irt/extensions/kernel.rb
88
+ - lib/irt/extensions/method.rb
89
+ - lib/irt/extensions/object.rb
90
+ - lib/irt/extensions/rails.rb
91
+ - lib/irt/history.rb
92
+ - lib/irt/hunks.rb
93
+ - lib/irt/init.rb
94
+ - lib/irt/log.rb
95
+ - lib/irt/prompter.rb
96
+ - lib/irt/ruby_version.rb
97
+ - lib/irt/session.rb
98
+ - lib/irt/utils.rb
99
+ has_rdoc: true
97
100
  homepage: http://github.com/ddnexus/irt
98
101
  licenses: []
99
102
 
@@ -121,28 +124,27 @@ post_install_message: |+
121
124
  ________________________________________________________________________________
122
125
 
123
126
  rdoc_options:
124
- - --charset=UTF-8
127
+ - --charset=UTF-8
125
128
  require_paths:
126
- - lib
129
+ - lib
127
130
  required_ruby_version: !ruby/object:Gem::Requirement
128
131
  none: false
129
132
  requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: "0"
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "0"
133
136
  required_rubygems_version: !ruby/object:Gem::Requirement
134
137
  none: false
135
138
  requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 1.3.6
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 1.3.6
139
142
  requirements: []
140
143
 
141
144
  rubyforge_project:
142
- rubygems_version: 1.7.2
145
+ rubygems_version: 1.5.0
143
146
  signing_key:
144
147
  specification_version: 3
145
148
  summary: Interactive Ruby Tools - Very improved irb and Rails Console with a lot of cool features.
146
149
  test_files: []
147
150
 
148
- has_rdoc: