pry 0.10.4 → 0.11.0.pre

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -18
  3. data/LICENSE +1 -1
  4. data/README.md +28 -26
  5. data/bin/pry +3 -7
  6. data/lib/pry.rb +3 -2
  7. data/lib/pry/basic_object.rb +6 -0
  8. data/lib/pry/cli.rb +39 -34
  9. data/lib/pry/code.rb +6 -1
  10. data/lib/pry/code/code_file.rb +8 -2
  11. data/lib/pry/code_object.rb +23 -0
  12. data/lib/pry/color_printer.rb +11 -8
  13. data/lib/pry/command.rb +40 -16
  14. data/lib/pry/command_set.rb +9 -2
  15. data/lib/pry/commands/cat/exception_formatter.rb +11 -10
  16. data/lib/pry/commands/cat/file_formatter.rb +7 -3
  17. data/lib/pry/commands/code_collector.rb +16 -14
  18. data/lib/pry/commands/easter_eggs.rb +9 -9
  19. data/lib/pry/commands/edit.rb +6 -2
  20. data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
  21. data/lib/pry/commands/find_method.rb +1 -1
  22. data/lib/pry/commands/gem_open.rb +1 -1
  23. data/lib/pry/commands/gem_readme.rb +25 -0
  24. data/lib/pry/commands/gem_search.rb +40 -0
  25. data/lib/pry/commands/hist.rb +2 -2
  26. data/lib/pry/commands/jump_to.rb +7 -7
  27. data/lib/pry/commands/ls/formatter.rb +1 -0
  28. data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
  29. data/lib/pry/commands/ls/self_methods.rb +2 -0
  30. data/lib/pry/commands/play.rb +2 -2
  31. data/lib/pry/commands/reload_code.rb +2 -2
  32. data/lib/pry/commands/ri.rb +4 -0
  33. data/lib/pry/commands/shell_command.rb +34 -8
  34. data/lib/pry/commands/show_info.rb +10 -2
  35. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  36. data/lib/pry/commands/whereami.rb +6 -6
  37. data/lib/pry/config.rb +3 -16
  38. data/lib/pry/config/behavior.rb +139 -49
  39. data/lib/pry/config/default.rb +21 -33
  40. data/lib/pry/config/lazy.rb +25 -0
  41. data/lib/pry/editor.rb +1 -1
  42. data/lib/pry/exceptions.rb +1 -1
  43. data/lib/pry/helpers/base_helpers.rb +6 -10
  44. data/lib/pry/helpers/documentation_helpers.rb +1 -0
  45. data/lib/pry/helpers/options_helpers.rb +1 -1
  46. data/lib/pry/helpers/text.rb +69 -76
  47. data/lib/pry/history.rb +22 -1
  48. data/lib/pry/history_array.rb +1 -1
  49. data/lib/pry/hooks.rb +48 -107
  50. data/lib/pry/indent.rb +6 -2
  51. data/lib/pry/input_completer.rb +118 -118
  52. data/lib/pry/method.rb +13 -13
  53. data/lib/pry/method/disowned.rb +1 -0
  54. data/lib/pry/method/patcher.rb +0 -3
  55. data/lib/pry/output.rb +37 -38
  56. data/lib/pry/pager.rb +11 -8
  57. data/lib/pry/plugins.rb +20 -5
  58. data/lib/pry/pry_class.rb +29 -3
  59. data/lib/pry/pry_instance.rb +8 -6
  60. data/lib/pry/repl.rb +37 -5
  61. data/lib/pry/repl_file_loader.rb +1 -1
  62. data/lib/pry/rubygem.rb +3 -1
  63. data/lib/pry/slop.rb +661 -0
  64. data/lib/pry/slop/LICENSE +20 -0
  65. data/lib/pry/slop/commands.rb +196 -0
  66. data/lib/pry/slop/option.rb +208 -0
  67. data/lib/pry/terminal.rb +16 -5
  68. data/lib/pry/test/helper.rb +11 -2
  69. data/lib/pry/version.rb +1 -1
  70. data/lib/pry/wrapped_module.rb +5 -5
  71. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +2 -4
  72. metadata +14 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1b85ec70167eee63c4f58e11c27f2c1f94f49db
