1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
Commit graph

25 commits

Author SHA1 Message Date
Matthias Winkelmann
1feb395903
Check for existance of cli_options_file before calling realpath() 2018-10-01 11:16:28 +02:00
Damien Robert
975fd746db PluginManager#load_cli_options: use the realpath (#1762)
* PluginManager#load_cli_options: use the realpath

Since ruby 2.5, `require 'foo'` will use the realpath of the file
corresponding to foo.rb. However `require '/absolute/path/to/foo.rb'`
won't use the realpath.

So when $GEM_HOME contains a symlink (ie it is not the realpath), when a
pry plugin is loaded, by `activate!`:
    require gem_name if !active?
the real_path of `gem_name` is used.

But then in load_cli_options:
    cli_options_file = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb")
    require cli_options_file if File.exist?(cli_options_file)
since the path given is absolute, it will be used directly without realpath.

This means that cli.rb may potentially be required twice (once via its realpath if the plugin requires it, the other via its $GEM_HOME path when required by `load_cli_options`), which could raise some errors.

Fix this by using the realpath in load_cli_options too.

Revision r59984 in ruby 2.5 introduced the use of realpath for load paths,
and it was backported to version 2.4 in the minor revision 2.4.4. So
only use the realpath ourselves for ruby versions above or equal to
2.4.4.
2018-10-01 12:18:28 +08:00
Carl Zulauf
69b025e38f Only load plugins that support current pry 2014-10-26 02:39:30 -05:00
Steven Harman
0fd61f6aac Clean File.exists? deprecation warning
This API has been deprecated in Ruby 2.1, so use the File.exist? API.
2014-06-24 16:34:51 -04:00
Robert Gleeson
91d412c044 remove openstruct dependency from all of pry. 2014-01-21 11:11:42 +01:00
☈king
0f207450a9 Robustify the plugin require
I was getting trouble with both pry-editline and pry-syntax-hacks, while
running with a newly-compiled-Ruby with GNU Readline on a Mac (the
default Readline was working OK with these. There could be more
investigation about the error, but for now, at least pry boots with a
handy error instead of a total failure).
2013-02-07 20:58:31 -06:00
☈king
955580e2db Don't mention .gemspec detail explicitly 2012-12-31 21:13:17 -06:00
☈king
46439ca4b6 Explain plugin failure message 2012-12-31 20:16:41 -06:00
Mon ouïe
d86f374cc8 Removed double trailing new-lines (really just because it's done automatically) 2012-07-22 23:30:40 +02:00
Yorick Peterse
70dfb424a8 Set plugin options before requiring the plugin.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
2012-04-23 12:36:27 +02:00
Yorick Peterse
048a58b85b Auto create configuration objects for plugins.
Whenever a plugin is activated a configuration object (using OpenStruct) will be
created in Pry.config for that plugin. For example, for the plugin "pry-doc" the
object Pry.config.pry_doc would be created.

See #436 for more information.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
2012-04-20 13:15:33 +02:00
John Mair
98c3272a75 .puts -> warn, fixes #429 2012-01-23 16:40:40 +13:00
John Mair
b2bce306ad added exact error message to plugin warning when gem is found but not loaded 2011-12-11 04:13:42 +13:00
John Mair
9142aa173f Added Pry::CLI class for processing command line options, with plugin support.
Plugins can define their own command line options by having a lib/plugin_name/cli.rb file. If this file exists
it is loaded immediately before command line options are processed. The contents of the file should be along the lines of:

Pry::CLI.add_options do
  on "my-option", "My first option!" do
    puts "I just defined an option!"
  end
end
2011-12-09 03:14:33 +13:00
John Mair
cab51af3ef extracted initial_session_setup method from Pry.start; invoking :when_started hook in Pry.start 2011-11-13 04:31:43 +13:00
John Mair
aba38ea9e8 refactored plugin code: 1. should not warn when activate called twice on a gem that has already been activated (but ceases to be accessible due to bundler, robgleeson's bug). 2. calling activate on a non-existent plugin should warn not raise 2011-09-02 04:16:43 +12:00
John Mair
ef7ebbc61e converted plugin load failtures from exceptions to warnings, bump to version 0.9.3pre1 2011-07-25 19:43:34 +12:00
John Mair
8133fd8914 added gemspec to Plugin object, so can extract summary/description etc 2011-06-17 01:43:45 +12:00
John Mair
6888630212 plugin activation/disabling errors can be turned off using Pry.config.plugins.strict_loading = false 2011-06-02 21:45:53 +12:00
David Palm
bafff3dc7d rubygems 1.8.x compatibility fixes applied to dev branch 2011-06-01 08:47:14 +02:00
John Mair
2982f5c6b8 plugins are now enabled when explicitly activated! (even if previously disabled) 2011-05-23 22:29:09 +12:00
John Mair
54de8361e2 many changes to plugins, command processor etc, just saving state 2011-05-23 19:11:41 +12:00
John Mair
08b76a555b further basic work on plugin system, for run-time activation of plugins. Added Pry.init for basic initialization of Pry 2011-05-19 15:31:29 +12:00
John Mair
0fa64814b1 documentation for plugins.rb 2011-05-16 04:19:13 +12:00
John Mair
f993448fb6 first stab at plugin system 2011-05-15 23:49:15 +12:00