Class: Findr::Findr
- Inherits:
-
Object
- Object
- Findr::Findr
- Defined in:
- lib/findr.rb
Instance Method Summary collapse
- #find_and_replace ⇒ Object
-
#initialize(pattern, replacement, search_path, options = {}) ⇒ Findr
constructor
A new instance of Findr.
Constructor Details
#initialize(pattern, replacement, search_path, options = {}) ⇒ Findr
Returns a new instance of Findr.
9 10 11 12 13 14 15 16 17 |
# File 'lib/findr.rb', line 9 def initialize(pattern, replacement, search_path, = {}) @pattern = pattern @replacement = replacement @search_path = search_path @options = @results = [] Diffy::Diff.default_format = :color end |
Instance Method Details
#find_and_replace ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/findr.rb', line 19 def find_and_replace paths.each do |path| print "searching: #{path}\n" if @options[:verbose] sed_i(path) end if @options[:verbose] && !@results.empty? print_line print @results.map { |x| [x[0].bold, x[1]].join("\n") }.join("\n") print_line end print "searched: #{paths.size} files\n".bold print "replaced: #{@results.size} files\n".bold end |