Browse files

Added some useful methods to the generators.textile

  • Loading branch information...
jstrocel committed Apr 24, 2012
1 parent 52188c7 commit f45f1bacb03421094ef3cca9cd541cc41798586c
Showing with 21 additions and 0 deletions.
  1. +21 −0 guides/source/generators.textile
@@ -451,6 +451,27 @@ Adds a specified source to +Gemfile+:
add_source ""
+h4. +inject_into_file+
+Injects a block of code into a defined position in your file.
+inject_into_file 'name_of_file.rb', :after => "#The code goes below this line. Don't for get the Line break at the end\n" do <<-'RUBY'
+ puts "Hello World"
+h4. +gsub_file+
+Replaces text inside a file.
+ gsub_file 'name_of_file.rb', 'method.to_be_replaced', 'method.the_replacing_code'
+Regular Expressions can be used to make this method more precise. You can also use append_file and prepend_file in the same way to place code at the beginning and end of a file respectively.
h4. +application+
Adds a line to +config/application.rb+ directly after the application class definition.

0 comments on commit f45f1ba

Please sign in to comment.