class Pry::Command::ReloadCode
Public Instance Methods
process()
click to toggle source
# File lib/pry/commands/reload_code.rb, line 17 def process if !args.empty? reload_object(args.join(" ")) elsif internal_binding?(target) reload_object("self") else reload_current_file end end
Private Instance Methods
check_for_reloadability(code_object, identifier)
click to toggle source
# File lib/pry/commands/reload_code.rb, line 49 def check_for_reloadability(code_object, identifier) if !code_object || !code_object.source_file raise CommandError, "Cannot locate #{identifier}!" elsif !File.exists?(code_object.source_file) raise CommandError, "Cannot reload #{identifier} as it has no associated file on disk. " "File found was: #{code_object.source_file}" end end
current_file()
click to toggle source
# File lib/pry/commands/reload_code.rb, line 29 def current_file File.expand_path target.eval("__FILE__") end
reload_current_file()
click to toggle source
# File lib/pry/commands/reload_code.rb, line 33 def reload_current_file if !File.exists?(current_file) raise CommandError, "Current file: #{current_file} cannot be found on disk!" end load current_file output.puts "The current file: #{current_file} was reloaded!" end
reload_object(identifier)
click to toggle source
# File lib/pry/commands/reload_code.rb, line 42 def reload_object(identifier) code_object = Pry::CodeObject.lookup(identifier, _pry_) check_for_reloadability(code_object, identifier) load code_object.source_file output.puts "#{identifier} was reloaded!" end