Class: ReplaceRecursive

Inherits:
Thor
  • Object
show all
Defined in:
lib/replace_recursive.rb

Instance Method Summary collapse

Instance Method Details

#path(name = nil) ⇒ Object



8
9
10
# File 'lib/replace_recursive.rb', line 8

def path(name = nil)
  system "find #{options[:path]} -depth -name '*#{options[:find]}*' -execdir bash -c 'mv \"$1\" \"${1//#{options[:find]}/#{options[:replace]}}\"' _ {} \\;"
end

#text(name = nil) ⇒ Object



16
17
18
# File 'lib/replace_recursive.rb', line 16

def text(name = nil)
  system "grep -rl \"#{options[:find]}\" #{options[:path]} | xargs sed -i \"s/#{options[:find]}/#{options[:replace]}/g\""
end