modify lib/ and spec/ to use Pry::Slop

This commit is contained in:
strcmp 2015-12-11 06:04:54 +00:00
parent cab1e094fa
commit 52d88cdd6b
7 changed files with 17 additions and 17 deletions

View File

@ -126,7 +126,7 @@ require 'shellwords'
require 'stringio'
require 'strscan'
require 'coderay'
require 'slop'
require 'pry/slop'
require 'rbconfig'
require 'tempfile'
require 'pathname'

View File

@ -19,7 +19,7 @@ class Pry
# as CLI options.
attr_accessor :input_args
# Add another set of CLI options (a Slop block)
# Add another set of CLI options (a Pry::Slop block)
def add_options(&block)
if options
old_options = options
@ -68,16 +68,16 @@ class Pry
self.input_args = args
begin
opts = Slop.parse!(
opts = Pry::Slop.parse!(
args,
:help => true,
:multiple_switches => false,
:strict => true,
&options
)
rescue Slop::InvalidOptionError
rescue Pry::Slop::InvalidOptionError
# Display help message on unknown switches and exit.
puts Slop.new(&options)
puts Pry::Slop.new(&options)
exit
end
@ -124,7 +124,7 @@ end
# Bring in options defined by plugins
Slop.new do
Pry::Slop.new do
on "no-plugins" do
Pry.config.should_load_plugins = false
end

View File

@ -531,7 +531,7 @@ class Pry
# subclasses.
#
# Create subclasses using {Pry::CommandSet#create_command}, and override the
# `options(opt)` method to set up an instance of Slop, and the `process`
# `options(opt)` method to set up an instance of Pry::Slop, and the `process`
# method to actually run the command. If necessary, you can also override
# `setup` which will be called before `options`, for example to require any
# gems your command needs to run, or to set up state.
@ -607,15 +607,15 @@ class Pry
end
end
# Return the help generated by Slop for this command.
# Return the help generated by Pry::Slop for this command.
def help
slop.help
end
# Return an instance of Slop that can parse either subcommands or the
# Return an instance of Pry::Slop that can parse either subcommands or the
# options that this command accepts.
def slop
Slop.new do |opt|
Pry::Slop.new do |opt|
opt.banner(unindent(self.class.banner))
subcommands(opt)
options(opt)
@ -644,7 +644,7 @@ class Pry
# end
def setup; end
# A method to setup Slop commands so it can parse the subcommands your
# A method to setup Pry::Slop commands so it can parse the subcommands your
# command expects. If you need to set up default values, use `setup`
# instead.
#
@ -679,7 +679,7 @@ class Pry
# end
def subcommands(cmd); end
# A method to setup Slop so it can parse the options your command expects.
# A method to setup Pry::Slop so it can parse the options your command expects.
#
# @note Please don't do anything side-effecty in the main part of this
# method, as it may be called by Pry at any time for introspection reasons.
@ -696,7 +696,7 @@ class Pry
# The actual body of your command should go here.
#
# The `opts` mehod can be called to get the options that Slop has passed,
# The `opts` mehod can be called to get the options that Pry::Slop has passed,
# and `args` gives the remaining, unparsed arguments.
#
# The return value of this method is discarded unless the command was

View File

@ -3,7 +3,7 @@ class Pry
module OptionsHelpers
module_function
# Add method options to the Slop instance
# Add method options to the Pry::Slop instance
def method_options(opt)
@method_target = target
opt.on :M, "instance-methods", "Operate on instance methods."

View File

@ -435,7 +435,7 @@ class Pry
# @return [Boolean] `true` if `val` is a command, `false` otherwise
def process_command_safely(val)
process_command(val)
rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e
rescue CommandError, Pry::Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e
Pry.last_internal_error = e
output.puts "Error: #{e.message}"
true

View File

@ -3,7 +3,7 @@ require_relative '../../helper'
describe Pry::Command::Cat::FileFormatter do
before do
@p = Pry.new
@opt = Slop.new
@opt = Pry::Slop.new
end
describe "#file_and_line" do

View File

@ -26,7 +26,7 @@ if ENV["SET_TRACE_FUNC"]
}
end
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}, Slop v#{Slop::VERSION}"
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}, Pry::Pry::Slop v#{Pry::Pry::Slop::VERSION}"
RSpec.configure do |config|
config.expect_with :rspec do |c|