Refactor `--installed-plugins` switch

First of all, add `PluginManager.show_installed_plugins` method. The
body of this method is taken from `--installed-plugins` code, which
means that it still displays the list of all installed plugins.

Secondly, use `PluginManager.show_installed_plugins` in
`--installed-plugins` body instead of the old code.

This change is needed, because we want to invoke `--installed-plugins`
from other place of the program and we don't want to repeat ourselves.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Implement rudimentary `plugin` command

Add `plugin` command and add `-l` aka `--list` switch to it. It allows
to display the list of all intalled Pry plugins.

Also, change the `PluginManager.show_installed_plugins` method a little
bit: it takes Hash parameter instead of Array one.

Last but not least, adjust `--installed-plugins` switch of Pry to that
method change.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Fix indentation and typo

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Add `Pry::Helpers::Text.wrap` method

Also, create `test/test_helpers` directory and place a new file in it:
`test_text.rb` with tests for `wrap` method.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Relocate `test_command_helpers.rb` to another dir

Relocate it to `test/test_helpers` directory

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Extend ClassCommand so it can define sub commands

Create `ClassCommand::Options` class, which ties up sub commands and
default options together.

Let's consider the command `food make --tea`. `food` is a command,
`make` is a sub command and `--tea` is an option of `make` sub command.
We can access `--tea` via `opts[:make][:tea].

Also, we can check the freshness of our food like so: `food --freshness`.
`--freshness` is a default option. We can access it like so:
`opts.freshness?` or `opts[:freshness]`.

Add unit tests for `ClassCommand::Option` and some other tests that
reflect the additions.

Finally, document everything and fix different typos in the existing
documentation.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Add basic support for remote plugins

Lots of stuff happens here.

First of all, change the value of `PRY_PLUGIN_PREFIX` constant from
Regexp to String, because String interpolates better.

Add `RemotePlugin` struct, which represents remote Pry plugins and
carries information about them.

Next, add `@remote_plugins` ivar to `PluginManager`. This variable is an
`Array`, which contains the list of remote plugins (instances of
`RemotePlugin`). Refactor `PluginManager#locate_plugins`, so it supports
detection of remote plugins (basically it's just a dispatcher method).

Make `PluginManager` fetch Pry plugins through RubyGems API.

Last but not least, add `PluginManager.show_remote_plugins`, which forms
a nice list of plugins with their dependencies.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Delegate `#remote_plugins` method

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Use stagger_output for `plugin list` headers

Include the headers of `plugin list` and `plugin list -r` into
stagger_output.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Update gemspec

Update it with help of `rake gemspec` task.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Implement "plugin status" subcommand

"plugin status" subcommand shows plugin statuses (active or inactive).

Add two options to this subcommand: `--active` and `--inactive`. By
default, `plugin status` will display all installed plugins. With help
of these options a user can choose, which type of plugins wants to see.
For example:

  pry(main)> plugin status --active
  Active Plugins:
  --
  debundle
  rails

Also, make all newly initialized plugins inactive by setting
`self.active` to `false` (currently the default value is `nil`).

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Rename "sub_command" to "subcommand"

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Create "plugin.rb" file from old "misc.rb"

Follow the new convention, where every command should be in its own
separate file.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Integrate branch with master

There were some changes in master that affect current code. Make a
couple of small amendments to feature/plugin_manager branch so the tests
pass again.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Refactor ClassCommand#slop

Do not create unwanted Proc, because there is no real reason for it.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Implement `install` subcommand

The interesting part is `ClassCommand::Options#command?` method.

TL;DR
-----

It's the same as `Slop::Commands#present?`.

Details
-------

Usually, when you use `Slop::Commands` you have `#present?` method,
which checks for a command presence. But `Options` class uses
`#command?` method to do the same (this is a just a wrapper around
Slop's `#present?`). The reason is that I don't want to refactor all the
existing code just for one method name change. Also, it reads better.

You may ask how to use `install`. That is a very good question. The
answer:

  pry(main)> plugin install doc stack_explorer

This command will install "pry-doc" and "pry-stack_explorer" gems.
Internally, it uses "gem-install" command from Pry.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>