It's easy to accidently change something with find/replace that you didn't mean to change. Cambiar makes find/replace safer by replacing only certain types using the Ruby AST.
Add this line to your application's Gemfile:
gem 'cambiar'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cambiar
Usage: cambiar [-ic] "s/<from>/<to>/" [file ...]
-i, --on_ident Substitute identifers
-c, --on_const Substitute constants
cambiar -i "s/reader/fast_reader/" test.rb
before
class Reader
READER = 'reader'
def my_reader
puts "Reader reader"
end
end
after
class Reader
READER = 'reader'
def my_fast_reader
puts "Reader reader"
end
end
cambiar -c "s/READER/FAST_READER/" test.rb
before
class Reader
READER = 'reader'
def my_reader
puts "READER Reader reader"
end
end
after
class Reader
FAST_READER = 'reader'
def my_reader
puts "READER Reader reader"
end
end
- Fork it ( http://github.com//cambiar/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request