-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edit command: extract out ExceptionPatcher, and clean up some code
- Loading branch information
Showing
3 changed files
with
60 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Pry | ||
class Command::Edit | ||
class ExceptionPatcher | ||
attr_accessor :edit_context | ||
|
||
def initialize(edit_context) | ||
@edit_context = edit_context | ||
end | ||
|
||
# perform the patch | ||
def perform_patch | ||
file_name, line = edit_context.retrieve_file_and_line | ||
lines = edit_context.state.dynamical_ex_file || File.read(file_name) | ||
|
||
source = Pry::Editor.edit_tempfile_with_content(lines) | ||
edit_context._pry_.evaluate_ruby source | ||
edit_context.state.dynamical_ex_file = source.split("\n") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters