mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1798 from pry/rubocop-style-hash-syntax
rubocop: fix offences of the Style/HashSyntax cop
This commit is contained in:
commit
e7f01818d3
64 changed files with 390 additions and 397 deletions
.rubocop_todo.ymlGemfileRakefile
lib/pry
cli.rbcode.rbcode_object.rbcommand.rbcommand_set.rb
commands
amend_line.rbbang.rbcat.rbcode_collector.rbeaster_eggs.rbedit.rbexit.rbfind_method.rbgem_cd.rbgem_install.rbgem_open.rbgist.rbhist.rbls.rbplay.rbraise_up.rbri.rbshell_command.rbshow_doc.rbshow_info.rbstat.rbwatch_expression.rbwtf.rb
helpers
method.rbpry_class.rbpry_instance.rbrepl_file_loader.rbrubygem.rbslop.rbslop
testable
spec
|
@ -1130,13 +1130,6 @@ Style/GlobalVars:
|
|||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 459
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
Style/HashSyntax:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
Style/IdenticalConditionalBranches:
|
||||
Exclude:
|
||||
|
|
6
Gemfile
6
Gemfile
|
@ -6,12 +6,12 @@ gem 'rake', '~> 10.0'
|
|||
group :development do
|
||||
gem 'gist'
|
||||
gem 'yard'
|
||||
gem 'rb-inotify', :require => false
|
||||
gem 'rb-fsevent', :require => false
|
||||
gem 'rb-inotify', require: false
|
||||
gem 'rb-fsevent', require: false
|
||||
|
||||
# Rubocop supports only >=2.2.0
|
||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
|
||||
gem 'rubocop', '= 0.59.2', :require => false
|
||||
gem 'rubocop', '= 0.59.2', require: false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
20
Rakefile
20
Rakefile
|
@ -9,7 +9,7 @@ CLEAN.include('**/*#*', '**/*#*.*', '**/*_flymake*.*', '**/*_flymake', '**/*.rbc
|
|||
|
||||
require 'rspec/core/rake_task'
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
task :default => :spec
|
||||
task default: :spec
|
||||
|
||||
desc "Run pry (you can pass arguments using _ in place of -)"
|
||||
task :pry do
|
||||
|
@ -29,7 +29,7 @@ desc "Profile pry's startup time"
|
|||
task :profile do
|
||||
require 'profile'
|
||||
require 'pry'
|
||||
Pry.start(TOPLEVEL_BINDING, :input => StringIO.new('exit'))
|
||||
Pry.start(TOPLEVEL_BINDING, input: StringIO.new('exit'))
|
||||
end
|
||||
|
||||
def modify_base_gemspec
|
||||
|
@ -77,23 +77,23 @@ end
|
|||
end
|
||||
|
||||
desc "build all platform gems at once"
|
||||
task :gems => [:clean, :rmgems, 'ruby:gem', 'jruby:gem']
|
||||
task gems: [:clean, :rmgems, 'ruby:gem', 'jruby:gem']
|
||||
|
||||
desc "remove all platform gems"
|
||||
task :rmgems => ['ruby:clobber_package']
|
||||
task :rm_gems => :rmgems
|
||||
task :rm_pkgs => :rmgems
|
||||
task rmgems: ['ruby:clobber_package']
|
||||
task rm_gems: :rmgems
|
||||
task rm_pkgs: :rmgems
|
||||
|
||||
desc "reinstall gem"
|
||||
task :reinstall => :gems do
|
||||
task reinstall: :gems do
|
||||
sh "gem uninstall pry" rescue nil
|
||||
sh "gem install #{File.dirname(__FILE__)}/pkg/pry-#{Pry::VERSION}.gem"
|
||||
end
|
||||
|
||||
task :install => :reinstall
|
||||
task install: :reinstall
|
||||
|
||||
desc "build and push latest gems"
|
||||
task :pushgems => :gems do
|
||||
task pushgems: :gems do
|
||||
chdir("#{File.dirname(__FILE__)}/pkg") do
|
||||
Dir["*.gem"].each do |gemfile|
|
||||
sh "gem push #{gemfile}"
|
||||
|
@ -108,7 +108,7 @@ namespace :docker do
|
|||
end
|
||||
|
||||
desc "test pry on multiple ruby versions"
|
||||
task :test => :build do
|
||||
task test: :build do
|
||||
system "docker run -i -t -v /tmp/prytmp:/tmp/prytmp pry/pry ./multi_test_inside_docker.sh"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,9 +70,9 @@ class Pry
|
|||
begin
|
||||
opts = Pry::Slop.parse!(
|
||||
args,
|
||||
:help => true,
|
||||
:multiple_switches => false,
|
||||
:strict => true,
|
||||
help: true,
|
||||
multiple_switches: false,
|
||||
strict: true,
|
||||
&options
|
||||
)
|
||||
rescue Pry::Slop::InvalidOptionError
|
||||
|
@ -113,7 +113,7 @@ class Pry
|
|||
end
|
||||
|
||||
# Start the session (running any code passed with -e, if there is any)
|
||||
Pry.start(context, :input => StringIO.new(Pry.config.exec_string))
|
||||
Pry.start(context, input: StringIO.new(Pry.config.exec_string))
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -198,7 +198,7 @@ Copyright (c) 2016 John Mair (banisterfiend)
|
|||
Pry.config.requires << file
|
||||
end
|
||||
|
||||
on :I=, "Add a path to the $LOAD_PATH", :as => Array, :delimiter => ":" do |load_path|
|
||||
on :I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":" do |load_path|
|
||||
load_path.map! do |path|
|
||||
/\A\.\// =~ path ? path : File.expand_path(path)
|
||||
end
|
||||
|
@ -220,6 +220,6 @@ Copyright (c) 2016 John Mair (banisterfiend)
|
|||
|
||||
on(:c, :context=,
|
||||
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
|
||||
:default => "Pry.toplevel_binding"
|
||||
default: "Pry.toplevel_binding"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -291,7 +291,7 @@ class Pry
|
|||
# @param [Integer] line_number (1-based)
|
||||
# @return [String] the code.
|
||||
def expression_at(line_number, consume = 0)
|
||||
self.class.expression_at(raw, line_number, :consume => consume)
|
||||
self.class.expression_at(raw, line_number, consume: consume)
|
||||
end
|
||||
|
||||
# Get the (approximate) Module.nesting at the give line number.
|
||||
|
|
|
@ -79,7 +79,7 @@ class Pry
|
|||
|
||||
def initialize(str, _pry_, options={})
|
||||
options = {
|
||||
:super => 0,
|
||||
super: 0,
|
||||
}.merge!(options)
|
||||
|
||||
@str = str
|
||||
|
|
|
@ -84,14 +84,14 @@ class Pry
|
|||
|
||||
def default_options(match)
|
||||
{
|
||||
:requires_gem => [],
|
||||
:keep_retval => false,
|
||||
:argument_required => false,
|
||||
:interpolate => true,
|
||||
:shellwords => true,
|
||||
:listing => (String === match ? match : match.inspect),
|
||||
:use_prefix => true,
|
||||
:takes_block => false
|
||||
requires_gem: [],
|
||||
keep_retval: false,
|
||||
argument_required: false,
|
||||
interpolate: true,
|
||||
shellwords: true,
|
||||
listing: (String === match ? match : match.inspect),
|
||||
use_prefix: true,
|
||||
takes_block: false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -214,8 +214,8 @@ class Pry
|
|||
original_options = cmd.options.dup
|
||||
|
||||
options = original_options.merge!({
|
||||
:desc => "Alias for `#{action}`",
|
||||
:listing => match
|
||||
desc: "Alias for `#{action}`",
|
||||
listing: match
|
||||
}).merge!(options)
|
||||
|
||||
# ensure default description is used if desc is nil
|
||||
|
@ -249,8 +249,8 @@ class Pry
|
|||
cmd = find_command_by_match_or_listing(search)
|
||||
|
||||
options = {
|
||||
:listing => new_match,
|
||||
:description => cmd.description
|
||||
listing: new_match,
|
||||
description: cmd.description
|
||||
}.merge!(options)
|
||||
|
||||
@commands[new_match] = cmd.dup
|
||||
|
@ -396,7 +396,7 @@ class Pry
|
|||
# @return [CommandSet::Result]
|
||||
def process_line(val, context={})
|
||||
if command = find_command(val)
|
||||
context = context.merge(:command_set => self)
|
||||
context = context.merge(command_set: self)
|
||||
retval = command.new(context).process_line(val)
|
||||
Result.new(true, retval)
|
||||
else
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
|
||||
group 'Editing'
|
||||
description 'Amend a line of input in multi-line mode.'
|
||||
command_options :interpolate => false, :listing => 'amend-line'
|
||||
command_options interpolate: false, listing: 'amend-line'
|
||||
|
||||
banner <<-'BANNER'
|
||||
Amend a line of input in multi-line mode. `amend-line N`, where the N represents
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match(/^\s*!\s*$/)
|
||||
group 'Editing'
|
||||
description 'Clear the input buffer.'
|
||||
command_options :use_prefix => false
|
||||
command_options use_prefix: false
|
||||
|
||||
banner <<-'BANNER'
|
||||
Clear the input buffer. Useful if the parsing process goes wrong and you get
|
||||
|
|
|
@ -23,12 +23,12 @@ class Pry
|
|||
BANNER
|
||||
|
||||
def options(opt)
|
||||
opt.on :ex, "Show the context of the last exception", :optional_argument => true, :as => Integer
|
||||
opt.on :i, :in, "Show one or more entries from Pry's expression history", :optional_argument => true, :as => Range, :default => -5..-1
|
||||
opt.on :s, :start, "Starting line (defaults to the first line)", :optional_argument => true, :as => Integer
|
||||
opt.on :e, :end, "Ending line (defaults to the last line)", :optional_argument => true, :as => Integer
|
||||
opt.on :ex, "Show the context of the last exception", optional_argument: true, as: Integer
|
||||
opt.on :i, :in, "Show one or more entries from Pry's expression history", optional_argument: true, as: Range, default: -5..-1
|
||||
opt.on :s, :start, "Starting line (defaults to the first line)", optional_argument: true, as: Integer
|
||||
opt.on :e, :end, "Ending line (defaults to the last line)", optional_argument: true, as: Integer
|
||||
opt.on :l, :'line-numbers', "Show line numbers"
|
||||
opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", :argument => true, :as => Symbol
|
||||
opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", argument: true, as: Symbol
|
||||
end
|
||||
|
||||
def process
|
||||
|
|
|
@ -29,17 +29,17 @@ class Pry
|
|||
@output_result_ranges = []
|
||||
|
||||
opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range",
|
||||
:optional_argument => true, :as => Range, :default => 1..-1
|
||||
optional_argument: true, as: Range, default: 1..-1
|
||||
opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
|
||||
:optional_argument => true, :as => Range, :default => -5..-1 do |r|
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
output_result_ranges << (r || (-5..-1))
|
||||
end
|
||||
opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
|
||||
:optional_argument => true, :as => Range, :default => -5..-1 do |r|
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
input_expression_ranges << (r || (-5..-1))
|
||||
end
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
|
||||
:as => :count
|
||||
as: :count
|
||||
opt.on :d, :doc, "Select lines from the code object's documentation"
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ class Pry
|
|||
#
|
||||
# @return [Pry::WrappedModule, Pry::Method, Pry::Command]
|
||||
def code_object
|
||||
Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super])
|
||||
Pry::CodeObject.lookup(obj_name, _pry_, super: opts[:super])
|
||||
end
|
||||
|
||||
# Given a string and a range, return the `range` lines of that
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Pry
|
||||
Pry::Commands.instance_eval do
|
||||
command "nyan-cat", "", :requires_gem => ["nyancat"] do
|
||||
command "nyan-cat", "", requires_gem: ["nyancat"] do
|
||||
run ".nyancat"
|
||||
end
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ class Pry
|
|||
|
||||
def options(opt)
|
||||
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
|
||||
:optional_argument => true, :as => Integer
|
||||
optional_argument: true, as: Integer
|
||||
opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
|
||||
:optional_argument => true, :as => Range, :default => -1..-1
|
||||
optional_argument: true, as: Range, default: -1..-1
|
||||
opt.on :t, :temp, "Open an empty temporary file"
|
||||
opt.on :l, :line, "Jump to this line in the opened file",
|
||||
:argument => true, :as => Integer
|
||||
argument: true, as: Integer
|
||||
opt.on :n, :"no-reload", "Don't automatically reload the edited file"
|
||||
opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
|
||||
opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'exit'
|
||||
group 'Navigating Pry'
|
||||
description 'Pop the previous binding.'
|
||||
command_options :keep_retval => true
|
||||
command_options keep_retval: true
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: exit [OPTIONS] [--help]
|
||||
|
|
|
@ -5,7 +5,7 @@ class Pry
|
|||
match 'find-method'
|
||||
group 'Context'
|
||||
description 'Recursively search for a method within a Class/Module or the current namespace.'
|
||||
command_options :shellwords => false
|
||||
command_options shellwords: false
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: find-method [-n|-c] METHOD [NAMESPACE]
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'gem-cd'
|
||||
group 'Gems'
|
||||
description "Change working directory to specified gem's directory."
|
||||
command_options :argument_required => true
|
||||
command_options argument_required: true
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: gem-cd GEM_NAME
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'gem-install'
|
||||
group 'Gems'
|
||||
description 'Install a gem and refresh the gem cache.'
|
||||
command_options :argument_required => true
|
||||
command_options argument_required: true
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: gem-install GEM_NAME
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'gem-open'
|
||||
group 'Gems'
|
||||
description 'Opens the working directory of the gem in your editor.'
|
||||
command_options :argument_required => true
|
||||
command_options argument_required: true
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: gem-open GEM_NAME
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'gist'
|
||||
group 'Misc'
|
||||
description 'Upload code, docs, history to https://gist.github.com/.'
|
||||
command_options :requires_gem => "gist"
|
||||
command_options requires_gem: "gist"
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: gist [OPTIONS] [--help]
|
||||
|
@ -22,8 +22,8 @@ class Pry
|
|||
def options(opt)
|
||||
CodeCollector.inject_options(opt)
|
||||
opt.on :login, "Authenticate the gist gem with GitHub"
|
||||
opt.on :p, :public, "Create a public gist (default: false)", :default => false
|
||||
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :default => false
|
||||
opt.on :p, :public, "Create a public gist (default: false)", default: false
|
||||
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", default: false
|
||||
end
|
||||
|
||||
def process
|
||||
|
@ -81,7 +81,7 @@ class Pry
|
|||
end
|
||||
|
||||
def gist_content(content, filename)
|
||||
response = ::Gist.gist(content, :filename => filename || "pry_gist.rb", :public => !!opts[:p])
|
||||
response = ::Gist.gist(content, filename: filename || "pry_gist.rb", public: !!opts[:p])
|
||||
if response
|
||||
url = response['html_url']
|
||||
message = "Gist created at URL #{url}"
|
||||
|
|
|
@ -21,13 +21,13 @@ class Pry
|
|||
|
||||
def options(opt)
|
||||
opt.on :a, :all, "Display all history"
|
||||
opt.on :H, :head, "Display the first N items", :optional_argument => true, :as => Integer
|
||||
opt.on :T, :tail, "Display the last N items", :optional_argument => true, :as => Integer
|
||||
opt.on :s, :show, "Show the given range of lines", :optional_argument => true, :as => Range
|
||||
opt.on :G, :grep, "Show lines matching the given pattern", :argument => true, :as => String
|
||||
opt.on :H, :head, "Display the first N items", optional_argument: true, as: Integer
|
||||
opt.on :T, :tail, "Display the last N items", optional_argument: true, as: Integer
|
||||
opt.on :s, :show, "Show the given range of lines", optional_argument: true, as: Range
|
||||
opt.on :G, :grep, "Show lines matching the given pattern", argument: true, as: String
|
||||
opt.on :c, :clear , "Clear the current session's history"
|
||||
opt.on :r, :replay, "Replay a line or range of lines", :argument => true, :as => Range
|
||||
opt.on :save, "Save history to a file", :argument => true, :as => Range
|
||||
opt.on :r, :replay, "Replay a line or range of lines", argument: true, as: Range
|
||||
opt.on :save, "Save history to a file", argument: true, as: Range
|
||||
opt.on :e, :'exclude-pry', "Exclude Pry commands from the history"
|
||||
opt.on :n, :'no-numbers', "Omit line numbers"
|
||||
end
|
||||
|
@ -120,7 +120,7 @@ class Pry
|
|||
check_for_juxtaposed_replay(replay_sequence)
|
||||
|
||||
replay_sequence.lines.each do |line|
|
||||
_pry_.eval line, :generated => true
|
||||
_pry_.eval line, generated: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,31 +2,31 @@ require 'pry/commands/ls/ls_entity'
|
|||
class Pry
|
||||
class Command::Ls < Pry::ClassCommand
|
||||
DEFAULT_OPTIONS = {
|
||||
:heading_color => :bright_blue,
|
||||
:public_method_color => :default,
|
||||
:private_method_color => :blue,
|
||||
:protected_method_color => :blue,
|
||||
:method_missing_color => :bright_red,
|
||||
:local_var_color => :yellow,
|
||||
:pry_var_color => :default, # e.g. _, _pry_, _file_
|
||||
:instance_var_color => :blue, # e.g. @foo
|
||||
:class_var_color => :bright_blue, # e.g. @@foo
|
||||
:global_var_color => :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
||||
:builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID
|
||||
:pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
||||
:constant_color => :default, # e.g. VERSION, ARGF
|
||||
:class_constant_color => :blue, # e.g. Object, Kernel
|
||||
:exception_constant_color => :magenta, # e.g. Exception, RuntimeError
|
||||
:unloaded_constant_color => :yellow, # Any constant that is still in .autoload? state
|
||||
:separator => " ",
|
||||
:ceiling => [Object, Module, Class]
|
||||
heading_color: :bright_blue,
|
||||
public_method_color: :default,
|
||||
private_method_color: :blue,
|
||||
protected_method_color: :blue,
|
||||
method_missing_color: :bright_red,
|
||||
local_var_color: :yellow,
|
||||
pry_var_color: :default, # e.g. _, _pry_, _file_
|
||||
instance_var_color: :blue, # e.g. @foo
|
||||
class_var_color: :bright_blue, # e.g. @@foo
|
||||
global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
||||
builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
|
||||
pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
||||
constant_color: :default, # e.g. VERSION, ARGF
|
||||
class_constant_color: :blue, # e.g. Object, Kernel
|
||||
exception_constant_color: :magenta, # e.g. Exception, RuntimeError
|
||||
unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
|
||||
separator: " ",
|
||||
ceiling: [Object, Module, Class]
|
||||
}
|
||||
|
||||
|
||||
match 'ls'
|
||||
group 'Context'
|
||||
description 'Show the list of vars and methods in the current scope.'
|
||||
command_options :shellwords => false, :interpolate => false
|
||||
command_options shellwords: false, interpolate: false
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
|
||||
|
@ -60,7 +60,7 @@ class Pry
|
|||
opt.on :c, :constants, "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" <<
|
||||
" " * 32 << "Constants that are pending autoload? are also shown (in yellow)"
|
||||
opt.on :i, :ivars, "Show instance variables (in blue) and class variables (in bright blue)"
|
||||
opt.on :G, :grep, "Filter output by regular expression", :argument => true
|
||||
opt.on :G, :grep, "Filter output by regular expression", argument: true
|
||||
if Object.respond_to?(:deprecate_constant)
|
||||
opt.on :d, :dconstants, "Show deprecated constants"
|
||||
end
|
||||
|
@ -80,11 +80,11 @@ class Pry
|
|||
@interrogatee = args.empty? ? target_self : target.eval(args.join(' '))
|
||||
raise_errors_if_arguments_are_weird
|
||||
ls_entity = LsEntity.new({
|
||||
:interrogatee => @interrogatee,
|
||||
:no_user_opts => no_user_opts?,
|
||||
:opts => opts,
|
||||
:args => args,
|
||||
:_pry_ => _pry_
|
||||
interrogatee: @interrogatee,
|
||||
no_user_opts: no_user_opts?,
|
||||
opts: opts,
|
||||
args: args,
|
||||
_pry_: _pry_
|
||||
})
|
||||
|
||||
_pry_.pager.page ls_entity.entities_table
|
||||
|
|
|
@ -31,7 +31,7 @@ class Pry
|
|||
' "open". `amend-line` can then be used to' \
|
||||
' modify the method.'
|
||||
|
||||
opt.on :e, :expression=, 'Executes until end of valid expression', :as => Integer
|
||||
opt.on :e, :expression=, 'Executes until end of valid expression', as: Integer
|
||||
opt.on :p, :print, 'Prints executed code'
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class Pry
|
|||
match(/raise-up(!?\b.*)/)
|
||||
group 'Context'
|
||||
description 'Raise an exception out of the current pry instance.'
|
||||
command_options :listing => 'raise-up'
|
||||
command_options listing: 'raise-up'
|
||||
|
||||
banner <<-BANNER
|
||||
Raise up, like exit, allows you to quit pry. Instead of returning a value
|
||||
|
|
|
@ -50,7 +50,7 @@ class Pry
|
|||
end
|
||||
|
||||
# Spin-up an RI insance.
|
||||
ri = RDoc::RI::PryDriver.new _pry_.pager, :use_stdout => true, :interactive => false
|
||||
ri = RDoc::RI::PryDriver.new _pry_.pager, use_stdout: true, interactive: false
|
||||
|
||||
begin
|
||||
ri.display_names [spec] # Get the documentation (finally!)
|
||||
|
|
|
@ -3,8 +3,8 @@ class Pry
|
|||
match(/\.(.*)/)
|
||||
group 'Input and Output'
|
||||
description "All text following a '.' is forwarded to the shell."
|
||||
command_options :listing => '.<shell command>', :use_prefix => false,
|
||||
:takes_block => true
|
||||
command_options listing: '.<shell command>', use_prefix: false,
|
||||
takes_block: true
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: .COMMAND_NAME
|
||||
|
|
|
@ -62,7 +62,7 @@ class Pry
|
|||
# Which sections to include in the 'header', can toggle: :owner,
|
||||
# :signature and visibility.
|
||||
def header_options
|
||||
super.merge :signature => true
|
||||
super.merge signature: true
|
||||
end
|
||||
|
||||
# figure out start line of docs by back-calculating based on
|
||||
|
|
|
@ -2,7 +2,7 @@ class Pry
|
|||
class Command::ShowInfo < Pry::ClassCommand
|
||||
extend Pry::Helpers::BaseHelpers
|
||||
|
||||
command_options :shellwords => false, :interpolate => false
|
||||
command_options shellwords: false, interpolate: false
|
||||
|
||||
def initialize(*)
|
||||
super
|
||||
|
@ -11,14 +11,14 @@ class Pry
|
|||
end
|
||||
|
||||
def options(opt)
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", :as => :count
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", as: :count
|
||||
opt.on :l, "line-numbers", "Show line numbers"
|
||||
opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)"
|
||||
opt.on :a, :all, "Show all definitions and monkeypatches of the module/class"
|
||||
end
|
||||
|
||||
def process
|
||||
code_object = Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super])
|
||||
code_object = Pry::CodeObject.lookup(obj_name, _pry_, super: opts[:super])
|
||||
raise CommandError, no_definition_message if !code_object
|
||||
@original_code_object = code_object
|
||||
|
||||
|
@ -151,17 +151,17 @@ class Pry
|
|||
|
||||
def method_sections(code_object)
|
||||
{
|
||||
:owner => "\n#{bold("Owner:")} #{code_object.owner || "N/A"}\n",
|
||||
:visibility => "#{bold("Visibility:")} #{code_object.visibility}",
|
||||
:signature => "\n#{bold("Signature:")} #{code_object.signature}"
|
||||
owner: "\n#{bold("Owner:")} #{code_object.owner || "N/A"}\n",
|
||||
visibility: "#{bold("Visibility:")} #{code_object.visibility}",
|
||||
signature: "\n#{bold("Signature:")} #{code_object.signature}"
|
||||
}.merge(header_options) { |key, old, new| (new && old).to_s }
|
||||
end
|
||||
|
||||
def header_options
|
||||
{
|
||||
:owner => true,
|
||||
:visibility => true,
|
||||
:signature => nil
|
||||
owner: true,
|
||||
visibility: true,
|
||||
signature: nil
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match 'stat'
|
||||
group 'Introspection'
|
||||
description 'View method information and set _file_ and _dir_ locals.'
|
||||
command_options :shellwords => false
|
||||
command_options shellwords: false
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: stat [OPTIONS] [METH]
|
||||
|
|
|
@ -5,7 +5,7 @@ class Pry
|
|||
match 'watch'
|
||||
group 'Context'
|
||||
description 'Watch the value of an expression and print a notification whenever it changes.'
|
||||
command_options :use_prefix => false
|
||||
command_options use_prefix: false
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: watch [EXPRESSION]
|
||||
|
@ -29,7 +29,7 @@ class Pry
|
|||
def options(opt)
|
||||
opt.on :d, :delete,
|
||||
"Delete the watch expression with the given index. If no index is given; clear all watch expressions.",
|
||||
:optional_argument => true, :as => Integer
|
||||
optional_argument: true, as: Integer
|
||||
opt.on :l, :list,
|
||||
"Show all current watch expressions and their values. Calling watch with no expressions or options will also show the watch expressions."
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
match(/wtf([?!]*)/)
|
||||
group 'Context'
|
||||
description 'Show the backtrace of the most recent exception.'
|
||||
options :listing => 'wtf?'
|
||||
options listing: 'wtf?'
|
||||
|
||||
banner <<-'BANNER'
|
||||
Usage: wtf[?|!]
|
||||
|
|
|
@ -8,8 +8,8 @@ class Pry
|
|||
@method_target = target
|
||||
opt.on :M, "instance-methods", "Operate on instance methods."
|
||||
opt.on :m, :methods, "Operate on methods."
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors.", :as => :count
|
||||
opt.on :c, :context, "Select object context to run under.", :argument => true do |context|
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors.", as: :count
|
||||
opt.on :c, :context, "Select object context to run under.", argument: true do |context|
|
||||
@method_target = Pry.binding_for(target.eval(context))
|
||||
end
|
||||
end
|
||||
|
@ -17,9 +17,9 @@ class Pry
|
|||
# Get the method object parsed by the slop instance
|
||||
def method_object
|
||||
@method_object ||= get_method_or_raise(args.empty? ? nil : args.join(" "), @method_target,
|
||||
:super => opts[:super],
|
||||
:instance => opts.present?(:'instance-methods') && !opts.present?(:'methods'),
|
||||
:methods => opts.present?(:'methods') && !opts.present?(:'instance-methods')
|
||||
super: opts[:super],
|
||||
instance: opts.present?(:'instance-methods') && !opts.present?(:'methods'),
|
||||
methods: opts.present?(:'methods') && !opts.present?(:'instance-methods')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,11 +2,11 @@ class Pry
|
|||
module Helpers
|
||||
def self.tablify_or_one_line(heading, things)
|
||||
plain_heading = Pry::Helpers::Text.strip_color(heading)
|
||||
attempt = Table.new(things, :column_count => things.size)
|
||||
attempt = Table.new(things, column_count: things.size)
|
||||
if attempt.fits_on_line?(Terminal.width! - plain_heading.size - 2)
|
||||
"#{heading}: #{attempt}\n"
|
||||
else
|
||||
"#{heading}: \n#{tablify_to_screen_width(things, :indent => ' ')}\n"
|
||||
"#{heading}: \n#{tablify_to_screen_width(things, indent: ' ')}\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Pry
|
|||
end
|
||||
|
||||
def self.tablify(things, line_length)
|
||||
table = Table.new(things, :column_count => things.size)
|
||||
table = Table.new(things, column_count: things.size)
|
||||
table.column_count -= 1 until 1 == table.column_count or
|
||||
table.fits_on_line?(line_length)
|
||||
table
|
||||
|
|
|
@ -56,8 +56,8 @@ class Pry
|
|||
elsif options[:methods]
|
||||
from_obj(target.eval("self"), name, target)
|
||||
else
|
||||
from_str(name, target, :instance => true) or
|
||||
from_str(name, target, :methods => true)
|
||||
from_str(name, target, instance: true) or
|
||||
from_str(name, target, methods: true)
|
||||
end
|
||||
|
||||
rescue Pry::RescuableException
|
||||
|
@ -142,7 +142,7 @@ class Pry
|
|||
def all_from_class(klass, include_super=true)
|
||||
%w(public protected private).flat_map do |visibility|
|
||||
safe_send(klass, :"#{visibility}_instance_methods", include_super).map do |method_name|
|
||||
new(safe_send(klass, :instance_method, method_name), :visibility => visibility.to_sym)
|
||||
new(safe_send(klass, :instance_method, method_name), visibility: visibility.to_sym)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -276,17 +276,17 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
|
|||
# Pry.run_command "ls -av", :show_output => true
|
||||
def self.run_command(command_string, options={})
|
||||
options = {
|
||||
:target => TOPLEVEL_BINDING,
|
||||
:show_output => true,
|
||||
:output => Pry.config.output,
|
||||
:commands => Pry.config.commands
|
||||
target: TOPLEVEL_BINDING,
|
||||
show_output: true,
|
||||
output: Pry.config.output,
|
||||
commands: Pry.config.commands
|
||||
}.merge!(options)
|
||||
|
||||
# :context for compatibility with <= 0.9.11.4
|
||||
target = options[:context] || options[:target]
|
||||
output = options[:show_output] ? options[:output] : StringIO.new
|
||||
|
||||
pry = Pry.new(:output => output, :target => target, :commands => options[:commands])
|
||||
pry = Pry.new(output: output, target: target, commands: options[:commands])
|
||||
pry.eval command_string
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -345,7 +345,7 @@ class Pry
|
|||
# (If nested sessions are going to exist, this method is fine, but a goal is
|
||||
# to come up with an alternative to nested sessions altogether.)
|
||||
def repl(target = nil)
|
||||
Pry::REPL.new(self, :target => target).start
|
||||
Pry::REPL.new(self, target: target).start
|
||||
end
|
||||
|
||||
def evaluate_ruby(code)
|
||||
|
@ -403,11 +403,11 @@ class Pry
|
|||
val = val.lstrip if /^\s\S/ !~ val
|
||||
val = val.chomp
|
||||
result = commands.process_line(val,
|
||||
:target => current_binding,
|
||||
:output => output,
|
||||
:eval_string => @eval_string,
|
||||
:pry_instance => self,
|
||||
:hooks => hooks
|
||||
target: current_binding,
|
||||
output: output,
|
||||
eval_string: @eval_string,
|
||||
pry_instance: self,
|
||||
hooks: hooks
|
||||
)
|
||||
|
||||
# set a temporary (just so we can inject the value we want into eval_string)
|
||||
|
@ -448,10 +448,10 @@ class Pry
|
|||
# pry_instance.run_command("ls -m")
|
||||
def run_command(val)
|
||||
commands.process_line(val,
|
||||
:eval_string => @eval_string,
|
||||
:target => current_binding,
|
||||
:pry_instance => self,
|
||||
:output => output
|
||||
eval_string: @eval_string,
|
||||
target: current_binding,
|
||||
pry_instance: self,
|
||||
output: output
|
||||
)
|
||||
Pry::Command::VOID_VALUE
|
||||
end
|
||||
|
@ -533,17 +533,17 @@ class Pry
|
|||
@indent.stack.last
|
||||
|
||||
c = Pry::Config.assign({
|
||||
:object => object,
|
||||
:nesting_level => binding_stack.size - 1,
|
||||
:open_token => open_token,
|
||||
:session_line => Pry.history.session_line_count + 1,
|
||||
:history_line => Pry.history.history_line_count + 1,
|
||||
:expr_number => input_array.count,
|
||||
:_pry_ => self,
|
||||
:binding_stack => binding_stack,
|
||||
:input_array => input_array,
|
||||
:eval_string => @eval_string,
|
||||
:cont => !@eval_string.empty?
|
||||
object: object,
|
||||
nesting_level: binding_stack.size - 1,
|
||||
open_token: open_token,
|
||||
session_line: Pry.history.session_line_count + 1,
|
||||
history_line: Pry.history.history_line_count + 1,
|
||||
expr_number: input_array.count,
|
||||
_pry_: self,
|
||||
binding_stack: binding_stack,
|
||||
input_array: input_array,
|
||||
eval_string: @eval_string,
|
||||
cont: !@eval_string.empty?
|
||||
})
|
||||
|
||||
Pry.critical_section do
|
||||
|
|
|
@ -42,7 +42,7 @@ class Pry
|
|||
end
|
||||
|
||||
content.lines.each do |line|
|
||||
break unless _pry_.eval line, :generated => true
|
||||
break unless _pry_.eval line, generated: true
|
||||
end
|
||||
|
||||
unless _pry_.eval_string.empty?
|
||||
|
|
|
@ -67,7 +67,7 @@ class Pry
|
|||
else
|
||||
Gem.user_dir
|
||||
end
|
||||
installer = Gem::DependencyInstaller.new(:install_dir => destination)
|
||||
installer = Gem::DependencyInstaller.new(install_dir: destination)
|
||||
installer.install(name)
|
||||
rescue Errno::EACCES
|
||||
raise CommandError,
|
||||
|
|
|
@ -24,15 +24,15 @@ class Pry::Slop
|
|||
|
||||
# Returns a default Hash of configuration options this Slop instance uses.
|
||||
DEFAULT_OPTIONS = {
|
||||
:strict => false,
|
||||
:help => false,
|
||||
:banner => nil,
|
||||
:ignore_case => false,
|
||||
:autocreate => false,
|
||||
:arguments => false,
|
||||
:optional_arguments => false,
|
||||
:multiple_switches => true,
|
||||
:longest_flag => 0
|
||||
strict: false,
|
||||
help: false,
|
||||
banner: nil,
|
||||
ignore_case: false,
|
||||
autocreate: false,
|
||||
arguments: false,
|
||||
optional_arguments: false,
|
||||
multiple_switches: true,
|
||||
longest_flag: 0
|
||||
}
|
||||
|
||||
class << self
|
||||
|
@ -135,7 +135,7 @@ class Pry::Slop
|
|||
end
|
||||
|
||||
if config[:help]
|
||||
on('-h', '--help', 'Display this help message.', :tail => true) do
|
||||
on('-h', '--help', 'Display this help message.', tail: true) do
|
||||
$stderr.puts help
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,18 +3,18 @@ class Pry::Slop
|
|||
|
||||
# The default Hash of configuration options this class uses.
|
||||
DEFAULT_OPTIONS = {
|
||||
:argument => false,
|
||||
:optional_argument => false,
|
||||
:tail => false,
|
||||
:default => nil,
|
||||
:callback => nil,
|
||||
:delimiter => ',',
|
||||
:limit => 0,
|
||||
:match => nil,
|
||||
:optional => true,
|
||||
:required => false,
|
||||
:as => String,
|
||||
:autocreated => false
|
||||
argument: false,
|
||||
optional_argument: false,
|
||||
tail: false,
|
||||
default: nil,
|
||||
callback: nil,
|
||||
delimiter: ',',
|
||||
limit: 0,
|
||||
match: nil,
|
||||
optional: true,
|
||||
required: false,
|
||||
as: String,
|
||||
autocreated: false
|
||||
}
|
||||
|
||||
attr_reader :short, :long, :description, :config, :types
|
||||
|
@ -41,12 +41,12 @@ class Pry::Slop
|
|||
@value = nil
|
||||
|
||||
@types = {
|
||||
:string => proc { |v| v.to_s },
|
||||
:symbol => proc { |v| v.to_sym },
|
||||
:integer => proc { |v| value_to_integer(v) },
|
||||
:float => proc { |v| value_to_float(v) },
|
||||
:range => proc { |v| value_to_range(v) },
|
||||
:count => proc { |v| @count }
|
||||
string: proc { |v| v.to_s },
|
||||
symbol: proc { |v| v.to_sym },
|
||||
integer: proc { |v| value_to_integer(v) },
|
||||
float: proc { |v| value_to_float(v) },
|
||||
range: proc { |v| value_to_range(v) },
|
||||
count: proc { |v| @count }
|
||||
}
|
||||
|
||||
if long && long.size > @slop.config[:longest_flag]
|
||||
|
|
|
@ -2,7 +2,7 @@ module Pry::Testable::Mockable
|
|||
def mock_command(cmd, args=[], opts={})
|
||||
output = StringIO.new
|
||||
pry = Pry.new(output: output)
|
||||
ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args)
|
||||
ret = cmd.new(opts.merge(pry_instance: pry, output: output)).call_safely(*args)
|
||||
Struct.new(:output, :return).new(output.string, ret)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class Pry::Testable::PryTester
|
|||
def_delegators :@pry, :eval_string, :eval_string=
|
||||
|
||||
def initialize(target = TOPLEVEL_BINDING, options = {})
|
||||
@pry = Pry.new(options.merge(:target => target))
|
||||
@pry = Pry.new(options.merge(target: target))
|
||||
@history = options[:history]
|
||||
@pry.inject_sticky_locals!
|
||||
reset_output
|
||||
|
|
|
@ -91,7 +91,7 @@ describe Pry::CodeObject do
|
|||
end
|
||||
|
||||
it 'looks up commands by :listing name as well' do
|
||||
@p.commands.command(/jeremy-.*/, "", :listing => "jeremy-baby") do
|
||||
@p.commands.command(/jeremy-.*/, "", listing: "jeremy-baby") do
|
||||
"lobster"
|
||||
end
|
||||
m = Pry::CodeObject.lookup("jeremy-baby", @p)
|
||||
|
@ -196,13 +196,13 @@ describe Pry::CodeObject do
|
|||
end
|
||||
|
||||
it 'should lookup original class with :super => 0' do
|
||||
m = Pry::CodeObject.lookup("CuteSubclass", @p, :super => 0)
|
||||
m = Pry::CodeObject.lookup("CuteSubclass", @p, super: 0)
|
||||
expect(m.is_a?(Pry::WrappedModule)).to eq true
|
||||
expect(m.wrapped).to eq CuteSubclass
|
||||
end
|
||||
|
||||
it 'should lookup immediate super class with :super => 1' do
|
||||
m = Pry::CodeObject.lookup("CuteSubclass", @p, :super => 1)
|
||||
m = Pry::CodeObject.lookup("CuteSubclass", @p, super: 1)
|
||||
expect(m.is_a?(Pry::WrappedModule)).to eq true
|
||||
expect(m.wrapped).to eq MyClassyWassy
|
||||
end
|
||||
|
@ -213,7 +213,7 @@ describe Pry::CodeObject do
|
|||
"lobster"
|
||||
end
|
||||
p.binding_stack = [binding]
|
||||
m = Pry::CodeObject.lookup("jeremy-jones", p, :super => 10)
|
||||
m = Pry::CodeObject.lookup("jeremy-jones", p, super: 10)
|
||||
expect(m.source).to match(/lobster/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ describe "commands" do
|
|||
alias_command "test-alias", "test-command"
|
||||
end
|
||||
|
||||
pry_tester(:commands => set).tap do |t|
|
||||
pry_tester(commands: set).tap do |t|
|
||||
expect(t.eval('test-command')).to eq t.eval('test-alias')
|
||||
end
|
||||
end
|
||||
|
@ -53,7 +53,7 @@ describe "commands" do
|
|||
alias_command "test-alias", "test-command"
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => set)
|
||||
t = pry_tester(commands: set)
|
||||
|
||||
t.process_command "test-alias hello baby duck"
|
||||
expect(t.last_output).to match(/testing hello baby duck/)
|
||||
|
@ -66,7 +66,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
obj = Class.new { @x = 10 }
|
||||
t = pry_tester(obj, :commands => set)
|
||||
t = pry_tester(obj, commands: set)
|
||||
|
||||
t.process_command "test-alias -i"
|
||||
expect(t.last_output).to match(/@x/)
|
||||
|
@ -79,7 +79,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
obj = Class.new { @x = Class.new { define_method(:plymouth) {} } }
|
||||
t = pry_tester(obj, :commands => set)
|
||||
t = pry_tester(obj, commands: set)
|
||||
t.process_command "test-alias @x"
|
||||
expect(t.last_output).to match(/plymouth/)
|
||||
end
|
||||
|
@ -92,7 +92,7 @@ describe "commands" do
|
|||
alias_command "test-alias", "duck"
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => set)
|
||||
t = pry_tester(commands: set)
|
||||
t.process_command "test-alias"
|
||||
expect(t.last_output).to match(/ducky/)
|
||||
end
|
||||
|
@ -106,7 +106,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
redirect_pry_io(InputTester.new("test-alias"), out1 = StringIO.new) do
|
||||
Pry.start self, :commands => set
|
||||
Pry.start self, commands: set
|
||||
end
|
||||
|
||||
expect(out1.string).to match(/ducky/)
|
||||
|
@ -124,7 +124,7 @@ describe "commands" do
|
|||
|
||||
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6", @bs1, "test-run",
|
||||
@self, @bs2, "exit-all")) do
|
||||
Pry.start(@o, :commands => set)
|
||||
Pry.start(@o, commands: set)
|
||||
end
|
||||
|
||||
expect(Pad.bs1.size).to eq 7
|
||||
|
@ -141,7 +141,7 @@ describe "commands" do
|
|||
end
|
||||
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6", @bs1, "test-run",
|
||||
@self, @bs2, "exit-all")) do
|
||||
Pry.start(@o, :commands => set)
|
||||
Pry.start(@o, commands: set)
|
||||
end
|
||||
|
||||
expect(Pad.bs1.size).to eq 7
|
||||
|
@ -158,7 +158,7 @@ describe "commands" do
|
|||
end
|
||||
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6", @bs1, "test-run",
|
||||
@self, @bs2, "exit-all")) do
|
||||
Pry.start(@o, :commands => set)
|
||||
Pry.start(@o, commands: set)
|
||||
end
|
||||
|
||||
expect(Pad.bs1.size).to eq 7
|
||||
|
@ -177,7 +177,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => klass).eval('run_v')).to match(/v command/)
|
||||
expect(pry_tester(commands: klass).eval('run_v')).to match(/v command/)
|
||||
end
|
||||
|
||||
it 'should run a regex command from within a command' do
|
||||
|
@ -191,7 +191,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => klass).eval('run_v')).to match(/v baby/)
|
||||
expect(pry_tester(commands: klass).eval('run_v')).to match(/v baby/)
|
||||
end
|
||||
|
||||
it 'should run a command from within a command with arguments' do
|
||||
|
@ -210,14 +210,14 @@ describe "commands" do
|
|||
end
|
||||
|
||||
["run_v_explicit_parameter", "run_v_embedded_parameter"].each do |cmd|
|
||||
expect(pry_tester(:commands => klass).eval(cmd)).to match(/v baby param/)
|
||||
expect(pry_tester(commands: klass).eval(cmd)).to match(/v baby param/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Pry#run_command" do
|
||||
it 'should run a command that modifies the passed in eval_string' do
|
||||
p = Pry.new(:output => @str_output)
|
||||
p = Pry.new(output: @str_output)
|
||||
p.eval "def hello\npeter pan\n"
|
||||
p.run_command "amend-line !"
|
||||
expect(p.eval_string).to match(/def hello/)
|
||||
|
@ -234,12 +234,12 @@ describe "commands" do
|
|||
|
||||
it 'should interpolate ruby code into commands' do
|
||||
set = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do |arg|
|
||||
command "hello", "", keep_retval: true do |arg|
|
||||
arg
|
||||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello #{Pad.bong}')).to match(/bong/)
|
||||
expect(pry_tester(commands: set).eval('hello #{Pad.bong}')).to match(/bong/)
|
||||
end
|
||||
|
||||
# bug fix for https://github.com/pry/pry/issues/170
|
||||
|
@ -253,12 +253,12 @@ describe "commands" do
|
|||
|
||||
it 'should NOT interpolate ruby code into commands if :interpolate => false' do
|
||||
set = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true, :interpolate => false do |arg|
|
||||
command "hello", "", keep_retval: true, interpolate: false do |arg|
|
||||
arg
|
||||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello #{Pad.bong}')).
|
||||
expect(pry_tester(commands: set).eval('hello #{Pad.bong}')).
|
||||
to match(/Pad\.bong/)
|
||||
end
|
||||
|
||||
|
@ -277,7 +277,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello baby')).
|
||||
expect(pry_tester(commands: set).eval('hello baby')).
|
||||
to match(/hello baby command/)
|
||||
end
|
||||
|
||||
|
@ -288,7 +288,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello baby john')).
|
||||
expect(pry_tester(commands: set).eval('hello baby john')).
|
||||
to match(/hello baby command john/)
|
||||
end
|
||||
|
||||
|
@ -300,7 +300,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello1')).to match(/hello1/)
|
||||
expect(pry_tester(commands: set).eval('hello1')).to match(/hello1/)
|
||||
end
|
||||
|
||||
it 'should create a regex command and pass captures into the args list before regular arguments' do
|
||||
|
@ -310,7 +310,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello1 baby')).to match(/hello 1 baby/)
|
||||
expect(pry_tester(commands: set).eval('hello1 baby')).to match(/hello 1 baby/)
|
||||
end
|
||||
|
||||
it 'should create a regex command and interpolate the captures' do
|
||||
|
@ -321,7 +321,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
bong = "bong"
|
||||
expect(pry_tester(binding, :commands => set).eval('hello #{bong}')).
|
||||
expect(pry_tester(binding, commands: set).eval('hello #{bong}')).
|
||||
to match(/hello #{bong}/)
|
||||
end
|
||||
|
||||
|
@ -336,7 +336,7 @@ describe "commands" do
|
|||
bong = 'bong'
|
||||
bang = 'bang'
|
||||
|
||||
expect(pry_tester(binding, :commands => set).
|
||||
expect(pry_tester(binding, commands: set).
|
||||
eval('hellojohn #{bing} #{bong} #{bang}')).
|
||||
to match(/hello john #{bing} #{bong} #{bang}/)
|
||||
end
|
||||
|
@ -348,7 +348,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => set).eval('hello baby')).to match(/hello nil baby/)
|
||||
expect(pry_tester(commands: set).eval('hello baby')).to match(/hello nil baby/)
|
||||
end
|
||||
|
||||
it 'should create a command in a nested context and that command should be accessible from the parent' do
|
||||
|
@ -363,48 +363,48 @@ describe "commands" do
|
|||
|
||||
it 'should define a command that keeps its return value' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do
|
||||
command "hello", "", keep_retval: true do
|
||||
:kept_hello
|
||||
end
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => klass)
|
||||
t = pry_tester(commands: klass)
|
||||
t.eval("hello\n")
|
||||
expect(t.last_command_result).to eq :kept_hello
|
||||
end
|
||||
|
||||
it 'should define a command that does NOT keep its return value' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => false do
|
||||
command "hello", "", keep_retval: false do
|
||||
:kept_hello
|
||||
end
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => klass)
|
||||
t = pry_tester(commands: klass)
|
||||
expect(t.eval("hello\n")).to eq ''
|
||||
expect(t.last_command_result).to eq Pry::Command::VOID_VALUE
|
||||
end
|
||||
|
||||
it 'should define a command that keeps its return value even when nil' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do
|
||||
command "hello", "", keep_retval: true do
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => klass)
|
||||
t = pry_tester(commands: klass)
|
||||
t.eval("hello\n")
|
||||
expect(t.last_command_result).to eq nil
|
||||
end
|
||||
|
||||
it 'should define a command that keeps its return value but does not return when value is void' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do
|
||||
command "hello", "", keep_retval: true do
|
||||
void
|
||||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => klass).eval("hello\n").empty?).to eq true
|
||||
expect(pry_tester(commands: klass).eval("hello\n").empty?).to eq true
|
||||
end
|
||||
|
||||
it 'a command (with :keep_retval => false) that replaces eval_string with a valid expression should not have the expression value suppressed' do
|
||||
|
@ -415,7 +415,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
redirect_pry_io(InputTester.new('def yo', 'hello'), @str_output) do
|
||||
Pry.start self, :commands => klass
|
||||
Pry.start self, commands: klass
|
||||
end
|
||||
|
||||
expect(@str_output.string).to match(/6/)
|
||||
|
@ -423,23 +423,23 @@ describe "commands" do
|
|||
|
||||
it 'a command (with :keep_retval => true) that replaces eval_string with a valid expression should overwrite the eval_string with the return value' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do
|
||||
command "hello", "", keep_retval: true do
|
||||
eval_string.replace("6")
|
||||
7
|
||||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => klass).eval("def yo\nhello\n")).to eq 7
|
||||
expect(pry_tester(commands: klass).eval("def yo\nhello\n")).to eq 7
|
||||
end
|
||||
|
||||
it 'a command that return a value in a multi-line expression should clear the expression and return the value' do
|
||||
klass = Pry::CommandSet.new do
|
||||
command "hello", "", :keep_retval => true do
|
||||
command "hello", "", keep_retval: true do
|
||||
5
|
||||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(:commands => klass).eval("def yo\nhello\n")).to eq 5
|
||||
expect(pry_tester(commands: klass).eval("def yo\nhello\n")).to eq 5
|
||||
end
|
||||
|
||||
it 'should set the commands default, and the default should be overridable' do
|
||||
|
@ -457,7 +457,7 @@ describe "commands" do
|
|||
|
||||
Pry.config.commands = klass
|
||||
expect(pry_tester.eval("hello")).to eq "hello world\n"
|
||||
expect(pry_tester(:commands => other_klass).eval("goodbye")).to eq "goodbye world\n"
|
||||
expect(pry_tester(commands: other_klass).eval("goodbye")).to eq "goodbye world\n"
|
||||
end
|
||||
|
||||
it 'should inherit commands from Pry::Commands' do
|
||||
|
@ -495,8 +495,8 @@ describe "commands" do
|
|||
child_klass = Pry::CommandSet.new klass do
|
||||
end
|
||||
|
||||
mock_pry(Pry.binding_for('john'), "v", :print => proc {}, :commands => child_klass,
|
||||
:output => @str_output)
|
||||
mock_pry(Pry.binding_for('john'), "v", print: proc {}, commands: child_klass,
|
||||
output: @str_output)
|
||||
|
||||
expect(@str_output.string).to eq "john\n"
|
||||
end
|
||||
|
@ -540,18 +540,18 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
t = pry_tester(:commands => klass)
|
||||
t = pry_tester(commands: klass)
|
||||
expect(t.eval('jump-to')).to eq "jump-to the music\n"
|
||||
expect(t.eval('help')).to eq "help to the music\n"
|
||||
end
|
||||
|
||||
it 'should run a command with no parameter' do
|
||||
expect(pry_tester(:commands => @command_tester).eval('command1')).
|
||||
expect(pry_tester(commands: @command_tester).eval('command1')).
|
||||
to eq "command1\n"
|
||||
end
|
||||
|
||||
it 'should run a command with one parameter' do
|
||||
expect(pry_tester(:commands => @command_tester).eval('command2 horsey')).
|
||||
expect(pry_tester(commands: @command_tester).eval('command2 horsey')).
|
||||
to eq "horsey\n"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
@ctx = {
|
||||
:target => binding,
|
||||
:command_set => @set,
|
||||
:pry_instance => Pry.new(output: StringIO.new)
|
||||
target: binding,
|
||||
command_set: @set,
|
||||
pry_instance: Pry.new(output: StringIO.new)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should be able to remove its own commands, by listing name' do
|
||||
@set.command(/^foo1/, 'desc', :listing => 'foo') {}
|
||||
@set.command(/^foo1/, 'desc', listing: 'foo') {}
|
||||
@set.delete 'foo'
|
||||
|
||||
expect { @set.run_command @ctx, /^foo1/ }.to raise_error Pry::NoCommandError
|
||||
|
@ -125,7 +125,7 @@ describe Pry::CommandSet do
|
|||
run = false
|
||||
|
||||
other_set = Pry::CommandSet.new do
|
||||
command(/^foo1/, 'desc', :listing => 'foo') { run = true }
|
||||
command(/^foo1/, 'desc', listing: 'foo') { run = true }
|
||||
end
|
||||
|
||||
@set.import_from(other_set, 'foo')
|
||||
|
@ -195,7 +195,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should inherit options from original command' do
|
||||
run = false
|
||||
@set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true }
|
||||
@set.command('foo', 'stuff', shellwords: true, interpolate: false) { run = true }
|
||||
|
||||
@set.alias_command 'bar', 'foo'
|
||||
expect(@set['bar'].options[:shellwords]).to eq @set['foo'].options[:shellwords]
|
||||
|
@ -210,7 +210,7 @@ describe Pry::CommandSet do
|
|||
run = false
|
||||
@set.command('foo', 'stuff') { run = true }
|
||||
|
||||
@set.alias_command 'bar', 'foo', :desc => "tobina"
|
||||
@set.alias_command 'bar', 'foo', desc: "tobina"
|
||||
expect(@set['bar'].match).to eq 'bar'
|
||||
expect(@set['bar'].description).to eq "tobina"
|
||||
|
||||
|
@ -220,7 +220,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it "should be able to alias a command by its invocation line" do
|
||||
run = false
|
||||
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
||||
@set.command(/^foo1/, 'stuff', listing: 'foo') { run = true }
|
||||
|
||||
@set.alias_command 'bar', 'foo1'
|
||||
expect(@set['bar'].match).to eq 'bar'
|
||||
|
@ -232,15 +232,15 @@ describe Pry::CommandSet do
|
|||
|
||||
it "should be able to specify options when creating alias" do
|
||||
run = false
|
||||
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
||||
@set.command(/^foo1/, 'stuff', listing: 'foo') { run = true }
|
||||
|
||||
@set.alias_command(/^b.r/, 'foo1', :listing => "bar")
|
||||
@set.alias_command(/^b.r/, 'foo1', listing: "bar")
|
||||
expect(@set.to_hash[/^b.r/].options[:listing]).to eq "bar"
|
||||
end
|
||||
|
||||
it "should set description to default if description parameter is nil" do
|
||||
run = false
|
||||
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
||||
@set.command(/^foo1/, 'stuff', listing: 'foo') { run = true }
|
||||
|
||||
@set.alias_command "bar", 'foo1'
|
||||
expect(@set["bar"].description).to eq "Alias for `foo1`"
|
||||
|
@ -260,7 +260,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should get the descriptions of commands, by listing' do
|
||||
@set.command(/^foo1/, 'bar', :listing => 'foo') {}
|
||||
@set.command(/^foo1/, 'bar', listing: 'foo') {}
|
||||
expect(@set.desc('foo')).to eq 'bar'
|
||||
end
|
||||
|
||||
|
@ -270,12 +270,12 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should be able to keep return values' do
|
||||
@set.command('foo', '', :keep_retval => true) { 3 }
|
||||
@set.command('foo', '', keep_retval: true) { 3 }
|
||||
expect(@set.run_command(@ctx, 'foo')).to eq 3
|
||||
end
|
||||
|
||||
it 'should be able to keep return values, even if return value is nil' do
|
||||
@set.command('foo', '', :keep_retval => true) { nil }
|
||||
@set.command('foo', '', keep_retval: true) { nil }
|
||||
expect(@set.run_command(@ctx, 'foo')).to eq nil
|
||||
end
|
||||
|
||||
|
@ -285,7 +285,7 @@ describe Pry::CommandSet do
|
|||
|
||||
@set.run_command(@ctx, 'foo')
|
||||
expect(Pry::Command.subclass('foo', '', {}, Module.new)
|
||||
.new({:target => binding}))
|
||||
.new({target: binding}))
|
||||
.not_to(respond_to :my_helper)
|
||||
end
|
||||
|
||||
|
@ -338,7 +338,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should provide a :listing for a command that differs from its name' do
|
||||
@set.command 'foo', "", :listing => 'bar' do;end
|
||||
@set.command 'foo', "", listing: 'bar' do;end
|
||||
expect(@set['foo'].options[:listing]).to eq 'bar'
|
||||
end
|
||||
|
||||
|
@ -361,7 +361,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should accept listing name when renaming a command' do
|
||||
run = false
|
||||
@set.command('foo', "", :listing => 'love') { run = true }
|
||||
@set.command('foo', "", listing: 'love') { run = true }
|
||||
@set.rename_command('bar', 'love')
|
||||
@set.run_command(@ctx, 'bar')
|
||||
expect(run).to eq true
|
||||
|
@ -381,7 +381,7 @@ describe Pry::CommandSet do
|
|||
desc = "hello"
|
||||
listing = "bing"
|
||||
@set.command('foo') { }
|
||||
@set.rename_command('bar', 'foo', :description => desc, :listing => listing, :keep_retval => true)
|
||||
@set.rename_command('bar', 'foo', description: desc, listing: listing, keep_retval: true)
|
||||
expect(@set['bar'].description).to eq desc
|
||||
expect(@set['bar'].options[:listing]).to eq listing
|
||||
expect(@set['bar'].options[:keep_retval]).to eq true
|
||||
|
@ -401,7 +401,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should be called before the original command, using listing name' do
|
||||
foo = []
|
||||
@set.command(/^foo1/, '', :listing => 'foo') { foo << 1 }
|
||||
@set.command(/^foo1/, '', listing: 'foo') { foo << 1 }
|
||||
@set.before_command('foo') { foo << 2 }
|
||||
@set.run_command(@ctx, /^foo1/)
|
||||
|
||||
|
@ -445,7 +445,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should be called after the original command, using listing name' do
|
||||
foo = []
|
||||
@set.command(/^foo1/, '', :listing => 'foo') { foo << 1 }
|
||||
@set.command(/^foo1/, '', listing: 'foo') { foo << 1 }
|
||||
@set.after_command('foo') { foo << 2 }
|
||||
@set.run_command(@ctx, /^foo1/)
|
||||
|
||||
|
@ -465,7 +465,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should determine the return value for the command' do
|
||||
@set.command('foo', 'bar', :keep_retval => true) { 1 }
|
||||
@set.command('foo', 'bar', keep_retval: true) { 1 }
|
||||
@set.after_command('foo') { 2 }
|
||||
expect(@set.run_command(@ctx, 'foo')).to eq 2
|
||||
end
|
||||
|
@ -529,7 +529,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should not find commands by listing' do
|
||||
@set.command(/werewol(f|ve)s?/, 'only once a month', :listing => "angua"){ }
|
||||
@set.command(/werewol(f|ve)s?/, 'only once a month', listing: "angua"){ }
|
||||
expect(@set.find_command('angua')).to eq nil
|
||||
end
|
||||
|
||||
|
@ -546,7 +546,7 @@ describe Pry::CommandSet do
|
|||
it "should find commands that don't use the prefix" do
|
||||
begin
|
||||
Pry.config.command_prefix = '%'
|
||||
cmd = @set.command('colon', 'Sergeant Fred', :use_prefix => false){ }
|
||||
cmd = @set.command('colon', 'Sergeant Fred', use_prefix: false){ }
|
||||
expect(@set.find_command('colon')).to eq cmd
|
||||
ensure
|
||||
Pry.config.command_prefix = ''
|
||||
|
@ -603,7 +603,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should return Result.new(true, retval) if the command is keep_retval' do
|
||||
@set.create_command('magrat', 'the maiden', :keep_retval => true) do
|
||||
@set.create_command('magrat', 'the maiden', keep_retval: true) do
|
||||
def process; 42; end
|
||||
end
|
||||
|
||||
|
@ -615,10 +615,10 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should pass through context' do
|
||||
ctx = {
|
||||
:eval_string => "bloomers",
|
||||
:pry_instance => Object.new,
|
||||
:output => StringIO.new,
|
||||
:target => binding
|
||||
eval_string: "bloomers",
|
||||
pry_instance: Object.new,
|
||||
output: StringIO.new,
|
||||
target: binding
|
||||
}
|
||||
|
||||
inside = inner_scope do |probe|
|
||||
|
|
|
@ -10,7 +10,7 @@ describe "Pry::Command" do
|
|||
describe 'call_safely' do
|
||||
|
||||
it 'should display a message if gems are missing' do
|
||||
cmd = @set.create_command "ford-prefect", "From a planet near Beetlegeuse", :requires_gem => %w(ghijkl) do
|
||||
cmd = @set.create_command "ford-prefect", "From a planet near Beetlegeuse", requires_gem: %w(ghijkl) do
|
||||
#
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should abort early if arguments are required' do
|
||||
cmd = @set.create_command 'arthur-dent', "Doesn't understand Thursdays", :argument_required => true do
|
||||
cmd = @set.create_command 'arthur-dent', "Doesn't understand Thursdays", argument_required: true do
|
||||
#
|
||||
end
|
||||
|
||||
|
@ -36,7 +36,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should return the return value with keep_retval' do
|
||||
cmd = @set.create_command 'tricia-mcmillian', "a.k.a Trillian", :keep_retval => true do
|
||||
cmd = @set.create_command 'tricia-mcmillian', "a.k.a Trillian", keep_retval: true do
|
||||
def process
|
||||
5
|
||||
end
|
||||
|
@ -109,7 +109,7 @@ describe "Pry::Command" do
|
|||
|
||||
# TODO: This strikes me as rather silly...
|
||||
it 'should return the value from the last hook with keep_retval' do
|
||||
cmd = @set.create_command 'slartibartfast', "Designs Fjords", :keep_retval => true do
|
||||
cmd = @set.create_command 'slartibartfast', "Designs Fjords", keep_retval: true do
|
||||
def process
|
||||
22
|
||||
end
|
||||
|
@ -129,7 +129,7 @@ describe "Pry::Command" do
|
|||
#
|
||||
end
|
||||
|
||||
expect(mock_command(@set['help'], %w(oolon-colluphid), :command_set => @set).output).to match(/Raving Atheist/)
|
||||
expect(mock_command(@set['help'], %w(oolon-colluphid), command_set: @set).output).to match(/Raving Atheist/)
|
||||
end
|
||||
|
||||
it 'should use slop to generate the help for classy commands' do
|
||||
|
@ -139,7 +139,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(mock_command(@set['help'], %w(eddie), :command_set => @set).output).to match(/Over-cheerful/)
|
||||
expect(mock_command(@set['help'], %w(eddie), command_set: @set).output).to match(/Over-cheerful/)
|
||||
end
|
||||
|
||||
it 'should provide --help for classy commands' do
|
||||
|
@ -176,11 +176,11 @@ describe "Pry::Command" do
|
|||
describe 'context' do
|
||||
let(:context) {
|
||||
{
|
||||
:target => binding,
|
||||
:output => StringIO.new,
|
||||
:eval_string => "eval-string",
|
||||
:command_set => @set,
|
||||
:pry_instance => Pry.new
|
||||
target: binding,
|
||||
output: StringIO.new,
|
||||
eval_string: "eval-string",
|
||||
command_set: @set,
|
||||
pry_instance: Pry.new
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should work if neither options, nor setup is overridden' do
|
||||
cmd = @set.create_command 'wowbagger', "Immortal, insulting.", :keep_retval => true do
|
||||
cmd = @set.create_command 'wowbagger', "Immortal, insulting.", keep_retval: true do
|
||||
def process
|
||||
5
|
||||
end
|
||||
|
@ -265,7 +265,7 @@ describe "Pry::Command" do
|
|||
it 'should provide opts and args as provided by slop' do
|
||||
cmd = @set.create_command 'lintilla', "One of 800,000,000 clones" do
|
||||
def options(opt)
|
||||
opt.on :f, :four, "A numeric four", :as => Integer, :optional_argument => true
|
||||
opt.on :f, :four, "A numeric four", as: Integer, optional_argument: true
|
||||
end
|
||||
|
||||
def process
|
||||
|
@ -279,9 +279,9 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should allow overriding options after definition' do
|
||||
cmd = @set.create_command(/number-(one|two)/, "Lieutenants of the Golgafrinchan Captain", :shellwords => false) do
|
||||
cmd = @set.create_command(/number-(one|two)/, "Lieutenants of the Golgafrinchan Captain", shellwords: false) do
|
||||
|
||||
command_options :listing => 'number-one'
|
||||
command_options listing: 'number-one'
|
||||
end
|
||||
|
||||
expect(cmd.command_options[:shellwords]).to eq false
|
||||
|
@ -340,7 +340,7 @@ describe "Pry::Command" do
|
|||
describe "explicit classes" do
|
||||
before do
|
||||
@x = Class.new(Pry::ClassCommand) do
|
||||
options :baby => :pig
|
||||
options baby: :pig
|
||||
match(/goat/)
|
||||
description "waaaninngggiiigygygygygy"
|
||||
end
|
||||
|
@ -361,7 +361,7 @@ describe "Pry::Command" do
|
|||
cmd = @set.command('random-dent', &probe)
|
||||
|
||||
_foo = 5
|
||||
cmd.new(:target => binding).process_line 'random-dent #{1 + 2} #{3 + _foo}'
|
||||
cmd.new(target: binding).process_line 'random-dent #{1 + 2} #{3 + _foo}'
|
||||
}.to yield_with_args('3', '8')
|
||||
end
|
||||
|
||||
|
@ -375,7 +375,7 @@ describe "Pry::Command" do
|
|||
|
||||
it 'should not interpolate commands with :interpolate => false' do
|
||||
expect { |probe|
|
||||
cmd = @set.command('thor', 'norse god', :interpolate => false, &probe)
|
||||
cmd = @set.command('thor', 'norse god', interpolate: false, &probe)
|
||||
|
||||
cmd.new.process_line 'thor %(#{foo})'
|
||||
}.to yield_with_args('%(#{foo})')
|
||||
|
@ -391,7 +391,7 @@ describe "Pry::Command" do
|
|||
|
||||
it 'should split on spaces if shellwords is not used' do
|
||||
expect { |probe|
|
||||
cmd = @set.command('bugblatter-beast', 'would eat its grandmother', :shellwords => false, &probe)
|
||||
cmd = @set.command('bugblatter-beast', 'would eat its grandmother', shellwords: false, &probe)
|
||||
|
||||
cmd.new.process_line %(bugblatter-beast "of traal")
|
||||
}.to yield_with_args('"of', 'traal"')
|
||||
|
@ -417,7 +417,7 @@ describe "Pry::Command" do
|
|||
|
||||
_frankie = 'boyle'
|
||||
output = StringIO.new
|
||||
cmd.new(:target => binding, :output => output).process_line %(_frankie mouse)
|
||||
cmd.new(target: binding, output: output).process_line %(_frankie mouse)
|
||||
|
||||
expect(output.string).to match(/command .* conflicts/)
|
||||
|
||||
|
@ -433,7 +433,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
output = StringIO.new
|
||||
cmd.new(:target => binding, :output => output).process_line %(frankie = mouse)
|
||||
cmd.new(target: binding, output: output).process_line %(frankie = mouse)
|
||||
|
||||
expect(output.string).to match(/command .* conflicts/)
|
||||
|
||||
|
@ -460,12 +460,12 @@ describe "Pry::Command" do
|
|||
describe "block parameters" do
|
||||
before do
|
||||
@context = Object.new
|
||||
@set.command "walking-spanish", "down the hall", :takes_block => true do
|
||||
@set.command "walking-spanish", "down the hall", takes_block: true do
|
||||
insert_variable(:@x, command_block.call, target)
|
||||
end
|
||||
@set.import Pry::Commands
|
||||
|
||||
@t = pry_tester(@context, :commands => @set)
|
||||
@t = pry_tester(@context, commands: @set)
|
||||
end
|
||||
|
||||
it 'should accept multiline blocks' do
|
||||
|
@ -481,7 +481,7 @@ describe "Pry::Command" do
|
|||
it 'should accept normal parameters along with block' do
|
||||
@set.block_command "walking-spanish",
|
||||
"litella's been screeching for a blind pig.",
|
||||
:takes_block => true do |x, y|
|
||||
takes_block: true do |x, y|
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
insert_variable(:@block_var, command_block.call, target)
|
||||
|
@ -515,7 +515,7 @@ describe "Pry::Command" do
|
|||
|
||||
describe "arg_string" do
|
||||
it 'should remove block-related content from arg_string (with one normal arg)' do
|
||||
@set.block_command "walking-spanish", "down the hall", :takes_block => true do |x, y|
|
||||
@set.block_command "walking-spanish", "down the hall", takes_block: true do |x, y|
|
||||
insert_variable(:@arg_string, arg_string, target)
|
||||
insert_variable(:@x, x, target)
|
||||
end
|
||||
|
@ -526,7 +526,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should remove block-related content from arg_string (with no normal args)' do
|
||||
@set.block_command "walking-spanish", "down the hall", :takes_block => true do
|
||||
@set.block_command "walking-spanish", "down the hall", takes_block: true do
|
||||
insert_variable(:@arg_string, arg_string, target)
|
||||
end
|
||||
|
||||
|
@ -537,7 +537,7 @@ describe "Pry::Command" do
|
|||
|
||||
it 'should NOT remove block-related content from arg_string when :takes_block => false' do
|
||||
block_string = "| { :jesus }"
|
||||
@set.block_command "walking-spanish", "homemade special", :takes_block => false do
|
||||
@set.block_command "walking-spanish", "homemade special", takes_block: false do
|
||||
insert_variable(:@arg_string, arg_string, target)
|
||||
end
|
||||
|
||||
|
@ -550,7 +550,7 @@ describe "Pry::Command" do
|
|||
describe "args" do
|
||||
describe "block_command" do
|
||||
it "should remove block-related content from arguments" do
|
||||
@set.block_command "walking-spanish", "glass is full of sand", :takes_block => true do |x, y|
|
||||
@set.block_command "walking-spanish", "glass is full of sand", takes_block: true do |x, y|
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
end
|
||||
|
@ -562,7 +562,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it "should NOT remove block-related content from arguments if :takes_block => false" do
|
||||
@set.block_command "walking-spanish", "litella screeching for a blind pig", :takes_block => false do |x, y|
|
||||
@set.block_command "walking-spanish", "litella screeching for a blind pig", takes_block: false do |x, y|
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
end
|
||||
|
@ -576,7 +576,7 @@ describe "Pry::Command" do
|
|||
|
||||
describe "create_command" do
|
||||
it "should remove block-related content from arguments" do
|
||||
@set.create_command "walking-spanish", "punk sanders carved one out of wood", :takes_block => true do
|
||||
@set.create_command "walking-spanish", "punk sanders carved one out of wood", takes_block: true do
|
||||
def process(x, y)
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
|
@ -590,7 +590,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it "should NOT remove block-related content from arguments if :takes_block => false" do
|
||||
@set.create_command "walking-spanish", "down the hall", :takes_block => false do
|
||||
@set.create_command "walking-spanish", "down the hall", takes_block: false do
|
||||
def process(x, y)
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
|
@ -609,7 +609,7 @@ describe "Pry::Command" do
|
|||
describe "blocks can take parameters" do
|
||||
describe "{} style blocks" do
|
||||
it 'should accept multiple parameters' do
|
||||
@set.block_command "walking-spanish", "down the hall", :takes_block => true do
|
||||
@set.block_command "walking-spanish", "down the hall", takes_block: true do
|
||||
insert_variable(:@x, command_block.call(1, 2), target)
|
||||
end
|
||||
|
||||
|
@ -621,7 +621,7 @@ describe "Pry::Command" do
|
|||
|
||||
describe "do/end style blocks" do
|
||||
it 'should accept multiple parameters' do
|
||||
@set.create_command "walking-spanish", "litella", :takes_block => true do
|
||||
@set.create_command "walking-spanish", "litella", takes_block: true do
|
||||
def process
|
||||
insert_variable(:@x, command_block.call(1, 2), target)
|
||||
end
|
||||
|
@ -648,7 +648,7 @@ describe "Pry::Command" do
|
|||
describe "exposing block parameter" do
|
||||
describe "block_command" do
|
||||
it "should expose block in command_block method" do
|
||||
@set.block_command "walking-spanish", "glass full of sand", :takes_block => true do
|
||||
@set.block_command "walking-spanish", "glass full of sand", takes_block: true do
|
||||
insert_variable(:@x, command_block.call, target)
|
||||
end
|
||||
|
||||
|
@ -660,7 +660,7 @@ describe "Pry::Command" do
|
|||
|
||||
describe "create_command" do
|
||||
it "should NOT expose &block in create_command's process method" do
|
||||
@set.create_command "walking-spanish", "down the hall", :takes_block => true do
|
||||
@set.create_command "walking-spanish", "down the hall", takes_block: true do
|
||||
def process(&block)
|
||||
block.call
|
||||
end
|
||||
|
@ -671,7 +671,7 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it "should expose block in command_block method" do
|
||||
@set.create_command "walking-spanish", "homemade special", :takes_block => true do
|
||||
@set.create_command "walking-spanish", "homemade special", takes_block: true do
|
||||
def process
|
||||
insert_variable(:@x, command_block.call, target)
|
||||
end
|
||||
|
@ -692,7 +692,7 @@ describe "Pry::Command" do
|
|||
match(/my-*test/)
|
||||
description 'So just how many sound technicians does it take to' \
|
||||
'change a lightbulb? 1? 2? 3? 1-2-3? Testing?'
|
||||
options :shellwords => false, :listing => 'my-test'
|
||||
options shellwords: false, listing: 'my-test'
|
||||
|
||||
undef process if method_defined? :process
|
||||
|
||||
|
@ -719,14 +719,14 @@ describe "Pry::Command" do
|
|||
describe "command options hash" do
|
||||
it "is always present" do
|
||||
options_hash = {
|
||||
:requires_gem => [],
|
||||
:keep_retval => false,
|
||||
:argument_required => false,
|
||||
:interpolate => true,
|
||||
:shellwords => false,
|
||||
:listing => 'my-test',
|
||||
:use_prefix => true,
|
||||
:takes_block => false
|
||||
requires_gem: [],
|
||||
keep_retval: false,
|
||||
argument_required: false,
|
||||
interpolate: true,
|
||||
shellwords: false,
|
||||
listing: 'my-test',
|
||||
use_prefix: true,
|
||||
takes_block: false
|
||||
}
|
||||
expect(MyTestCommand.options).to eq options_hash
|
||||
end
|
||||
|
@ -748,7 +748,7 @@ describe "Pry::Command" do
|
|||
class MerryChristmas < Pry::ClassCommand
|
||||
match 'merry-christmas'
|
||||
description 'Merry Christmas!'
|
||||
command_options :listing => 'happy-holidays'
|
||||
command_options listing: 'happy-holidays'
|
||||
end
|
||||
Pry.config.commands.add_command MerryChristmas
|
||||
|
||||
|
@ -798,7 +798,7 @@ describe "Pry::Command" do
|
|||
|
||||
end.import Pry::Commands
|
||||
|
||||
@t = pry_tester(:commands => @set)
|
||||
@t = pry_tester(commands: @set)
|
||||
end
|
||||
|
||||
it 'should save state for the command on the Pry#command_state hash' do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../helper'
|
||||
|
||||
describe "exit" do
|
||||
before { @pry = Pry.new(:target => :outer, :output => StringIO.new) }
|
||||
before { @pry = Pry.new(target: :outer, output: StringIO.new) }
|
||||
|
||||
it "should pop a binding" do
|
||||
@pry.eval "cd :inner"
|
||||
|
|
|
@ -17,7 +17,7 @@ describe "help" do
|
|||
end
|
||||
|
||||
it 'should display help for a regex command with a "listing"' do
|
||||
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
|
||||
@set.command(/bar(.*)/, "Test listing", listing: "foo") do; end
|
||||
expect(pry_eval('help foo')).to match(/Test listing/)
|
||||
end
|
||||
|
||||
|
@ -27,8 +27,8 @@ describe "help" do
|
|||
end
|
||||
|
||||
it 'should display help for all commands with a description' do
|
||||
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
|
||||
@set.command "b", "description for b", :listing => "foo" do; end
|
||||
@set.command(/bar(.*)/, "Test listing", listing: "foo") do; end
|
||||
@set.command "b", "description for b", listing: "foo" do; end
|
||||
@set.command "c" do;end
|
||||
@set.command "d", "" do;end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "hist" do
|
|||
@hist = Pry.history
|
||||
|
||||
@str_output = StringIO.new
|
||||
@t = pry_tester :history => @hist do
|
||||
@t = pry_tester history: @hist do
|
||||
# For looking at what hist pushes into the input stack. The implementation
|
||||
# of this helper will definitely have to change at some point.
|
||||
def next_input
|
||||
|
|
|
@ -419,7 +419,7 @@ describe "show-doc" do
|
|||
end
|
||||
|
||||
it 'should display help for a regex command with a "listing"' do
|
||||
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
|
||||
@set.command(/bar(.*)/, "Test listing", listing: "foo") do; end
|
||||
expect(pry_eval('show-doc foo')).to match(/Test listing/)
|
||||
end
|
||||
|
||||
|
|
|
@ -705,7 +705,7 @@ describe "show-source" do
|
|||
end
|
||||
|
||||
it 'should show source for a command by listing name' do
|
||||
@set.command(/foo(.*)/, :body_of_foo_bar_regex, :listing => "bar") do; end
|
||||
@set.command(/foo(.*)/, :body_of_foo_bar_regex, listing: "bar") do; end
|
||||
|
||||
expect(pry_eval('show-source bar')).to match(/:body_of_foo_bar_regex/)
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ require "pry/input_completer"
|
|||
|
||||
def completer_test(bind, pry=nil, assert_flag=true)
|
||||
test = proc {|symbol|
|
||||
expect(Pry::InputCompleter.new(pry || Readline, pry).call(symbol[0..-2], :target => Pry.binding_for(bind)).include?(symbol)).to eq(assert_flag)}
|
||||
expect(Pry::InputCompleter.new(pry || Readline, pry).call(symbol[0..-2], target: Pry.binding_for(bind)).include?(symbol)).to eq(assert_flag)}
|
||||
return proc {|*symbols| symbols.each(&test) }
|
||||
end
|
||||
|
||||
|
@ -30,12 +30,12 @@ describe Pry::InputCompleter do
|
|||
# another jruby hack :((
|
||||
if !Pry::Helpers::BaseHelpers.jruby?
|
||||
it "should not crash if there's a Module that has a symbolic name." do
|
||||
expect { Pry::InputCompleter.new(Readline).call "a.to_s.", :target => Pry.binding_for(Object.new) }.not_to raise_error
|
||||
expect { Pry::InputCompleter.new(Readline).call "a.to_s.", target: Pry.binding_for(Object.new) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
it 'should take parenthesis and other characters into account for symbols' do
|
||||
expect { Pry::InputCompleter.new(Readline).call ":class)", :target => Pry.binding_for(Object.new) }.not_to raise_error
|
||||
expect { Pry::InputCompleter.new(Readline).call ":class)", target: Pry.binding_for(Object.new) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'should complete instance variables' do
|
||||
|
@ -115,7 +115,7 @@ describe Pry::InputCompleter do
|
|||
completer_test(binding).call('o.foo')
|
||||
|
||||
# trailing slash
|
||||
expect(Pry::InputCompleter.new(Readline).call('Mod2/', :target => Pry.binding_for(Mod)).include?('Mod2/')).to eq(true)
|
||||
expect(Pry::InputCompleter.new(Readline).call('Mod2/', target: Pry.binding_for(Mod)).include?('Mod2/')).to eq(true)
|
||||
end
|
||||
|
||||
it 'should complete for arbitrary scopes' do
|
||||
|
@ -130,7 +130,7 @@ describe Pry::InputCompleter do
|
|||
Con = :constant
|
||||
end
|
||||
|
||||
pry = Pry.new(:target => Baz)
|
||||
pry = Pry.new(target: Baz)
|
||||
pry.push_binding(Bar)
|
||||
|
||||
b = Pry.binding_for(Bar)
|
||||
|
@ -188,7 +188,7 @@ describe Pry::InputCompleter do
|
|||
completer_test(binding).call('o.foo')
|
||||
|
||||
# trailing slash
|
||||
expect(Pry::InputCompleter.new(Readline).call('Mod2/', :target => Pry.binding_for(Mod)).include?('Mod2/')).to eq(true)
|
||||
expect(Pry::InputCompleter.new(Readline).call('Mod2/', target: Pry.binding_for(Mod)).include?('Mod2/')).to eq(true)
|
||||
end
|
||||
|
||||
it 'should complete for arbitrary scopes' do
|
||||
|
@ -203,7 +203,7 @@ describe Pry::InputCompleter do
|
|||
Con = :constant
|
||||
end
|
||||
|
||||
pry = Pry.new(:target => Baz)
|
||||
pry = Pry.new(target: Baz)
|
||||
pry.push_binding(Bar)
|
||||
|
||||
b = Pry.binding_for(Bar)
|
||||
|
@ -213,7 +213,7 @@ describe Pry::InputCompleter do
|
|||
|
||||
it 'should not return nil in its output' do
|
||||
pry = Pry.new
|
||||
expect(Pry::InputCompleter.new(Readline, pry).call("pry.", :target => binding)).not_to include nil
|
||||
expect(Pry::InputCompleter.new(Readline, pry).call("pry.", target: binding)).not_to include nil
|
||||
end
|
||||
|
||||
it 'completes expressions with all available methods' do
|
||||
|
|
|
@ -7,13 +7,13 @@ describe "Pry.config.exception_whitelist" do
|
|||
|
||||
it 'should rescue all exceptions NOT specified on whitelist' do
|
||||
expect(Pry.config.exception_whitelist.include?(NameError)).to eq false
|
||||
expect { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => @str_output) }.not_to raise_error
|
||||
expect { Pry.start(self, input: StringIO.new("raise NameError\nexit"), output: @str_output) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'should NOT rescue exceptions specified on whitelist' do
|
||||
old_whitelist = Pry.config.exception_whitelist
|
||||
Pry.config.exception_whitelist = [NameError]
|
||||
expect { Pry.start(self, :input => StringIO.new("raise NameError"), :output => @str_output) }.to raise_error NameError
|
||||
expect { Pry.start(self, input: StringIO.new("raise NameError"), output: @str_output) }.to raise_error NameError
|
||||
Pry.config.exception_whitelist = old_whitelist
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require_relative '../helper'
|
|||
|
||||
describe 'Formatting Table' do
|
||||
it 'knows about colorized fitting' do
|
||||
t = Pry::Helpers::Table.new %w(hihi), :column_count => 1
|
||||
t = Pry::Helpers::Table.new %w(hihi), column_count: 1
|
||||
expect(t.fits_on_line?(4)).to eq true
|
||||
t.items = []
|
||||
expect(t.fits_on_line?(4)).to eq true
|
||||
|
|
|
@ -135,7 +135,7 @@ describe Pry do
|
|||
describe "saving to a file" do
|
||||
before do
|
||||
@histfile = Tempfile.new(["pryhistory", "txt"])
|
||||
@history = Pry::History.new(:file_path => @histfile.path)
|
||||
@history = Pry::History.new(file_path: @histfile.path)
|
||||
Pry.config.history.should_save = true
|
||||
@history.pusher = proc{ }
|
||||
end
|
||||
|
|
|
@ -314,7 +314,7 @@ describe Pry::Hooks do
|
|||
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| options = opt }
|
||||
|
||||
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
|
||||
Pry.start binding, :hello => :baby
|
||||
Pry.start binding, hello: :baby
|
||||
end
|
||||
|
||||
expect(options[:hello]).to eq :baby
|
||||
|
@ -329,7 +329,7 @@ describe Pry::Hooks do
|
|||
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
|
||||
|
||||
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
|
||||
Pry.start 5, :hello => :baby
|
||||
Pry.start 5, hello: :baby
|
||||
end
|
||||
|
||||
expect(b.is_a?(Binding)).to eq true
|
||||
|
@ -341,7 +341,7 @@ describe Pry::Hooks do
|
|||
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
|
||||
|
||||
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
|
||||
Pry.start 5, :hello => :baby
|
||||
Pry.start 5, hello: :baby
|
||||
end
|
||||
|
||||
expect(b.eval('self')).to eq 5
|
||||
|
@ -356,7 +356,7 @@ describe Pry::Hooks do
|
|||
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
|
||||
|
||||
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
|
||||
Pry.start binding, :hello => :baby
|
||||
Pry.start binding, hello: :baby
|
||||
end
|
||||
|
||||
expect(o.value).to eq true
|
||||
|
@ -377,7 +377,7 @@ describe Pry::Hooks do
|
|||
|
||||
begin
|
||||
redirect_pry_io(StringIO.new("raise great_escape"), StringIO.new) do
|
||||
Pry.start o, :hooks => Pry::Hooks.new.add_hook(:after_session, :cleanup) { array = nil }
|
||||
Pry.start o, hooks: Pry::Hooks.new.add_hook(:after_session, :cleanup) { array = nil }
|
||||
end
|
||||
rescue => ex
|
||||
exception = ex
|
||||
|
@ -399,7 +399,7 @@ describe Pry::Hooks do
|
|||
it 'should replace input code with code determined by hook' do
|
||||
hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, pry| code.replace(":little_duck") }
|
||||
redirect_pry_io(InputTester.new(":jemima", "exit-all"), out = StringIO.new) do
|
||||
Pry.start(self, :hooks => hooks)
|
||||
Pry.start(self, hooks: hooks)
|
||||
end
|
||||
expect(out.string).to match(/little_duck/)
|
||||
expect(out.string).not_to match(/jemima/)
|
||||
|
@ -417,7 +417,7 @@ describe Pry::Hooks do
|
|||
hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, pry| code.replace(":little_duck") }
|
||||
|
||||
redirect_pry_io(InputTester.new("how-do-you-like-your-blue-eyed-boy-now-mister-death", "exit-all"), out = StringIO.new) do
|
||||
Pry.start(self, :hooks => hooks, :commands => commands)
|
||||
Pry.start(self, hooks: hooks, commands: commands)
|
||||
end
|
||||
expect(out.string).to match(/in hours of bitterness i imagine balls of sapphire, of metal/)
|
||||
expect(out.string).not_to match(/little_duck/)
|
||||
|
|
|
@ -34,7 +34,7 @@ describe Pry::Method do
|
|||
|
||||
it 'should look up methods if :methods option provided' do
|
||||
klass = Class.new { def hello; end; def self.hello; end }
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {:methods => true})
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {methods: true})
|
||||
expect(meth).to eq klass.method(:hello)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ describe "Prompts" do
|
|||
it 'should get full config object' do
|
||||
config = nil
|
||||
redirect_pry_io(InputTester.new("exit-all")) do
|
||||
Pry.start(self, :prompt => proc { |v| config = v })
|
||||
Pry.start(self, prompt: proc { |v| config = v })
|
||||
end
|
||||
expect(config.is_a?(Pry::Config)).to eq true
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ describe "Prompts" do
|
|||
it 'should get full config object, when using a proc array' do
|
||||
config1 = nil
|
||||
redirect_pry_io(InputTester.new("exit-all")) do
|
||||
Pry.start(self, :prompt => [proc { |v| config1 = v }, proc { |v| _config2 = v }])
|
||||
Pry.start(self, prompt: [proc { |v| config1 = v }, proc { |v| _config2 = v }])
|
||||
end
|
||||
expect(config1.is_a?(Pry::Config)).to eq true
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ describe "Prompts" do
|
|||
it 'should receive correct data in the config object' do
|
||||
config = nil
|
||||
redirect_pry_io(InputTester.new("def hello", "exit-all")) do
|
||||
Pry.start(self, :prompt => proc { |v| config = v })
|
||||
Pry.start(self, prompt: proc { |v| config = v })
|
||||
end
|
||||
|
||||
expect(config.eval_string).to match(/def hello/)
|
||||
|
@ -46,7 +46,7 @@ describe "Prompts" do
|
|||
it 'should get 3 parameters' do
|
||||
o = n = p = nil
|
||||
redirect_pry_io(InputTester.new("exit-all")) do
|
||||
Pry.start(:test, :prompt => proc { |obj, nesting, _pry_|
|
||||
Pry.start(:test, prompt: proc { |obj, nesting, _pry_|
|
||||
o, n, p = obj, nesting, _pry_ })
|
||||
end
|
||||
expect(o).to eq :test
|
||||
|
@ -57,10 +57,10 @@ describe "Prompts" do
|
|||
it 'should get 3 parameters, when using proc array' do
|
||||
o1 = n1 = p1 = nil
|
||||
redirect_pry_io(InputTester.new("exit-all")) do
|
||||
Pry.start(:test, :prompt => [proc { |obj, nesting, _pry_|
|
||||
Pry.start(:test, prompt: [proc { |obj, nesting, _pry_|
|
||||
o1, n1, p1 = obj, nesting, _pry_ },
|
||||
proc { |obj, nesting, _pry_|
|
||||
_o2, _n2, _p2 = obj, nesting, _pry_ }])
|
||||
proc { |obj, nesting, _pry_|
|
||||
_o2, _n2, _p2 = obj, nesting, _pry_ }])
|
||||
end
|
||||
expect(o1).to eq :test
|
||||
expect(n1).to eq 0
|
||||
|
|
|
@ -20,7 +20,7 @@ describe "test Pry defaults" do
|
|||
expect(@str_output.string).to match(/5/)
|
||||
|
||||
Pry.config.output = @str_output
|
||||
Object.new.pry :input => InputTester.new("6")
|
||||
Object.new.pry input: InputTester.new("6")
|
||||
expect(@str_output.string).to match(/6/)
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,7 @@ describe "test Pry defaults" do
|
|||
end
|
||||
end.new
|
||||
|
||||
Pry.start(self, :input => arity_one_input, :output => StringIO.new)
|
||||
Pry.start(self, input: arity_one_input, output: StringIO.new)
|
||||
expect(arity_one_input.prompt).to eq Pry.prompt.call
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ describe "test Pry defaults" do
|
|||
end
|
||||
end.new
|
||||
|
||||
expect { Pry.start(self, :input => arity_zero_input, :output => StringIO.new) }.to_not raise_error
|
||||
expect { Pry.start(self, input: arity_zero_input, output: StringIO.new) }.to_not raise_error
|
||||
end
|
||||
|
||||
it 'should not pass in the prompt if the arity is -1' do
|
||||
|
@ -63,7 +63,7 @@ describe "test Pry defaults" do
|
|||
end
|
||||
end.new
|
||||
|
||||
Pry.start(self, :input => arity_multi_input, :output => StringIO.new)
|
||||
Pry.start(self, input: arity_multi_input, output: StringIO.new)
|
||||
expect(arity_multi_input.prompt).to eq nil
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ describe "test Pry defaults" do
|
|||
|
||||
Pry.config.input = InputTester.new("7")
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :output => @str_output
|
||||
Object.new.pry output: @str_output
|
||||
expect(@str_output.string).not_to match(/5\n.*6/)
|
||||
expect(@str_output.string).to match(/7/)
|
||||
end
|
||||
|
@ -92,39 +92,39 @@ describe "test Pry defaults" do
|
|||
Pry.config.print = new_print
|
||||
|
||||
expect(Pry.new.print).to eq Pry.config.print
|
||||
Object.new.pry :input => InputTester.new("\"test\""), :output => @str_output
|
||||
Object.new.pry input: InputTester.new("\"test\""), output: @str_output
|
||||
expect(@str_output.string).to eq "=> LOL\n"
|
||||
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :input => InputTester.new("\"test\""), :output => @str_output,
|
||||
:print => proc { |out, value| out.puts value.reverse }
|
||||
Object.new.pry input: InputTester.new("\"test\""), output: @str_output,
|
||||
print: proc { |out, value| out.puts value.reverse }
|
||||
expect(@str_output.string).to eq "tset\n"
|
||||
|
||||
expect(Pry.new.print).to eq Pry.config.print
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :input => InputTester.new("\"test\""), :output => @str_output
|
||||
Object.new.pry input: InputTester.new("\"test\""), output: @str_output
|
||||
expect(@str_output.string).to eq "=> LOL\n"
|
||||
end
|
||||
|
||||
describe "pry return values" do
|
||||
it 'should return nil' do
|
||||
expect(Pry.start(self, :input => StringIO.new("exit-all"), :output => StringIO.new)).to eq nil
|
||||
expect(Pry.start(self, input: StringIO.new("exit-all"), output: StringIO.new)).to eq nil
|
||||
end
|
||||
|
||||
it 'should return the parameter given to exit-all' do
|
||||
expect(Pry.start(self, :input => StringIO.new("exit-all 10"), :output => StringIO.new)).to eq 10
|
||||
expect(Pry.start(self, input: StringIO.new("exit-all 10"), output: StringIO.new)).to eq 10
|
||||
end
|
||||
|
||||
it 'should return the parameter (multi word string) given to exit-all' do
|
||||
expect(Pry.start(self, :input => StringIO.new("exit-all \"john mair\""), :output => StringIO.new)).to eq "john mair"
|
||||
expect(Pry.start(self, input: StringIO.new("exit-all \"john mair\""), output: StringIO.new)).to eq "john mair"
|
||||
end
|
||||
|
||||
it 'should return the parameter (function call) given to exit-all' do
|
||||
expect(Pry.start(self, :input => StringIO.new("exit-all 'abc'.reverse"), :output => StringIO.new)).to eq 'cba'
|
||||
expect(Pry.start(self, input: StringIO.new("exit-all 'abc'.reverse"), output: StringIO.new)).to eq 'cba'
|
||||
end
|
||||
|
||||
it 'should return the parameter (self) given to exit-all' do
|
||||
expect(Pry.start("carl", :input => StringIO.new("exit-all self"), :output => StringIO.new)).to eq "carl"
|
||||
expect(Pry.start("carl", input: StringIO.new("exit-all self"), output: StringIO.new)).to eq "carl"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -150,7 +150,7 @@ describe "test Pry defaults" do
|
|||
expect(get_prompts(pry)).to eq ["test prompt> ", "test prompt> "]
|
||||
|
||||
|
||||
pry = Pry.new(:prompt => new_prompt)
|
||||
pry = Pry.new(prompt: new_prompt)
|
||||
expect(pry.prompt).to eq new_prompt
|
||||
expect(get_prompts(pry)).to eq ["A", "A"]
|
||||
|
||||
|
@ -168,7 +168,7 @@ describe "test Pry defaults" do
|
|||
expect(get_prompts(pry)).to eq ["test prompt> ", "test prompt* "]
|
||||
|
||||
|
||||
pry = Pry.new(:prompt => new_prompt)
|
||||
pry = Pry.new(prompt: new_prompt)
|
||||
expect(pry.prompt).to eq new_prompt
|
||||
expect(get_prompts(pry)).to eq ["A", "B"]
|
||||
|
||||
|
@ -185,7 +185,7 @@ describe "test Pry defaults" do
|
|||
prompt
|
||||
end
|
||||
@a , @b , @c = make[:a,0] , make[:b,1] , make[:c,2]
|
||||
@pry = Pry.new :prompt => @a
|
||||
@pry = Pry.new prompt: @a
|
||||
end
|
||||
it 'should have a prompt stack' do
|
||||
@pry.push_prompt @b
|
||||
|
@ -198,7 +198,7 @@ describe "test Pry defaults" do
|
|||
end
|
||||
|
||||
it 'should restore overridden prompts when returning from file-mode' do
|
||||
pry = Pry.new(:prompt => [ proc { 'P>' } ] * 2)
|
||||
pry = Pry.new(prompt: [ proc { 'P>' } ] * 2)
|
||||
expect(pry.select_prompt).to eq "P>"
|
||||
pry.process_command('shell-mode')
|
||||
expect(pry.select_prompt).to match(/\Apry .* \$ \z/)
|
||||
|
@ -343,18 +343,18 @@ describe "test Pry defaults" do
|
|||
|
||||
describe 'quiet' do
|
||||
it 'should show whereami by default' do
|
||||
Pry.start(binding, :input => InputTester.new("1", "exit-all"),
|
||||
:output => @str_output,
|
||||
:hooks => Pry::DEFAULT_HOOKS)
|
||||
Pry.start(binding, input: InputTester.new("1", "exit-all"),
|
||||
output: @str_output,
|
||||
hooks: Pry::DEFAULT_HOOKS)
|
||||
|
||||
expect(@str_output.string).to match(/[w]hereami by default/)
|
||||
end
|
||||
|
||||
it 'should hide whereami if quiet is set' do
|
||||
Pry.new(:input => InputTester.new("exit-all"),
|
||||
:output => @str_output,
|
||||
:quiet => true,
|
||||
:hooks => Pry::DEFAULT_HOOKS)
|
||||
Pry.new(input: InputTester.new("exit-all"),
|
||||
output: @str_output,
|
||||
quiet: true,
|
||||
hooks: Pry::DEFAULT_HOOKS)
|
||||
|
||||
expect(@str_output.string).to eq ""
|
||||
end
|
||||
|
@ -382,15 +382,15 @@ describe "test Pry defaults" do
|
|||
add_hook(:before_session, :my_name) { |out,_,_| out.puts "HELLO" }.
|
||||
add_hook(:after_session, :my_name) { |out,_,_| out.puts "BYE" }
|
||||
|
||||
Object.new.pry :output => @str_output
|
||||
Object.new.pry output: @str_output
|
||||
expect(@str_output.string).to match(/HELLO/)
|
||||
expect(@str_output.string).to match(/BYE/)
|
||||
|
||||
Pry.config.input.rewind
|
||||
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :output => @str_output,
|
||||
:hooks => Pry::Hooks.new.
|
||||
Object.new.pry output: @str_output,
|
||||
hooks: Pry::Hooks.new.
|
||||
add_hook( :before_session, :my_name) { |out,_,_| out.puts "MORNING" }.
|
||||
add_hook(:after_session, :my_name) { |out,_,_| out.puts "EVENING" }
|
||||
|
||||
|
@ -400,16 +400,16 @@ describe "test Pry defaults" do
|
|||
# try below with just defining one hook
|
||||
Pry.config.input.rewind
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :output => @str_output,
|
||||
:hooks => Pry::Hooks.new.
|
||||
Object.new.pry output: @str_output,
|
||||
hooks: Pry::Hooks.new.
|
||||
add_hook(:before_session, :my_name) { |out,_,_| out.puts "OPEN" }
|
||||
|
||||
expect(@str_output.string).to match(/OPEN/)
|
||||
|
||||
Pry.config.input.rewind
|
||||
@str_output = StringIO.new
|
||||
Object.new.pry :output => @str_output,
|
||||
:hooks => Pry::Hooks.new.
|
||||
Object.new.pry output: @str_output,
|
||||
hooks: Pry::Hooks.new.
|
||||
add_hook(:after_session, :my_name) { |out,_,_| out.puts "CLOSE" }
|
||||
|
||||
expect(@str_output.string).to match(/CLOSE/)
|
||||
|
|
|
@ -86,7 +86,7 @@ describe Pry::REPL do
|
|||
end
|
||||
end
|
||||
|
||||
ReplTester.start(:commands => set) do
|
||||
ReplTester.start(commands: set) do
|
||||
input 'def x'
|
||||
output ''
|
||||
prompt(/\* $/)
|
||||
|
|
|
@ -171,13 +171,13 @@ describe Pry do
|
|||
|
||||
it 'should be able to evaluate exceptions normally' do
|
||||
was_called = false
|
||||
mock_pry("RuntimeError.new", :exception_handler => proc{ was_called = true })
|
||||
mock_pry("RuntimeError.new", exception_handler: proc{ was_called = true })
|
||||
expect(was_called).to eq false
|
||||
end
|
||||
|
||||
it 'should notice when exceptions are raised' do
|
||||
was_called = false
|
||||
mock_pry("raise RuntimeError", :exception_handler => proc{ was_called = true })
|
||||
mock_pry("raise RuntimeError", exception_handler: proc{ was_called = true })
|
||||
expect(was_called).to eq true
|
||||
end
|
||||
|
||||
|
@ -243,7 +243,7 @@ describe Pry do
|
|||
|
||||
o = Object.new
|
||||
|
||||
Pry.start(o, :input => input, :output => StringIO.new)
|
||||
Pry.start(o, input: input, output: StringIO.new)
|
||||
|
||||
expect(o.instance_variable_get(:@x)).to eq 10
|
||||
end
|
||||
|
@ -292,7 +292,7 @@ describe Pry do
|
|||
end
|
||||
|
||||
it 'can change the size of the history arrays' do
|
||||
expect(pry_tester(:memory_size => 1000).eval("[_out_, _in_].map(&:max_size)")).to eq [1000, 1000]
|
||||
expect(pry_tester(memory_size: 1000).eval("[_out_, _in_].map(&:max_size)")).to eq [1000, 1000]
|
||||
end
|
||||
|
||||
it 'store exceptions' do
|
||||
|
@ -312,7 +312,7 @@ describe Pry do
|
|||
# replacing the eval_string, so _ won't be modified without Pry doing
|
||||
# a REPL loop.
|
||||
it "should be set to the result of a command with :keep_retval" do
|
||||
Pry::Commands.block_command '++', '', :keep_retval => true do |a|
|
||||
Pry::Commands.block_command '++', '', keep_retval: true do |a|
|
||||
a.to_i + 1
|
||||
end
|
||||
|
||||
|
@ -408,7 +408,7 @@ describe Pry do
|
|||
end
|
||||
|
||||
it "should raise if more than two arguments are passed to Object#pry" do
|
||||
expect { pry(20, :quiet, :input => Readline) }.to raise_error ArgumentError
|
||||
expect { pry(20, :quiet, input: Readline) }.to raise_error ArgumentError
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -425,11 +425,11 @@ describe Pry do
|
|||
|
||||
describe 'setting custom options' do
|
||||
it 'does not raise for unrecognized options' do
|
||||
expect { Pry.new(:custom_option => 'custom value') }.to_not raise_error
|
||||
expect { Pry.new(custom_option: 'custom value') }.to_not raise_error
|
||||
end
|
||||
|
||||
it 'correctly handles the :quiet option (#1261)' do
|
||||
instance = Pry.new(:quiet => true)
|
||||
instance = Pry.new(quiet: true)
|
||||
expect(instance.quiet?).to eq true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,10 +18,10 @@ describe Pry do
|
|||
end
|
||||
|
||||
it "should never run the rc file twice" do
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new)
|
||||
Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new)
|
||||
expect(TEST_RC).to eq [0]
|
||||
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new)
|
||||
Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new)
|
||||
expect(TEST_RC).to eq [0]
|
||||
end
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe Pry do
|
|||
Pry::HOME_RC_FILE.replace "spec/fixtures/testrc"
|
||||
Pry::LOCAL_RC_FILE.replace "spec/fixtures/testlinkrc"
|
||||
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new)
|
||||
Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new)
|
||||
|
||||
expect(TEST_RC).to eq [0]
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ describe Pry do
|
|||
File.chmod 0000, dir
|
||||
Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc')
|
||||
Pry.config.should_load_rc = true
|
||||
expect { Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new) }.to_not raise_error
|
||||
expect { Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new) }.to_not raise_error
|
||||
File.chmod 0777, dir
|
||||
end
|
||||
end
|
||||
|
@ -51,7 +51,7 @@ describe Pry do
|
|||
old_home = ENV['HOME']
|
||||
ENV['HOME'] = nil
|
||||
Pry.config.should_load_rc = true
|
||||
expect { Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new) }.to_not raise_error
|
||||
expect { Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new) }.to_not raise_error
|
||||
|
||||
ENV['HOME'] = old_home
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe Pry do
|
|||
it "should not run the rc file at all if Pry.config.should_load_rc is false" do
|
||||
Pry.config.should_load_rc = false
|
||||
Pry.config.should_load_local_rc = false
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new)
|
||||
Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new)
|
||||
expect(Object.const_defined?(:TEST_RC)).to eq false
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe Pry do
|
|||
}
|
||||
|
||||
@doing_it = lambda{
|
||||
Pry.start(self, :input => StringIO.new("Object::TEST_AFTER_RAISE=1\nexit-all\n"), :output => StringIO.new)
|
||||
Pry.start(self, input: StringIO.new("Object::TEST_AFTER_RAISE=1\nexit-all\n"), output: StringIO.new)
|
||||
putsed
|
||||
}
|
||||
end
|
||||
|
|
|
@ -11,13 +11,13 @@ describe "Pry.run_command" do
|
|||
|
||||
it 'performs a simple ls' do
|
||||
@context.eval("hokey_pokey = 10")
|
||||
Pry.run_command "ls", :context => @context, :output => out = StringIO.new
|
||||
Pry.run_command "ls", context: @context, output: out = StringIO.new
|
||||
expect(out.string).to match(/hokey_pokey/)
|
||||
end
|
||||
|
||||
# This is a regression test as 0.9.11 broke this behaviour
|
||||
it 'can perform a show-source' do
|
||||
Pry.run_command "show-source drum", :context => @context, :output => out = StringIO.new
|
||||
Pry.run_command "show-source drum", context: @context, output: out = StringIO.new
|
||||
expect(out.string).to match(/roken is dodelijk/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,7 +104,7 @@ describe "Sticky locals (_file_ and friends)" do
|
|||
o = Object.new
|
||||
redirect_pry_io(InputTester.new("@value = test_local",
|
||||
"exit-all")) do
|
||||
Pry.start(o, :extra_sticky_locals => { :test_local => :john } )
|
||||
Pry.start(o, extra_sticky_locals: { test_local: :john } )
|
||||
end
|
||||
|
||||
expect(o.instance_variable_get(:@value)).to eq :john
|
||||
|
@ -115,8 +115,8 @@ describe "Sticky locals (_file_ and friends)" do
|
|||
redirect_pry_io(InputTester.new("@value1 = test_local1",
|
||||
"@value2 = test_local2",
|
||||
"exit-all")) do
|
||||
Pry.start(o, :extra_sticky_locals => { :test_local1 => :john ,
|
||||
:test_local2 => :carl} )
|
||||
Pry.start(o, extra_sticky_locals: { test_local1: :john ,
|
||||
test_local2: :carl} )
|
||||
end
|
||||
|
||||
expect(o.instance_variable_get(:@value1)).to eq :john
|
||||
|
@ -128,7 +128,7 @@ describe "Sticky locals (_file_ and friends)" do
|
|||
o = Object.new
|
||||
redirect_pry_io(InputTester.new("@value = test_local",
|
||||
"exit-all")) do
|
||||
Pry.start(o, :extra_sticky_locals => { :test_local => proc { :john }} )
|
||||
Pry.start(o, extra_sticky_locals: { test_local: proc { :john }} )
|
||||
end
|
||||
|
||||
expect(o.instance_variable_get(:@value)).to eq :john
|
||||
|
@ -142,7 +142,7 @@ describe "Sticky locals (_file_ and friends)" do
|
|||
o = Object.new
|
||||
redirect_pry_io(InputTester.new("@value = test_local",
|
||||
"exit-all")) do
|
||||
Pry.start(o, :extra_sticky_locals => { :test_local => :carl })
|
||||
Pry.start(o, extra_sticky_locals: { test_local: :carl })
|
||||
end
|
||||
|
||||
expect(o.instance_variable_get(:@value)).to eq :carl
|
||||
|
|
Loading…
Add table
Reference in a new issue