pry 0.6.7-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,83 @@
1
+ 4/3/2011 version 0.6.7
2
+ * color support
3
+ * --simple-prompt for pry commandline
4
+ * -I mode for pry commandline
5
+ * --color mode for pry commandline
6
+ * clean up requires (put them all in one place)
7
+ * simple-prompt command and toggle-color commandd.
8
+
9
+ 28/2/2011 version 0.6.3
10
+ * Using MethodSource 0.3.4 so 1.8 show-method support provided
11
+ * `Set` class added to list of classes that are inspected
12
+
13
+ 26/2/2011 version 0.6.1
14
+ * !@ command alias for exit_all
15
+ * `cd /` for breaking out to pry top level (jump-to 0)
16
+ * made `-e` option work in a more effective way for `pry` command line invocation
17
+ * exit and exit-all commands now accept a parameter, this parameter becomes the return value of repl()
18
+ * `command` method from CommandBase now accepts a :keep_retval arg that determines if command value is returned to pry session or just `nil` (`nil` was old behaviour)
19
+ * tests for new :keep_retval and exit-all/exit behaviour; :keep_retval will remain undocumented.
20
+
21
+ 22/2/2011 version 0.5.8
22
+ * Added -c (context) option to show-doc, show-methods and eval-file
23
+ * Fixed up ordering issue of -c and -r parameters to command line pry
24
+
25
+ 21/2/2011 version 0.5.7
26
+ * Added pry executable, auto-loads .pryrc in user's home directory, if it
27
+ exists.
28
+
29
+ 19/2/2011 version 0.5.5
30
+ * Added Pry.run_command
31
+ * More useful error messages
32
+ * Easter eggs (game and cohen-poem)
33
+
34
+ 17/2/2011 version 0.5.0
35
+ * Use clipped version of Pry.view() for large objects
36
+ * Exit Pry session on ^d
37
+ * Use Shellwords for breaking up parameters to pry commands
38
+ * Use OptionParser to parse options for default pry commands
39
+ * Add version command
40
+ * Refactor 'status' command: add current method info
41
+ * Add meth_name_from_binding utility lambda to commands.rb
42
+ * Add -M, -m, -v(erbose), -a(ll), -s(uper), -l(ocals), -i(ivars), -k(klass
43
+ vars), etc options to ls
44
+ * add -M(instance method) options to show-method and show-doc
45
+ * add --help option to most commands
46
+ * Get rid of ls_method and ls_imethods (subsumed by more powerful ls)
47
+ * Get rid of show_idoc and show_imethod
48
+ * Add special eval-file command that evals target file in current context
49
+
50
+ 27/1/2011 version 0.4.5
51
+ * fixed show_method (though fragile as it references __binding_impl__
52
+ directly, making a name change to that method difficult
53
+ 27/1/2011 version 0.4.4
54
+ * oops, added examples/ directory
55
+ 26/1/2011 version 0.4.3
56
+ * added alias_command and desc methods to Pry::CommandBase
57
+ * changed behaviour of ls_methods and ls_imethods to return sorted lists
58
+ of methods
59
+ 23/1/2011 version 0.4.1
60
+ * made it so a 'def meth;end' in an object Pry session defines singleton
61
+ methods, not methods on the class (except in the case of
62
+ immediates)
63
+ * reorganized documentation, moving customization to a separate wiki file
64
+ * storing wiki in a nested git repo, as github wiki pages have their own
65
+ repo
66
+ * added more tests for new method definition behaviour
67
+ 21/1/2011 version 0.4.0
68
+ * added command API
69
+ * added many new commands, i.e ls_methods and friends
70
+ * modified other commands
71
+ * now accepts greater customization, can modify: input, output, hooks,
72
+ prompt, print object
73
+ * added tab completion (even completes commands)
74
+ * added extensive tests
75
+ * added examples
76
+ * many more changes
77
+ 9/12/2010 version 0.1.3
78
+ * Got rid of rubygems dependency, refactored some code.
79
+ 8/12/2010 version 0.1.2
80
+ * now rescuing SyntaxError as well as Racc::Parser error in valid_expression?
81
+ 8/12/2010 version 0.1.0
82
+ * release!
83
+
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2011 John Mair (banisterfiend)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,312 @@
1
+ Pry
2
+ =============
3
+
4
+ (C) John Mair (banisterfiend) 2011
5
+
6
+ _attach an irb-like session to any object at runtime_
7
+
8
+ Pry is a simple Ruby REPL (Read-Eval-Print-Loop) that specializes in the interactive
9
+ manipulation of objects during the running of a program.
10
+
11
+ In some sense it is the opposite of IRB in that you bring a REPL
12
+ session to your code (with Pry) instead of bringing your code to a
13
+ REPL session (as with IRB).
14
+
15
+ It is not based on the IRB codebase, and implements some unique REPL
16
+ commands such as `show-method`, `show-doc`, `ls` and `cd` (type `help`
17
+ to get a full list).
18
+
19
+ Pry is also fairly flexible and allows significant user
20
+ [customization](http://rdoc.info/github/banister/pry/master/file/wiki/Customizing-pry.md). It
21
+ is trivial to set it to read from any object that has a `readline` method and write to any object that has a
22
+ `puts` method - many other aspects of Pry are also configurable making
23
+ it a good choice for implementing custom shells.
24
+
25
+ Pry now comes with an executable so it can be invoked at the command line.
26
+ Just enter `pry` to start. A `.pryrc` file in the user's home directory will
27
+ be loaded if it exists. Type `pry --help` at the command line for more information.
28
+
29
+ * Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
30
+ * Read the [documentation](http://rdoc.info/github/banister/pry/master/file/README.markdown)
31
+ * See the [source code](http://github.com/banister/pry)
32
+
33
+ Pry also has `rubygems-test` support; to participate, first install
34
+ Pry, then:
35
+
36
+ 1. Install rubygems-test: `gem install rubygems-test`
37
+ 2. Run the test: `gem test pry`
38
+ 3. Finally choose 'Yes' to upload the results.
39
+
40
+ Example: Interacting with an object at runtime
41
+ ---------------------------------------
42
+
43
+ With the `Object#pry` method we can pry (open an irb-like session) on
44
+ an object. In the example below we open a Pry session for the `Test` class and execute a method and add
45
+ an instance variable. The current thread is halted for the duration of the session.
46
+
47
+ require 'pry'
48
+
49
+ class Test
50
+ def self.hello() "hello world" end
51
+ end
52
+
53
+ Test.pry
54
+
55
+ # Pry session begins on stdin
56
+ Beginning Pry session for Test
57
+ pry(Test)> self
58
+ => Test
59
+ pry(Test)> hello
60
+ => "hello world"
61
+ pry(Test)> @y = 20
62
+ => 20
63
+ pry(Test)> exit
64
+ Ending Pry session for Test
65
+
66
+ # program resumes here
67
+
68
+ If we now inspect the `Test` object we can see our changes have had
69
+ effect:
70
+
71
+ Test.instance_variable_get(:@y) #=> 20
72
+
73
+ ### Alternative Syntax
74
+
75
+ You can also use the `Pry.start(obj)` or `pry(obj)` syntax to start a pry session on
76
+ `obj`. e.g
77
+
78
+ Pry.start(5)
79
+ Beginning Pry session for 5
80
+ pry(5)>
81
+
82
+ OR
83
+
84
+ pry(6)
85
+ beginning Pry session for 6
86
+ pry(6)>
87
+
88
+ Example: Pry sessions can nest
89
+ -----------------------------------------------
90
+
91
+ Here we will begin Pry at top-level, then pry on a class and then on
92
+ an instance variable inside that class:
93
+
94
+ # Pry.start() without parameters begins a Pry session on top-level (main)
95
+ Pry.start
96
+ Beginning Pry session for main
97
+ pry(main)> class Hello
98
+ pry(main)* @x = 20
99
+ pry(main)* end
100
+ => 20
101
+ pry(main)> cd Hello
102
+ Beginning Pry session for Hello
103
+ pry(Hello):1> instance_variables
104
+ => [:@x]
105
+ pry(Hello):1> cd @x
106
+ Beginning Pry session for 20
107
+ pry(20:2)> self + 10
108
+ => 30
109
+ pry(20:2)> cd ..
110
+ Ending Pry session for 20
111
+ pry(Hello):1> cd ..
112
+ Ending Pry session for Hello
113
+ pry(main)> cd ..
114
+ Ending Pry session for main
115
+
116
+ The number after the `:` in the pry prompt indicates the nesting
117
+ level. To display more information about nesting, use the `nesting`
118
+ command. E.g
119
+
120
+ pry("friend":3)> nesting
121
+ Nesting status:
122
+ 0. main (Pry top level)
123
+ 1. Hello
124
+ 2. 100
125
+ 3. "friend"
126
+ => nil
127
+
128
+ We can then jump back to any of the previous nesting levels by using
129
+ the `jump-to` command:
130
+
131
+ pry("friend":3)> jump-to 1
132
+ Ending Pry session for "friend"
133
+ Ending Pry session for 100
134
+ => 100
135
+ pry(Hello):1>
136
+
137
+ If we just want to go back one level of nesting we can of course
138
+ use the `quit` or `exit` or `back` commands.
139
+
140
+ To break out of all levels of Pry nesting and return immediately to the
141
+ calling process use `exit-all`:
142
+
143
+ pry("friend":3)> exit-all
144
+ Ending Pry session for "friend"
145
+ Ending Pry session for 100
146
+ Ending Pry session for Hello
147
+ Ending Pry session for main
148
+ => main
149
+
150
+ # program resumes here
151
+
152
+ Features and limitations
153
+ ------------------------
154
+
155
+ Pry is an irb-like clone with an emphasis on interactively examining
156
+ and manipulating objects during the running of a program.
157
+
158
+ Its primary utility is probably in debugging, though it may have other
159
+ uses (such as implementing a quake-like console for games, for example). Here is a
160
+ list of Pry's features along with some of its limitations given at the
161
+ end.
162
+
163
+ ###Features:
164
+
165
+ * Pry can be invoked at any time and on any object in the running program.
166
+ * Pry sessions can nest arbitrarily deeply -- to go back one level of nesting type 'exit' or 'quit' or 'back'
167
+ * Pry comes with syntax highlighting just use the `toggle-color` command to use it.
168
+ * Use `_` to recover last result.
169
+ * Use `_pry_` to reference the Pry instance managing the current session.
170
+ * Pry supports tab completion.
171
+ * Pry has multi-line support built in.
172
+ * Use `^d` (control-d) to quickly break out of a session.
173
+ * Pry has special commands not found in many other Ruby REPLs: `show-method`, `show-doc`
174
+ `jump-to`, `ls`, `cd`, `cat`
175
+ * Pry gives good control over nested sessions (important when exploring complicated runtime state)
176
+ * Pry is not based on the IRB codebase.
177
+ * Pry allows significant customizability.
178
+ * Pry uses the [method_source](https://github.com/banister/method_source) gem; so
179
+ this functionality is available to a Pry session.
180
+ * Pry uses [RubyParser](https://github.com/seattlerb/ruby_parser) to
181
+ validate expressions in 1.8, and [Ripper](http://rdoc.info/docs/ruby-core/1.9.2/Ripper) for 1.9.
182
+ * Pry implements all the methods in the REPL chain separately: `Pry#r`
183
+ for reading; `Pry#re` for eval; `Pry#rep` for printing; and `Pry#repl`
184
+ for the loop (`Pry.start` simply wraps `Pry.new.repl`). You can
185
+ invoke any of these methods directly depending on exactly what aspect of the functionality you need.
186
+
187
+ ###Limitations:
188
+
189
+ * Some Pry commands (e.g `show-command`) do not work in Ruby 1.8.
190
+ * `method_source` functionality does not work in JRuby.
191
+ * 1.9 support requires `Ripper` - some implementations may not support this.
192
+
193
+ Commands
194
+ -----------
195
+
196
+ ### The Pry API:
197
+
198
+ * `Pry.start()` Starts a Read-Eval-Print-Loop on the object it
199
+ receives as a parameter. In the case of no parameter it operates on
200
+ top-level (main). It can receive any object or a `Binding`
201
+ object as parameter. `Pry.start()` is implemented as `Pry.new.repl()`
202
+ * `obj.pry` and `pry(obj)` may also be used as alternative syntax to
203
+ `Pry.start(obj)`.
204
+
205
+ However there are some differences. `obj.pry` opens
206
+ a Pry session on the receiver whereas `Pry.start` (with no parameter)
207
+ will start a Pry session on top-level. The other form of the `pry`
208
+ method: `pry(obj)` will also start a Pry session on its parameter.
209
+
210
+ The `pry` method invoked by itself, with no explict receiver and no
211
+ parameter will start a Pry session on the implied receiver. It is
212
+ perhaps more useful to invoke it in this form `pry(binding)` or
213
+ `binding.pry` so as to get access to locals in the current context.
214
+
215
+ Another difference is that `Pry.start()` accepts a second parameter
216
+ that is a hash of configuration options (discussed further, below).
217
+
218
+ * If, for some reason you do not want to 'loop' then use `Pry.new.rep()`; it
219
+ only performs the Read-Eval-Print section of the REPL - it ends the
220
+ session after just one line of input. It takes the same parameters as
221
+ `Pry#repl()`
222
+ * Likewise `Pry#re()` only performs the Read-Eval section of the REPL,
223
+ it returns the result of the evaluation or an Exception object in
224
+ case of error. It also takes the same parameters as `Pry#repl()`
225
+ * Similarly `Pry#r()` only performs the Read section of the REPL, only
226
+ returning the Ruby expression (as a string). It takes the same parameters as all the others.
227
+ * `Pry.run_command COMMAND` enables you to invoke Pry commands outside
228
+ of a session, e.g `Pry.run_command "ls -m", :context => MyObject`. See
229
+ docs for more info.
230
+
231
+ ### Session commands
232
+
233
+ Pry supports a few commands inside the session itself. These commands are
234
+ not methods and must start at the beginning of a line, with no
235
+ whitespace in between.
236
+
237
+ If you want to access a method of the same name, prefix the invocation by whitespace.
238
+
239
+ * Typing `!` on a line by itself will clear the input buffer - useful for
240
+ getting you out of a situation where the parsing process
241
+ goes wrong and you get stuck in an endless read loop.
242
+ * `status` shows status information about the current session.
243
+ * `version` Show Pry version information
244
+ * `help` shows the list of session commands with brief explanations.
245
+ * `toggle-color` turns on and off syntax highlighting.
246
+ * `simple-prompt` toggles the simple prompt mode.
247
+ * `exit` or `quit` or `back` or `^d` (control-d) will end the current Pry session and go
248
+ back to the calling process or back one level of nesting (if there
249
+ are nested sessions).
250
+ * `ls [OPTIONS] [VAR]` returns a list of local variables, instance variables, and
251
+ methods, etc. Highly flexible. See `ls --help` for more info.
252
+ * `cat VAR` Calls `inspect` on `VAR`
253
+ * `cd VAR` Starts a `Pry` session on the variable VAR. E.g `cd @x`
254
+ (use `cd ..` to go back).
255
+ * `show-method [OPTIONS] METH` Displays the sourcecode for the method
256
+ `METH`. e.g `show-method hello`. See `show-method --help` for more info.
257
+ * `show-doc [OPTIONS] METH` Displays comments for `METH`. See `show-doc
258
+ --help` for more info.
259
+ * `show-command COMMAND` Displays the sourcecode for the given Pry
260
+ command. e.g: `show-command cd`
261
+ * `jump-to NEST_LEVEL` Unwinds the Pry stack (nesting level) until the appropriate nesting level is reached.
262
+ * `exit-all` breaks out of all Pry nesting levels and returns to the
263
+ calling process.
264
+ * You can type `Pry.start(obj)` or `obj.pry` to nest another Pry session within the
265
+ current one with `obj` as the receiver of the new session. Very useful
266
+ when exploring large or complicated runtime state.
267
+
268
+ Bindings and objects
269
+ --------------------
270
+
271
+ Pry ultimately operates on `Binding` objects. If you invoke Pry with a
272
+ Binding object it uses that Binding. If you invoke Pry with anything
273
+ other than a `Binding`, Pry will generate a Binding for that
274
+ object and use that.
275
+
276
+ If you want to open a Pry session on the current context and capture
277
+ the locals you should use: `binding.pry`. If you do not care about
278
+ capturing the locals you can simply use `pry` (which will generate a
279
+ fresh `Binding` for the receiver).
280
+
281
+ Top-level is a special case; you can start a Pry session on top-level
282
+ *and* capture locals by simply using: `pry`. This is because Pry
283
+ automatically uses `TOPLEVEL_BINDING` for the top-level object (main).
284
+
285
+ Example Programs
286
+ ----------------
287
+
288
+ Pry comes bundled with a few example programs to illustrate some
289
+ features, see the `examples/` directory.
290
+
291
+ * `example_basic.rb` - Demonstrate basic Pry functionality
292
+ * `example_input.rb` - Demonstrates how to set the `input` object.
293
+ * `example_output.rb` - Demonstrates how to set the `output` object.
294
+ * `example_hooks.rb` - Demonstrates how to set the `hooks` hash.
295
+ * `example_print.rb` - Demonstrates how to set the `print` object.
296
+ * `example_prompt.rb` - Demonstrates how to set the `prompt`.
297
+ * `example_input2.rb` - An advanced `input` example.
298
+ * `example_commands.rb` - Implementing a mathematical command set.
299
+ * `example_commands_override.rb` - An advanced `commands` example.
300
+ * `example_image_edit.rb` - A simple image editor using a Pry REPL (requires `Gosu` and `TexPlay` gems).
301
+
302
+ Customizing Pry
303
+ ---------------
304
+
305
+ Pry allows a large degree of customization.
306
+
307
+ [Read how to customize Pry here.](http://rdoc.info/github/banister/pry/master/file/wiki/Customizing-pry.md)
308
+
309
+ Contact
310
+ -------
311
+
312
+ Problems or questions contact me at [github](http://github.com/banister)
@@ -0,0 +1,103 @@
1
+ dlext = Config::CONFIG['DLEXT']
2
+ direc = File.dirname(__FILE__)
3
+
4
+ require 'rake/clean'
5
+ require 'rake/gempackagetask'
6
+ require "#{direc}/lib/pry/version"
7
+
8
+ CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
9
+ CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
10
+ "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
11
+ "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
12
+
13
+ def apply_spec_defaults(s)
14
+ s.name = "pry"
15
+ s.summary = "attach an irb-like session to any object at runtime"
16
+ s.version = Pry::VERSION
17
+ s.date = Time.now.strftime '%Y-%m-%d'
18
+ s.author = "John Mair (banisterfiend)"
19
+ s.email = 'jrmair@gmail.com'
20
+ s.description = s.summary
21
+ s.require_path = 'lib'
22
+ s.add_dependency("ruby_parser",">=2.0.5")
23
+ s.add_dependency("coderay",">=0.9.7")
24
+ s.add_development_dependency("bacon",">=1.1.0")
25
+ s.homepage = "http://banisterfiend.wordpress.com"
26
+ s.has_rdoc = 'yard'
27
+ s.executables = ["pry"]
28
+ s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb", "examples/**/*.rb",
29
+ "test/*.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"]
30
+ end
31
+
32
+ task :test do
33
+ sh "bacon -k #{direc}/test/test.rb"
34
+ end
35
+
36
+ desc "run pry"
37
+ task :pry do
38
+ require "#{direc}/lib/pry.rb"
39
+ Pry.start
40
+ end
41
+
42
+ desc "show pry version"
43
+ task :version do
44
+ puts "Pry version: #{Pry::VERSION}"
45
+ end
46
+
47
+ namespace :ruby do
48
+ spec = Gem::Specification.new do |s|
49
+ apply_spec_defaults(s)
50
+ s.add_dependency("method_source",">=0.3.4")
51
+ s.platform = Gem::Platform::RUBY
52
+ end
53
+
54
+ Rake::GemPackageTask.new(spec) do |pkg|
55
+ pkg.need_zip = false
56
+ pkg.need_tar = false
57
+ end
58
+ end
59
+
60
+ [:mingw32, :mswin32].each do |v|
61
+ namespace v do
62
+ spec = Gem::Specification.new do |s|
63
+ apply_spec_defaults(s)
64
+ s.add_dependency("method_source",">=0.3.4")
65
+ s.add_dependency("win32console", ">=1.3.0")
66
+ s.platform = "i386-#{v}"
67
+ end
68
+
69
+ Rake::GemPackageTask.new(spec) do |pkg|
70
+ pkg.need_zip = false
71
+ pkg.need_tar = false
72
+ end
73
+ end
74
+ end
75
+
76
+ namespace :jruby do
77
+ spec = Gem::Specification.new do |s|
78
+ apply_spec_defaults(s)
79
+ s.add_dependency("method_source","=0.2.0")
80
+ s.platform = "java"
81
+ end
82
+
83
+ Rake::GemPackageTask.new(spec) do |pkg|
84
+ pkg.need_zip = false
85
+ pkg.need_tar = false
86
+ end
87
+ end
88
+
89
+
90
+ desc "build all platform gems at once"
91
+ task :gems => [:rmgems, "ruby:gem", "jruby:gem", "mswin32:gem", "mingw32:gem"]
92
+
93
+ desc "remove all platform gems"
94
+ task :rmgems => ["ruby:clobber_package"]
95
+
96
+ desc "build and push latest gems"
97
+ task :pushgems => :gems do
98
+ chdir("#{direc}/pkg") do
99
+ Dir["*.gem"].each do |gemfile|
100
+ sh "gem push #{gemfile}"
101
+ end
102
+ end
103
+ end