pry 0.10.pre.1-java → 0.10.0.pre2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +41 -35
  5. data/lib/pry.rb +82 -139
  6. data/lib/pry/cli.rb +77 -30
  7. data/lib/pry/code.rb +126 -182
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +71 -0
  10. data/lib/pry/code/loc.rb +92 -0
  11. data/lib/pry/code_object.rb +172 -0
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +184 -28
  14. data/lib/pry/command_set.rb +113 -59
  15. data/lib/pry/commands.rb +4 -27
  16. data/lib/pry/commands/amend_line.rb +99 -0
  17. data/lib/pry/commands/bang.rb +20 -0
  18. data/lib/pry/commands/bang_pry.rb +17 -0
  19. data/lib/pry/commands/cat.rb +62 -0
  20. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  21. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  22. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  23. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  24. data/lib/pry/commands/cd.rb +41 -0
  25. data/lib/pry/commands/change_inspector.rb +27 -0
  26. data/lib/pry/commands/change_prompt.rb +26 -0
  27. data/lib/pry/commands/code_collector.rb +165 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/disabled_commands.rb +2 -0
  30. data/lib/pry/commands/easter_eggs.rb +112 -0
  31. data/lib/pry/commands/edit.rb +195 -0
  32. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +23 -0
  37. data/lib/pry/commands/find_method.rb +193 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +32 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +101 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +180 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +53 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/list_inspectors.rb +35 -0
  50. data/lib/pry/commands/list_prompts.rb +35 -0
  51. data/lib/pry/commands/ls.rb +114 -0
  52. data/lib/pry/commands/ls/constants.rb +47 -0
  53. data/lib/pry/commands/ls/formatter.rb +49 -0
  54. data/lib/pry/commands/ls/globals.rb +48 -0
  55. data/lib/pry/commands/ls/grep.rb +21 -0
  56. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  57. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  58. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  59. data/lib/pry/commands/ls/local_names.rb +35 -0
  60. data/lib/pry/commands/ls/local_vars.rb +39 -0
  61. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  62. data/lib/pry/commands/ls/methods.rb +57 -0
  63. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  64. data/lib/pry/commands/ls/self_methods.rb +32 -0
  65. data/lib/pry/commands/nesting.rb +25 -0
  66. data/lib/pry/commands/play.rb +103 -0
  67. data/lib/pry/commands/pry_backtrace.rb +25 -0
  68. data/lib/pry/commands/pry_version.rb +17 -0
  69. data/lib/pry/commands/raise_up.rb +32 -0
  70. data/lib/pry/commands/reload_code.rb +62 -0
  71. data/lib/pry/commands/reset.rb +18 -0
  72. data/lib/pry/commands/ri.rb +60 -0
  73. data/lib/pry/commands/save_file.rb +61 -0
  74. data/lib/pry/commands/shell_command.rb +48 -0
  75. data/lib/pry/commands/shell_mode.rb +25 -0
  76. data/lib/pry/commands/show_doc.rb +83 -0
  77. data/lib/pry/commands/show_info.rb +195 -0
  78. data/lib/pry/commands/show_input.rb +17 -0
  79. data/lib/pry/commands/show_source.rb +50 -0
  80. data/lib/pry/commands/simple_prompt.rb +22 -0
  81. data/lib/pry/commands/stat.rb +40 -0
  82. data/lib/pry/commands/switch_to.rb +23 -0
  83. data/lib/pry/commands/toggle_color.rb +24 -0
  84. data/lib/pry/commands/watch_expression.rb +105 -0
  85. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  86. data/lib/pry/commands/whereami.rb +190 -0
  87. data/lib/pry/commands/wtf.rb +57 -0
  88. data/lib/pry/config.rb +20 -229
  89. data/lib/pry/config/behavior.rb +139 -0
  90. data/lib/pry/config/convenience.rb +26 -0
  91. data/lib/pry/config/default.rb +165 -0
  92. data/lib/pry/core_extensions.rb +59 -38
  93. data/lib/pry/editor.rb +133 -0
  94. data/lib/pry/exceptions.rb +77 -0
  95. data/lib/pry/helpers.rb +1 -0
  96. data/lib/pry/helpers/base_helpers.rb +40 -154
  97. data/lib/pry/helpers/command_helpers.rb +19 -130
  98. data/lib/pry/helpers/documentation_helpers.rb +21 -11
  99. data/lib/pry/helpers/table.rb +109 -0
  100. data/lib/pry/helpers/text.rb +8 -9
  101. data/lib/pry/history.rb +61 -45
  102. data/lib/pry/history_array.rb +11 -1
  103. data/lib/pry/hooks.rb +10 -32
  104. data/lib/pry/indent.rb +110 -38
  105. data/lib/pry/input_completer.rb +242 -0
  106. data/lib/pry/input_lock.rb +132 -0
  107. data/lib/pry/inspector.rb +27 -0
  108. data/lib/pry/last_exception.rb +61 -0
  109. data/lib/pry/method.rb +199 -200
  110. data/lib/pry/method/disowned.rb +53 -0
  111. data/lib/pry/method/patcher.rb +125 -0
  112. data/lib/pry/method/weird_method_locator.rb +186 -0
  113. data/lib/pry/module_candidate.rb +39 -33
  114. data/lib/pry/object_path.rb +82 -0
  115. data/lib/pry/output.rb +50 -0
  116. data/lib/pry/pager.rb +234 -0
  117. data/lib/pry/plugins.rb +4 -3
  118. data/lib/pry/prompt.rb +26 -0
  119. data/lib/pry/pry_class.rb +199 -227
  120. data/lib/pry/pry_instance.rb +344 -403
  121. data/lib/pry/rbx_path.rb +1 -1
  122. data/lib/pry/repl.rb +202 -0
  123. data/lib/pry/repl_file_loader.rb +20 -26
  124. data/lib/pry/rubygem.rb +82 -0
  125. data/lib/pry/terminal.rb +79 -0
  126. data/lib/pry/test/helper.rb +170 -0
  127. data/lib/pry/version.rb +1 -1
  128. data/lib/pry/wrapped_module.rb +133 -48
  129. metadata +132 -197
  130. data/.document +0 -2
  131. data/.gemtest +0 -0
  132. data/.gitignore +0 -16
  133. data/.travis.yml +0 -17
  134. data/.yardopts +0 -1
  135. data/CHANGELOG +0 -387
  136. data/CONTRIBUTORS +0 -36
  137. data/Gemfile +0 -2
  138. data/Rakefile +0 -137
  139. data/TODO +0 -117
  140. data/examples/example_basic.rb +0 -15
  141. data/examples/example_command_override.rb +0 -32
  142. data/examples/example_commands.rb +0 -36
  143. data/examples/example_hooks.rb +0 -9
  144. data/examples/example_image_edit.rb +0 -67
  145. data/examples/example_input.rb +0 -7
  146. data/examples/example_input2.rb +0 -29
  147. data/examples/example_output.rb +0 -11
  148. data/examples/example_print.rb +0 -6
  149. data/examples/example_prompt.rb +0 -9
  150. data/examples/helper.rb +0 -6
  151. data/lib/pry/completion.rb +0 -221
  152. data/lib/pry/custom_completions.rb +0 -6
  153. data/lib/pry/default_commands/cd.rb +0 -81
  154. data/lib/pry/default_commands/commands.rb +0 -62
  155. data/lib/pry/default_commands/context.rb +0 -98
  156. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  157. data/lib/pry/default_commands/editing.rb +0 -420
  158. data/lib/pry/default_commands/find_method.rb +0 -169
  159. data/lib/pry/default_commands/gems.rb +0 -84
  160. data/lib/pry/default_commands/gist.rb +0 -187
  161. data/lib/pry/default_commands/help.rb +0 -127
  162. data/lib/pry/default_commands/hist.rb +0 -120
  163. data/lib/pry/default_commands/input_and_output.rb +0 -306
  164. data/lib/pry/default_commands/introspection.rb +0 -410
  165. data/lib/pry/default_commands/ls.rb +0 -272
  166. data/lib/pry/default_commands/misc.rb +0 -38
  167. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  168. data/lib/pry/default_commands/whereami.rb +0 -92
  169. data/lib/pry/extended_commands/experimental.rb +0 -7
  170. data/lib/pry/rbx_method.rb +0 -13
  171. data/man/pry.1 +0 -195
  172. data/man/pry.1.html +0 -204
  173. data/man/pry.1.ronn +0 -141
  174. data/pry.gemspec +0 -46
  175. data/test/candidate_helper1.rb +0 -11
  176. data/test/candidate_helper2.rb +0 -8
  177. data/test/helper.rb +0 -223
  178. data/test/test_cli.rb +0 -78
  179. data/test/test_code.rb +0 -201
  180. data/test/test_command.rb +0 -712
  181. data/test/test_command_helpers.rb +0 -9
  182. data/test/test_command_integration.rb +0 -668
  183. data/test/test_command_set.rb +0 -610
  184. data/test/test_completion.rb +0 -62
  185. data/test/test_control_d_handler.rb +0 -45
  186. data/test/test_default_commands/example.erb +0 -5
  187. data/test/test_default_commands/test_cd.rb +0 -318
  188. data/test/test_default_commands/test_context.rb +0 -280
  189. data/test/test_default_commands/test_documentation.rb +0 -314
  190. data/test/test_default_commands/test_find_method.rb +0 -50
  191. data/test/test_default_commands/test_gems.rb +0 -18
  192. data/test/test_default_commands/test_help.rb +0 -57
  193. data/test/test_default_commands/test_input.rb +0 -428
  194. data/test/test_default_commands/test_introspection.rb +0 -511
  195. data/test/test_default_commands/test_ls.rb +0 -151
  196. data/test/test_default_commands/test_shell.rb +0 -343
  197. data/test/test_default_commands/test_show_source.rb +0 -432
  198. data/test/test_exception_whitelist.rb +0 -21
  199. data/test/test_history_array.rb +0 -65
  200. data/test/test_hooks.rb +0 -521
  201. data/test/test_indent.rb +0 -277
  202. data/test/test_input_stack.rb +0 -86
  203. data/test/test_method.rb +0 -401
  204. data/test/test_pry.rb +0 -463
  205. data/test/test_pry_defaults.rb +0 -419
  206. data/test/test_pry_history.rb +0 -84
  207. data/test/test_pry_output.rb +0 -41
  208. data/test/test_sticky_locals.rb +0 -155
  209. data/test/test_syntax_checking.rb +0 -65
  210. data/test/test_wrapped_module.rb +0 -174
  211. data/test/testrc +0 -2
  212. data/test/testrcbad +0 -2
  213. data/wiki/Customizing-pry.md +0 -397
  214. data/wiki/Home.md +0 -4
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source :rubygems
2
- gemspec
data/Rakefile DELETED
@@ -1,137 +0,0 @@
1
- require 'rake/clean'
2
- require 'rubygems/package_task'
3
-
4
- $:.unshift 'lib'
5
- require 'pry/version'
6
-
7
- CLOBBER.include('**/*~', '**/*#*', '**/*.log')
8
- CLEAN.include('**/*#*', '**/*#*.*', '**/*_flymake*.*', '**/*_flymake', '**/*.rbc', '**/.#*.*')
9
-
10
- def apply_spec_defaults(s)
11
- s.name = 'pry'
12
- s.summary = "An IRB alternative and runtime developer console"
13
- s.version = Pry::VERSION
14
- s.date = Time.now.strftime '%Y-%m-%d'
15
- s.authors = ["John Mair (banisterfiend)", "Conrad Irwin"]
16
- s.email = ['jrmair@gmail.com', 'conrad.irwin@gmail.com']
17
- s.description = s.summary
18
- s.homepage = 'http://pry.github.com'
19
- s.executables = ['pry']
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- test/*`.split("\n")
22
- s.add_dependency('coderay', '~> 1.0.5')
23
- s.add_dependency('slop', ['~> 3.3.1'])
24
- s.add_dependency('method_source','~> 0.8')
25
- s.add_development_dependency('bacon', '~> 1.1')
26
- s.add_development_dependency('open4', '~> 1.3')
27
- s.add_development_dependency('rake', '~> 0.9')
28
- end
29
-
30
- def check_dependencies
31
- require 'bundler'
32
- Bundler.definition.missing_specs
33
-
34
- eval('nil', TOPLEVEL_BINDING, '<main>') # workaround for issue #395
35
- rescue LoadError
36
- # if Bundler isn't installed, we'll just assume your setup is ok.
37
- rescue Bundler::GemNotFound
38
- raise RuntimeError, "You're missing one or more required gems. Run `bundle install` first."
39
- end
40
-
41
- desc "Set up and run tests"
42
- task :default => [:test]
43
-
44
- desc "Run tests"
45
- task :test do
46
- check_dependencies unless ENV['SKIP_DEP_CHECK']
47
- sh "bacon -Itest -rubygems -a -q"
48
- end
49
-
50
- desc "Run pry"
51
- task :pry do
52
- check_dependencies unless ENV['SKIP_DEP_CHECK']
53
- load 'bin/pry'
54
- end
55
-
56
- desc "Show pry version"
57
- task :version do
58
- puts "Pry version: #{Pry::VERSION}"
59
- end
60
-
61
- desc "Profile pry's startup time"
62
- task :profile do
63
- require 'profile'
64
- require 'pry'
65
- Pry.start(TOPLEVEL_BINDING, :input => StringIO.new('exit'))
66
- end
67
-
68
- desc "Build the gemspec file"
69
- task :gemspec => "ruby:gemspec"
70
-
71
- namespace :ruby do
72
- spec = Gem::Specification.new do |s|
73
- apply_spec_defaults(s)
74
- s.platform = Gem::Platform::RUBY
75
- end
76
-
77
- Gem::PackageTask.new(spec) do |pkg|
78
- pkg.need_zip = false
79
- pkg.need_tar = false
80
- end
81
-
82
- task :gemspec do
83
- File.open("#{spec.name}.gemspec", "w") do |f|
84
- f << spec.to_ruby
85
- end
86
- end
87
- end
88
-
89
- namespace :jruby do
90
- spec = Gem::Specification.new do |s|
91
- apply_spec_defaults(s)
92
- s.add_dependency('spoon', '~> 0.0')
93
- s.platform = 'java'
94
- end
95
-
96
- Gem::PackageTask.new(spec) do |pkg|
97
- pkg.need_zip = false
98
- pkg.need_tar = false
99
- end
100
- end
101
-
102
-
103
- [:mingw32, :mswin32].each do |v|
104
- namespace v do
105
- spec = Gem::Specification.new do |s|
106
- apply_spec_defaults(s)
107
- s.add_dependency('win32console', '~> 1.3')
108
- s.platform = "i386-#{v}"
109
- end
110
-
111
- Gem::PackageTask.new(spec) do |pkg|
112
- pkg.need_zip = false
113
- pkg.need_tar = false
114
- end
115
- end
116
- end
117
-
118
- desc "build all platform gems at once"
119
- task :gems => [:clean, :rmgems, 'ruby:gem', 'mswin32:gem', 'mingw32:gem', 'jruby:gem']
120
-
121
- desc "remove all platform gems"
122
- task :rmgems => ['ruby:clobber_package']
123
-
124
- desc "reinstall gem"
125
- task :reinstall => :gems do
126
- sh "gem uninstall pry" rescue nil
127
- sh "gem install #{File.dirname(__FILE__)}/pkg/pry-#{Pry::VERSION}.gem"
128
- end
129
-
130
- desc "build and push latest gems"
131
- task :pushgems => :gems do
132
- chdir("#{File.dirname(__FILE__)}/pkg") do
133
- Dir["*.gem"].each do |gemfile|
134
- sh "gem push #{gemfile}"
135
- end
136
- end
137
- end
data/TODO DELETED
@@ -1,117 +0,0 @@
1
- 0.9.5
2
- * include method visiblity in show-doc and stat output
3
- * tempfile should end in .rb (for edit -t)
4
- * ls output should not be in array format
5
- * exceptions should allow access to previous items in the backtrace
6
- * input should allow multiple objects which are switched to automatically when EOF is reached on the preceding one
7
- * pry -r should happen in pry
8
- * more plugin-related commands in pry - see installed ones, see activated ones, see available on rubygems
9
- * should also allow plugins be explicitly activated as a command line option
10
- * should not raise if plugin activation fails (should show warning instead)
11
- * more documentation on CommandContext, etc and also command helpers
12
- * fix history saving (should not save all of Readline::HISTORY, but only what changed)
13
- * prevent blank lines going to Readline::HISTORY
14
- * ensure that cat --ex emulates the `whereami` format - includes line numbers and formatted the same, etc
15
- * rename inp and out to _inp_ and _out_ otherwise than can overwrite locals by those names when debugging (not good)
16
- * add source file to stat command
17
- * make plugins use hash instead of array
18
- * ensure edit -t has 'edit' alias (no parameters) and dumps eval_string into buffer
19
- * whitelist exceptions
20
- * hooks system
21
- * jruby shell command support
22
-
23
- 0.9.3
24
- * hist command now excludes last line of input (the command invocation itself)
25
- * hist now has `history` alias
26
- * `pry -r` requires now happen after plugin loading (so as not to interfere with
27
- * new Pry.config.disable_auto_reload option, for turning off auto reloading by edit-method and related
28
- * add better error messages for `cd` command
29
- * add command_prefix
30
- * change some command names to include hyphen, e.g version => pry-version, install => install-command
31
- * do cat --ex and edit --ex
32
- * add reload-method
33
- * fixed exotic object regression - BasicObject.new etc now return "=> unknown"
34
- * converted: import => import-set, version => pry-version, install => install-command
35
- * fix show-doc bug for ruby 1.8 and Kernel.fork
36
- * edit -t (opens a temporary file and evals it in current context when closed)
37
-
38
- 0.9.0
39
- Major features
40
- --------------
41
- * Restructure command system and helpers (almost complete)
42
- * Delete unnecessary commands, add a couple of new ones (e.g amend-line)
43
- * Readline history
44
- * Plugin support
45
- * Support Rubinius core methods
46
- * in[] and out[] arrays
47
- * Improve test coverage (test some commands, etc)
48
-
49
- Minor changes
50
- -------------
51
- * improve edit-method support for various editors
52
- * ensure all commands have appropriate error handing and informative error messages
53
- * show-doc should include signature of method
54
-
55
- Optional
56
- --------
57
- * multi-line readline support
58
-
59
-
60
- 0.8.0
61
- * allow #{} interpolation of all commands
62
- * update documentation! new commands and features and change in behaviour of `run`
63
- * add ; at end of line to suppress return value output
64
- * Remove message spam (before/after hooks)
65
- * stop commands returning a value
66
- * use `redo` in the r() method when encounter a command
67
- * shell functionality should just use system(), but redirect in and
68
- out to Pry.input and Pry.output by reassining $stdin and $stdout
69
- for duration of block.
70
- * basicobject and no to_s/inspect support
71
- * fix documentation, support rdoc and yard properly
72
- * only load Ripper if 1.9 AND MRI (support jruby 1.9, using
73
- RubyParser)
74
- * shell commands invokable file .<command>
75
- * supercharge cat-file so it can syntax highlight sourcecode files
76
-
77
-
78
- 0.7.0
79
- * add pry-doc support with syntax highlighting for docs
80
- * add 'mj' option to ls (restrict to singleton methods)
81
- * add _ex_ local to hold last exception raised in an exception
82
-
83
- 0.6.8
84
- * add whereami command, a la the `ir_b` gem
85
- * make .pryrc be loaded by run-time pry sessions
86
-
87
- 0.6.7
88
- * color support
89
- * --simple-prompt for pry commandline
90
- * -I mode for pry commandline
91
- * --color mode for pry commandline
92
- * clean up requires (put them all in one place)
93
- * simple-prompt command and toggle-color commandd.
94
-
95
- 0.6.1
96
- * !@ command alias for exit_all
97
- * `cd /` for breaking out to pry top level (jump-to 0)
98
- * made `-e` option work in a more effective way for `pry` command line invocation
99
- * exit and exit-all commands now accept a parameter, this parameter becomes the return value of repl()
100
- * `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)
101
- * tests for new :keep_retval and exit-all/exit behaviour; :keep_retval will remain undocumented.
102
-
103
- 0.5.0 release:
104
- * !!!! UPDATE DOCUMENTATION !!!!
105
- * Use clipped version of Pry.view() for large objects
106
- * Exit Pry session on ^d
107
- * Use Shellwords for breaking up parameters to pry commands
108
- * Use OptionParser to parse options for default pry commands
109
- * Add version command
110
- * Refactor 'status' command: add current method info
111
- * Add meth_name_from_binding utility lambda to commands.rb
112
- * Add -M, -m, -v(erbose), -a(ll), -s(uper), -l(ocals), -i(ivars), -k(klass vars) options to ls
113
- * add -i(nstance) option to show-method
114
- * add --help option to most commands
115
- * Get rid of ls_method and ls_imethods (subsumed by more powerful ls)
116
- * Get rid of show_idoc and show_imethod
117
- * Add special eval-file command that evals target file in current context
@@ -1,15 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # define a local.
4
- a = "a local variable"
5
-
6
- # defing a top-level method.
7
- def hello
8
- puts "hello world!"
9
- end
10
-
11
- # Start pry session at top-level.
12
- # The local variable `a` and the `hello` method will
13
- # be accessible.
14
- puts __LINE__
15
- binding.pry
@@ -1,32 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Inherit standard command set, but tweak them by importing some and
4
- # overriding others.
5
- # Illustrates use of `command`, `run`, and `import_from` commands.
6
- class MyCommands < Pry::CommandBase
7
-
8
- # Override ls command
9
- command "ls", "An unhelpful ls" do
10
- output.puts "No, i refuse to display any useful information."
11
- end
12
-
13
- # bring in just the status command from Pry::Commands
14
- import_from Pry::Commands, "status"
15
-
16
- # analogy to Ruby's native alias_method idiom for decorating a method
17
- alias_command "old_status", "status"
18
-
19
- # Invoke one command from within another using `run`
20
- command "status", "Modified status." do |x|
21
- output.puts "About to show status, are you ready?"
22
- run "old_status", x
23
- output.puts "Finished showing status."
24
- end
25
-
26
- # bring in a few other commands
27
- import_from Pry::Commands, "quit", "show-method"
28
- end
29
-
30
- # Start a Pry session using the commands defined in MyCommands
31
- # Type 'help' in Pry to get a list of the commands and their descriptions
32
- Pry.start(TOPLEVEL_BINDING, :commands => MyCommands)
@@ -1,36 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- class MathCommands < Pry::CommandBase
4
- command "greet", "Greet a person, e.g: greet john" do |name|
5
- output.puts "Good afternoon #{name.capitalize}! Do you like Math?"
6
- end
7
-
8
- command "add", "Add a list of numbers together, e.g: add 1 2 3 4" do |*args|
9
- output.puts "Total: #{args.map(&:to_f).inject(&:+)}"
10
- end
11
-
12
- command "multiply", "Multiply a list of numbers together, e.g: multiply 1 2 3 4" do |*args|
13
- output.puts "Total: #{args.map(&:to_f).inject(&:*)}"
14
- end
15
-
16
- # Explicitly giving a description of "" to prevent command being
17
- # displayed in 'help'
18
- command "exit", "" do
19
- throw :breakout, 0
20
- end
21
-
22
- # Bring in the "!" method from Pry::Commands
23
- import_from Pry::Commands, "!"
24
- end
25
-
26
- # Since we provide math commands, let's have mathematical
27
- # before_session and after_session hooks, and a mathematical prompt
28
- math_prompt = [proc { "math> " }, proc { "math* " }]
29
- math_hooks = {
30
- :before_session => proc { |output, *| output.puts "Welcome! Let's do some math! Type 'help' for a list of commands." },
31
- :after_session => proc { |output, *| output.puts "Goodbye!" }
32
- }
33
-
34
- # Start a Pry session using the commands defined in MyCommands
35
- # Type 'help' in Pry to get a list of the commands and their descriptions
36
- Pry.start(TOPLEVEL_BINDING, :commands => MathCommands, :prompt => math_prompt, :hooks => math_hooks)
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- my_hooks = {
4
- :before_session => proc { |out, target| out.puts "Opening #{target.eval('self')}." },
5
- :after_session => proc { |out, target| out.puts "Closing #{target.eval('self')}." }
6
- }
7
-
8
- # Start a Pry session using the hooks hash defined in my_hooks
9
- Pry.start(TOPLEVEL_BINDING, :hooks => my_hooks)
@@ -1,67 +0,0 @@
1
- # Note: this requires you to have Gosu and TexPlay installed.
2
- # `gem install gosu`
3
- # `gem install texplay`
4
- #
5
- # Extra instructions for installing Gosu on Linux can be found here:
6
- # http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
7
- #
8
- # Instructions for using TexPlay can be found here:
9
- # http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
10
- #
11
- # Have fun! :)
12
-
13
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
14
-
15
- WIDTH = 640
16
- HEIGHT = 480
17
-
18
- IMAGE_PROMPT = [ proc { "(image edit)> " }, proc { "(image edit)* " } ]
19
-
20
- class ImageCommands < Pry::CommandBase
21
- command "drawing_methods", "Show a list of TexPlay methods" do
22
- output.puts "#{Pry.view(TexPlay.public_instance_methods)}"
23
- end
24
-
25
- command "exit", "Exit the program." do
26
- output.puts "Thanks for dropping by!"
27
- exit
28
- end
29
-
30
- import_from Pry::Commands, "ls", "!"
31
- end
32
-
33
- class WinClass < Gosu::Window
34
-
35
- def initialize
36
- super(WIDTH, HEIGHT, false)
37
- @img = TexPlay.create_image(self, 200, 200).clear :color => :black
38
- @img.rect 0, 0, @img.width - 1, @img.height - 1
39
-
40
- @binding = Pry.binding_for(@img)
41
-
42
- @pry_instance = Pry.new(:commands => ImageCommands, :prompt => IMAGE_PROMPT)
43
- end
44
-
45
- def draw
46
- @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
47
- end
48
-
49
- def update
50
- exit if button_down?(Gosu::KbEscape)
51
-
52
- # We do not want a REPL session as the loop prevents the image
53
- # being updated; instead we do a REP session, and let the image
54
- # update each time the user presses enter. We maintain the same
55
- # binding object to keep locals between calls to `Pry#rep()`
56
- @pry_instance.rep(@binding)
57
- end
58
- end
59
-
60
- puts "Welcome to ImageEdit; type `help` for a list of commands and `drawing_methods` for a list of drawing methods available."
61
- puts "--"
62
- puts "Example: Try typing 'circle width/2, height/2, 95, :color => :blue, :fill => true'"
63
- puts "If you want to save your image, type: save(\"img.png\")"
64
-
65
- w = WinClass.new
66
- w.show
67
-
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO that contains the input data
4
- str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")
5
-
6
- # Start a Pry session on the Fixnum 5 using the input data in str_input
7
- Pry.start(5, :input => str_input)
@@ -1,29 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO that contains the input data for all the Pry objects
4
- cmds = <<-CMDS
5
- cd 1
6
- status
7
- puts 'hello from 1!!'
8
- cd 2
9
- nesting
10
- puts 'hello from 2!!'
11
- _pry_.parent.input = Readline
12
- back
13
- exit-all
14
- CMDS
15
-
16
- # create our StringIO object
17
- str_input = StringIO.new(cmds)
18
-
19
- # set global input to str_input, this means that all pry sessions
20
- # adopt this object as their input object.
21
- Pry.input = str_input
22
-
23
- # Start the session reading from str_input.
24
- # Note that because `Pry.input` is set to `str_input` all nested pry
25
- # sessions will read from `str_input` too. All pry sessions are there
26
- # for non-interactive, except for `pry(1)` which starts off
27
- # non-interactive but is set to be interactive by pry(2) (using
28
- # _pry_.parent.input = Readline)
29
- 0.pry