No commit activity in last 3 years
No release in over 3 years
recursive_replace is a ruby gem for recursively replacing text in multiple files and directories. It also escapes special characters, so you can replace code syntax and special characters easily.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.6.3
>= 0

Runtime

 Project Readme

recursive_replace

  • A ruby gem for recursively replacing text in multiple files and directories.
  • Use with shell executable or in code.
  • It auto-escapes most characters, so you can replace code syntax and special characters easily without using regular expressions.
  • Comes with a rspec testing suite for replacement verification of special characters, expressions and code syntax.

Installation

gem install recursive_replace

Examples

From Console/Terminal

recursive_replace [original] [replacement] [optional_path] 

Replace foo with bar in current directory and its subdirectories:

recursive_replace "foo" "bar"

Replace foo with bar in a specific file:

recursive_replace "foo" "bar" file

Replace erb syntax:

recursive_replace "<%= @object[:foo] %>" "<%= @new_object[:bar] %>" 

Replacing a backslash is the only time you'll actually need to escape an input character.

recursive_replace "\\" "_" somedirectory/ 

From Code

require "recursive_replace"
file = File.join("home", "bob", "Documents")
RecursiveReplace.replace("bad", "good", :path => file)

Testing

Want to add a test to see how recursive_replace performs with a specific situation or programming language? Pull the recursive_replace and run its rspec testing suite:

git clone git://github.com/hulihanapplications/recursive_replace.git
cd recursive_replace
rspec spec/