4
- data.tar.gz: 08a2b56e67aef2cdaf4fb6c4aa3ac0c1e8bf395f
3
+ metadata.gz: 46f588aa884919f6d4e40f085f85e3cda1fc1976
4
+ data.tar.gz: a1107f181339016ee7cf4439e1f43ff0aabb4206
5
5
  SHA512:
6
- metadata.gz: f82d5ccba499a9dc6a11bc48496424f691248134bad714cdaf8704bc95ffd3368fa07471d3651f464fcf92cac0b0779860276fa973783f1b2bd34b338c14ce92
7
- data.tar.gz: 088a2f47add7c3e16ca078f4e84ebac15b05051d945b3f5c25a295292ec6478bf5bbe0c6752a143f16d323116fbf1e19ebd72b5fbbfa716830a9181a768fe20a
6
+ metadata.gz: 583cc0eaf4644ddb80520ca52eecbad442d7dc5450e2eed4f32cd201869fb7c24a49bd70effe13355a845d7a99a9e0f1b9d45145e1e0267c2e6c3155fe990cbc
7
+ data.tar.gz: 37eefe5204e90592a1256d56b90eb2d77af48f4a86b3ce5931ac5582e64536162ee683d627142787e7e838187166f078fd5f1803ee86cc6e811553b6aa2ccd62
@@ -1,11 +1,38 @@
1
- ### 0.10.3
2
-
3
- * cherry-pick 0d1d72b and e0e5c75 to fix the install of Pry on Windows.
4
-
5
- ### 0.10.2
6
-
7
- * cherry-pick c2ed9ec135bd791a32c70fbe05cc0508ea17c4040e from master (fix inf. loop with prepended methods source retrieval)
8
- * Update some specs for recent ruby versions (2.2+)
1
+ ### HEAD
2
+ * Use `less` or system pager pager on MS Windows if it is available. [#1512](https://github.com/pry/pry/pull/1512)
3
+ * Add `Pry.configure` as an alternative to the current way of changing configuration options in `.pryrc` files. [#1502](https://github.com/pry/pry/pull/1502)
4
+ * Add `Pry::Config::Behavior#eager_load!` to add a possible workaround for issues like [#1501](https://github.com/pry/pry/issues/1501)
5
+ * Remove Slop as a runtime dependency by vendoring v3.4 as Pry::Slop.
6
+ People can depend on Slop v4 and Pry at the same time without running into version conflicts. ([#1497](https://github.com/pry/pry/issues/1497))
7
+ * Fix auto-indentation of code that uses a single-line rescue ([#1450](https://github.com/pry/pry/issues/1450))
8
+ * Remove "Pry::Config#refresh", please use "Pry::Config#clear" instead.
9
+ * Defining a method called "ls" no longer breaks the "ls" command ([#1407](https://github.com/pry/pry/issues/1407))
10
+ * Don't raise when directory permissions don't allow file expansion ([#1432](https://github.com/pry/pry/issues/1432))
11
+ * Syntax highlight <tt> tags in documentation output.
12
+ * Add support for BasicObject subclasses who implement their own #inspect (#1341)
13
+ * Fix 'include RSpec::Matchers' at the top-level (#1277)
14
+ * Add 'gem-readme' command, prints the README file bundled with a rubygem
15
+ * Add 'gem-search' command, searches for a gem with the rubygems.org HTTP API
16
+ * Fixed bug in the `cat` command where it was impossible to use line numbers with files ([#1349](https://github.com/pry/pry/issues/1349))
17
+ * Fixed uncaught Errno::EOPNOTSUPP exception when $stdout is a socket ([#1352](https://github.com/pry/pry/issues/1352))
18
+ * Display a warning when you cd'ed inside a C object and executed 'show-source' without arguments ([#691](https://github.com/pry/pry/issues/691))
19
+ * Make the stagger_output method more reliable by reusing possibly available Pry instance ([#1364](https://github.com/pry/pry/pull/1364))
20
+ * Make the 'gem-install' message less confusing by removing backticks ([#1350](https://github.com/pry/pry/pull/1350))
21
+ * Fixed error when Pry was trying to load incompatible versions of plugins ([#1312](https://github.com/pry/pry/issues/1312))
22
+ * Fixed bug when `hist --clear` led to ArgumentError ([#1340](https://github.com/pry/pry/pull/1340))
23
+ * Fixed the "uninitialized constant Pry::ObjectPath::StringScanner" exception during autocomplete ([#1330](https://github.com/pry/pry/issues/1330))
24
+ * Secured usage of colours with special characters (RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE) in Pry::Helpers::Text ([#493](https://github.com/pry/pry/issues/493#issuecomment-39232771))
25
+ * Fixed regression with `pry -e` when it messes the terminal ([#1387](https://github.com/pry/pry/issues/1387))
26
+ * Fixed regression with space prefixes of expressions ([#1369](https://github.com/pry/pry/issues/1369))
27
+ * Introduced the new way to define hooks for commands (with `Pry.hooks.add_hook("{before,after}_commandName")`). The old way is deprecated, but still supported (with `Pry.commands.{before,after}_command`) ([#651](https://github.com/pry/pry/issues/651))
28
+ * Removed old API's using `Pry::Hooks.from_hash` altogether
29
+ * Removed hints on Foreman support (see [this](https://github.com/ddollar/foreman/pull/536))
30
+ * Fixed support for the tee command ([#1334](https://github.com/pry/pry/issues/1334))
31
+ * Implemented support for CDPATH for ShellCommand ([#1433](https://github.com/pry/pry/issues/1433), [#1434](https://github.com/pry/pry/issues/1434))
32
+ * `Pry::CLI.parse_options` does not start Pry anymore ([#1393](https://github.com/pry/pry/pull/1393))
33
+ * The gem uses CPU-less platforms for Windows now ([#1410](https://github.com/pry/pry/pull/1410))
34
+ * Add `Pry::Config::Lazy` to make it easier to reimplement `Pry::Config::Default` without knowing its implementation [#1503](https://github.com/pry/pry/pull/1503/)
35
+ * Lazy load the config defaults for `Pry.config.history` and `Pry.config.gist`.
9
36
 
10
37
  ### 0.10.1
11
38
 
@@ -376,7 +403,7 @@
376
403
  * Fewer internal methods polluting output
377
404
 
378
405
  ### 0.9.8.4 (2012/6/3)
379
- * ~/.pry_history wasnt being created (if it did not exist)! FIXED
406
+ * ~/.pry_history wasn't being created (if it did not exist)! FIXED
380
407
  * `hist --save` saved colors! FIXED
381
408
  * added Pry#add_sticky_local API for adding sticky locals to individual pry instances
382
409
 
@@ -384,7 +411,7 @@
384
411
  * various tweaks to improve rbx support
385
412
  * commands now support optional block arguments
386
413
  * much improved help command
387
- * updated method_source dependencya
414
+ * updated method_source dependency
388
415
  * added wtf command
389
416
  * jruby should now work in windows (though without color)
390
417
 
@@ -412,7 +439,7 @@ MAJOR NEW FEATURES
412
439
  - added gist command (removed gist-method, new gist command is more general)
413
440
 
414
441
  complete CHANGELOG:
415
- * CommandError's no longer cause the current input to be disgarded
442
+ * CommandError's no longer cause the current input to be discarded
416
443
  * Better syntax highlighting for rbx code code
417
444
  * added cat --in to show pry input history
418
445
  * prefixed temporary file names with 'pry'
@@ -425,7 +452,7 @@ complete CHANGELOG:
425
452
  * added CommandSet#{before_command,after_command} for enhancing builtin commands
426
453
  * added checking for namespace collisions with pry commands, set Pry.config.collision_warning
427
454
  * work around namespace collisions by ensuring lines starting with a space are executed as
428
- * ruby.work around namespace collisions by prensuring lines starting with a space are executed as ruby
455
+ * ruby.work around namespace collisions by pressuring lines starting with a space are executed as ruby
429
456
  * added handlers for Ctrl+C (SIGINT) on jruby, these are now caught as in other ruby versions
430
457
  * removed dependency on ruby_parser
431
458
  * prevented colours leaking across the pry prompt
@@ -445,7 +472,7 @@ complete CHANGELOG:
445
472
 
446
473
  ### 0.9.7.4 (2011/11/5)
447
474
  * ls -M now works in modules (bugfix)
448
- * added exception msg for bad cd object/path
475
+ * added exception message for bad cd object/path
449
476
  * no longer die when encounter exceptions in .pryrc
450
477
  * baked in CoolLine support
451
478
  * Pry.config.input in .pryrc now respected
@@ -462,7 +489,7 @@ complete CHANGELOG:
462
489
  * changed ^D so it no longer resets indent level automatically
463
490
 
464
491
  ### 0.9.7.1 (2011/10/26)
465
- * fixed gem dependecy issues
492
+ * fixed gem dependency issues
466
493
 
467
494
  ### 0.9.7 (2011/10/25)
468
495
 
@@ -503,7 +530,7 @@ complete CHANGELOG:
503
530
  * play -m --open uses show-input to show play'd code
504
531
  * added "unindent" helper to make adding help to commands easier
505
532
  * local ./.pryrc now loaded after ~/.pryrc if it exists
506
- * cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves throuh successive levels of the backtrace automatically with state stored on the exceptino object itself
533
+ * cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves through successive levels of the backtrace automatically with state stored on the exception object itself
507
534
  * new option Pry.config.exception_window_size determines window size for cat --ex
508
535
  * input_stack now implemented - pushing objects onto a pry instance's input_stack causes the instance to read from those objects in turn as it encounters EOF on the previous object. On finishing the input_stack the input object for the pry instance is set back to Pry.config.input, if this fails, pry breaks out of the REPL (throw(:breakout)) with an error message
509
536
  * Pry.config.system() defines how pry runs system commands
@@ -536,10 +563,10 @@ complete CHANGELOG:
536
563
  * fixed bug #200 ( https://github.com/pry/pry/issues/200 )- string interpolation bug (thanks to ryanf)
537
564
  * show-doc and stat now display method visibility (update WIKI)
538
565
  * got rid of warnings caused by stricter ruby 1.9.3 rules
539
- * remove interpolation of command names and fix interpolation error messag (update WIKI) (thanks ryanf!)
566
+ * remove interpolation of command names and fix interpolation error message (update WIKI) (thanks ryanf!)
540
567
  * 'nested sessions' now use binding stacks (so each instance manages its own collection of bindings without spawning other instances)
541
568
  * 'cd ..' just pops a binding off the binding_stack with special behaviour when only one binding in stack - it breaks out of the repl loop
542
- * added switch-to command (like jump-to but doesnt unwind the stack)
569
+ * added switch-to command (like jump-to but doesn't unwind the stack)
543
570
  * show-method and show-doc now accept multiple method names
544
571
  * control_d hook added (Pry.config.control_d_handler)
545
572
  * behaviour of ^d is now to break out of current expr if in multi-line expr, or break out of current context if nested, or break out of pry repl loop if at top-level
@@ -633,7 +660,7 @@ complete CHANGELOG:
633
660
  * -I mode for pry commandline
634
661
  * --color mode for pry commandline
635
662
  * clean up requires (put them all in one place)
636
- * simple-prompt command and toggle-color commandd.
663
+ * simple-prompt command and toggle-color command.
637
664
 
638
665
  ### 0.6.3 (2011/2/28)
639
666
  * Using MethodSource 0.3.4 so 1.8 show-method support provided
data/LICENSE CHANGED
@@ -3,7 +3,7 @@ License
3
3
 
4
4
  (The MIT License)
5
5
 
6
- Copyright (c) 2013 John Mair (banisterfiend)
6
+ Copyright (c) 2016 John Mair (banisterfiend)
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining
9
9
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,25 +1,25 @@
1
1
  [![Build Status](https://img.shields.io/travis/pry/pry.svg)](https://travis-ci.org/pry/pry)
2
2
  [![Code Climate](https://img.shields.io/codeclimate/github/pry/pry.svg)](https://codeclimate.com/github/pry/pry)
3
- [![Inline docs](http://inch-ci.org/github/pry/pry.svg)](http://inch-ci.org/github/pry/pry)
3
+ [![Inline docs](http://inch-ci.org/github/pry/pry.svg?style=shields)](http://inch-ci.org/github/pry/pry)
4
4
 
5
5
  <center>
6
6
  ![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png)
7
7
 
8
- © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2013<br>
8
+ © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2016<br>
9
9
 
10
- **Please** [DONATE](http://www.pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
10
+ **Please** [DONATE](http://pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
11
11
 
12
12
  **Sponsors**
13
13
 
14
- [Tealeaf Academy](http://www.gotealeaf.com)<br/>
15
- [Atomic Object](http://www.atomicobject.com/)<br/>
14
+ [Launch School](https://launchschool.com)<br/>
15
+ [Atomic Object](https://atomicobject.com/)<br/>
16
16
  [Hashrocket](http://hashrocket.com/)<br/>
17
- [Intridea](http://intridea.com/)<br/>
18
- [Gaslight](http://gaslight.co/home)<br/>
17
+ [Intridea](http://www.intridea.com)<br/>
18
+ [Gaslight](https://teamgaslight.com/home)<br/>
19
19
 
20
20
  **Other Resources**
21
21
 
22
- [Skip to the website (recommended)](http://pry.github.com) <br />
22
+ [Skip to the website (recommended)](http://pryrepl.org/) <br />
23
23
  [Skip to the wiki](https://github.com/pry/pry/wiki)
24
24
  </center>
25
25
 
@@ -44,7 +44,7 @@ including:
44
44
 
45
45
  Pry also aims to be more than an IRB replacement; it is an
46
46
  attempt to bring REPL driven programming to the Ruby language. It is
47
- currently not as powerful as tools like [SLIME](http://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
47
+ currently not as powerful as tools like [SLIME](https://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
48
48
  general direction Pry is heading.
49
49
 
50
50
  Pry is also fairly flexible and allows significant user
@@ -64,8 +64,8 @@ methods. The additional docs are accessed through the `show-doc` and
64
64
 
65
65
  * Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
66
66
  * Browse the comprehensive [documentation at the official Pry wiki](https://github.com/pry/pry/wiki)
67
- * Read the [YARD API documentation](http://rdoc.info/github/pry/pry/master/file/README.markdown)
68
- * See the [source code](http://github.com/pry/pry)
67
+ * Read the [YARD API documentation](http://www.rubydoc.info/github/pry/pry/)
68
+ * See the [source code](https://github.com/pry/pry)
69
69
 
70
70
  ### Commands
71
71
 
@@ -137,20 +137,22 @@ implementing developer consoles and applying hot patches.
137
137
 
138
138
  code:
139
139
 
140
- # test.rb
141
- require 'pry'
140
+ ```ruby
141
+ # test.rb
142
+ require 'pry'
142
143
 
143
- class A
144
- def hello() puts "hello world!" end
145
- end
144
+ class A
145
+ def hello() puts "hello world!" end
146
+ end
146
147
 
147
- a = A.new
148
+ a = A.new
148
149
 
149
- # start a REPL session
150
- binding.pry
150
+ # start a REPL session
151
+ binding.pry
151
152
 
152
- # program resumes here (after pry session)
153
- puts "program resumes here."
153
+ # program resumes here (after pry session)
154
+ puts "program resumes here."
155
+ ```
154
156
 
155
157
  Pry session:
156
158
 
@@ -314,10 +316,10 @@ We can also use `ri` in the normal way:
314
316
 
315
317
  ### Gist integration
316
318
 
317
- If the `gist` gem is installed then method source or documentation can be gisted to github with the
319
+ If the `gist` gem is installed then method source or documentation can be gisted to GitHub with the
318
320
  `gist` command. The `gist` command is capable of gisting [almost any REPL content](https://gist.github.com/cae143e4533416529726), including methods, documentation,
319
321
  input expressions, command source, and so on. In the example below we will gist the C source
320
- code for the `Symbol#to_proc` method to github:
322
+ code for the `Symbol#to_proc` method to GitHub:
321
323
 
322
324
  pry(main)> gist -m Symbol#to_proc
323
325
  Gist created at https://gist.github.com/5332c38afc46d902ce46 and added to clipboard.
@@ -351,7 +353,7 @@ Many other commands are available in Pry; to see the full list type
351
353
  with basic instructions for use; some commands have a more extensive
352
354
  help that can be accessed via typing `command_name --help`. A command
353
355
  will typically say in its description if the `--help` option is
354
- avaiable.
356
+ available.
355
357
 
356
358
  ### Use Pry as your Rails Console
357
359
 
@@ -397,10 +399,10 @@ between commands and running commands in background
397
399
 
398
400
  ### Contact
399
401
 
400
- Problems or questions? file an issue at [github](https://github.com/pry/pry/issues)
402
+ Problems or questions? File an issue at [GitHub](https://github.com/pry/pry/issues).
401
403
 
402
404
  ### Contributors
403
405
 
404
- Pry is primarily the work of [John Mair (banisterfiend)](http://github.com/banister), for full list
406
+ Pry is primarily the work of [John Mair (banisterfiend)](https://github.com/banister), for full list
405
407
  of contributors see the
406
408
  [CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
data/bin/pry CHANGED
@@ -5,12 +5,8 @@
5
5
 
6
6
  $0 = 'pry'
7
7
 
8
- begin
9
- require 'pry'
10
- rescue LoadError
11
- require 'rubygems'
12
- require 'pry'
13
- end
8
+ require 'pry'
14
9
 
15
10
  # Process command line options and run Pry
16
- Pry::CLI.parse_options
11
+ opts = Pry::CLI.parse_options
12
+ Pry::CLI.start(opts)
data/lib/pry.rb CHANGED
@@ -1,4 +1,4 @@
1
- # (C) John Mair (banisterfiend) 2013
1
+ # (C) John Mair (banisterfiend) 2016
2
2
  # MIT License
3
3
  #
4
4
  require 'pp'
@@ -124,8 +124,9 @@ end
124
124
  require 'method_source'
125
125
  require 'shellwords'
126
126
  require 'stringio'
127
+ require 'strscan'
127
128
  require 'coderay'
128
- require 'slop'
129
+ require 'pry/slop'
129
130
  require 'rbconfig'
130
131
  require 'tempfile'
131
132
  require 'pathname'
@@ -0,0 +1,6 @@
1
+ class Pry::BasicObject < BasicObject
2
+ [:Kernel, :Pry].each do |constant|
3
+ const_set constant, ::Object.const_get(constant)
4
+ end
5
+ include Kernel
6
+ end
@@ -19,7 +19,7 @@ class Pry
19
19
  # as CLI options.
20
20
  attr_accessor :input_args
21
21
 
22
- # Add another set of CLI options (a Slop block)
22
+ # Add another set of CLI options (a Pry::Slop block)
23
23
  def add_options(&block)
24
24
  if options
25
25
  old_options = options
@@ -62,28 +62,58 @@ class Pry
62
62
  raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
63
63
  end
64
64
 
65
+ # Load config files etc first, ensuring that cli options will take precedence.
66
+ Pry.initial_session_setup
67
+
65
68
  self.input_args = args
66
69
 
67
70
  begin
68
- opts = Slop.parse!(
71
+ opts = Pry::Slop.parse!(
69
72
  args,
70
73
  :help => true,
71
74
  :multiple_switches => false,
72
75
  :strict => true,
73
76
  &options
74
77
  )
75
- rescue Slop::InvalidOptionError
78
+ rescue Pry::Slop::InvalidOptionError
76
79
  # Display help message on unknown switches and exit.
77
- puts Slop.new(&options)
80
+ puts Pry::Slop.new(&options)
78
81
  exit
79
82
  end
80
83
 
84
+ Pry.final_session_setup
85
+
81
86
  # Option processors are optional.
82
87
  if option_processors
83
88
  option_processors.each { |processor| processor.call(opts) }
84
89
  end
85
90
 
86
- self
91
+ opts
92
+ end
93
+
94
+ def start(opts)
95
+ exit if opts.help?
96
+
97
+ # invoked via cli
98
+ Pry.cli = true
99
+
100
+ # create the actual context
101
+ if opts[:context]
102
+ Pry.initial_session_setup
103
+ context = Pry.binding_for(eval(opts[:context]))
104
+ Pry.final_session_setup
105
+ else
106
+ context = Pry.toplevel_binding
107
+ end
108
+
109
+ if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
110
+ full_name = File.expand_path(Pry::CLI.input_args.first)
111
+ Pry.load_file_through_repl(full_name)
112
+ exit
113
+ end
114
+
115
+ # Start the session (running any code passed with -e, if there is any)
116
+ Pry.start(context, :input => StringIO.new(Pry.config.exec_string))
87
117
  end
88
118
 
89
119
  end
@@ -93,11 +123,8 @@ class Pry
93
123
  end
94
124
 
95
125
 
96
- # String that is built to be executed on start (created by -e and -exec switches)
97
- exec_string = ""
98
-
99
126
  # Bring in options defined by plugins
100
- Slop.new do
127
+ Pry::Slop.new do
101
128
  on "no-plugins" do
102
129
  Pry.config.should_load_plugins = false
103
130
  end
@@ -112,11 +139,12 @@ Pry::CLI.add_options do
112
139
  banner %{Usage: pry [OPTIONS]
113
140
  Start a Pry session.
114
141
  See http://pryrepl.org/ for more information.
115
- Copyright (c) 2013 John Mair (banisterfiend)
142
+ Copyright (c) 2016 John Mair (banisterfiend)
116
143
  --
117
144
  }
118
145
  on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
119
- exec_string << input << "\n"
146
+ Pry.config.exec_string += "\n" if Pry.config.exec_string.length > 0
147
+ Pry.config.exec_string += input
120
148
  end
121
149
 
122
150
  on "no-pager", "Disable pager for long output" do
@@ -194,27 +222,4 @@ Copyright (c) 2013 John Mair (banisterfiend)
194
222
  "Start the session in the specified context. Equivalent to `context.pry` in a session.",
195
223
  :default => "Pry.toplevel_binding"
196
224
  )
197
- end.add_option_processor do |opts|
198
-
199
- exit if opts.help?
200
-
201
- # invoked via cli
202
- Pry.cli = true
203
-
204
- # create the actual context
205
- if opts[:context]
206
- Pry.initial_session_setup
207
- context = Pry.binding_for(eval(opts[:context]))
208
- else
209
- context = Pry.toplevel_binding
210
- end
211
-
212
- if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
213
- full_name = File.expand_path(Pry::CLI.input_args.first)
214
- Pry.load_file_through_repl(full_name)
215
- exit
216
- end
217
-
218
- # Start the session (running any code passed with -e, if there is any)
219
- Pry.start(context, :input => StringIO.new(exec_string))
220
225
  end
@@ -92,7 +92,7 @@ class Pry
92
92
  LOC.new(line, lineno + start_line.to_i) }
93
93
  @code_type = code_type
94
94
 
95
- @with_marker = @with_indentation = nil
95
+ @with_marker = @with_indentation = @with_line_numbers = nil
96
96
  end
97
97
 
98
98
  # Append the given line. +lineno+ is one more than the last existing
@@ -337,6 +337,11 @@ class Pry
337
337
  end
338
338
  undef =~
339
339
 
340
+ # Check whether String responds to missing methods.
341
+ def respond_to_missing?(name, include_all = false)
342
+ ''.respond_to?(name, include_all)
343
+ end
344
+
340
345
  protected
341
346
 
342
347
  # An abstraction of the `dup.instance_eval` pattern used throughout this