Class: Main
Instance Attribute Summary collapse
-
#manual_edit ⇒ Object
Returns the value of attribute manual_edit.
Instance Method Summary collapse
-
#initialize ⇒ Main
constructor
A new instance of Main.
- #replace_all ⇒ Object
Constructor Details
#initialize ⇒ Main
Returns a new instance of Main.
10 11 12 |
# File 'lib/main.rb', line 10 def initialize @manual_edit = VimEdit.new end |
Instance Attribute Details
#manual_edit ⇒ Object
Returns the value of attribute manual_edit.
8 9 10 |
# File 'lib/main.rb', line 8 def manual_edit @manual_edit end |
Instance Method Details
#replace_all ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/main.rb', line 14 def replace_all pattern, root_path = prompt_search_details file_lines = FileLine.find_all(pattern, root_path) replacement_collection = ReplacementCollection.new file_lines.each do |file_line| if file_line.raw_contents.match(pattern) old_contents = file_line.raw_contents applicable_replacements = replacement_collection.applicable_replacements(old_contents) user_input = ChangePrompt.prompt(pattern, file_line, applicable_replacements) if user_input.chose_editor? manual_edit.execute!(file_line, pattern) record_manual_replacement!(replacement_collection, old_contents, file_line) elsif user_input.selected_replacement take_user_suggestion!(user_input.selected_replacement, file_line) end end end end |