module Thor::Actions
def inject_into_file(destination, *args, &block)
end
gems.split(" ").map{ |gem| " config.gem #{gem}" }.join("\n")
gems = ask "Which gems would you like to add?"
inject_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
inject_into_file "config/environment.rb", "config.gem thor", :after => "Rails::Initializer.run do |config|\n"
==== Examples
for injection (:after or :before).
config
data
destination
==== Parameters
deal with more complex cases.
the flag can only be strings. gsub_file is your friend if you need to
prepend_file and gsub_file, this method is reversible. By this reason,
Injects the given content into a file. Different from append_file,
def inject_into_file(destination, *args, &block) if block_given? data, config = block, args.shift else data, config = args.shift, args.shift end log_status = args.empty? || args.pop action InjectIntoFile.new(self, destination, data, config) end