Sha256: 1e87ece13be8cb3048cf5961628a85c6680823659bf316c8ee86d642313d057e
Contents?: true
Size: 854 Bytes
Versions: 18
Compression:
Stored size: 854 Bytes
Contents
# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master Rails::Generator::Commands::Base.class_eval do def file_contains?(relative_destination, line) File.read(destination_path(relative_destination)).include?(line) end end Rails::Generator::Commands::Create.class_eval do def append_to(file, line) logger.insert "#{line} appended to #{file}" return if options[:pretend] || file_contains?(file, line) File.open(file, 'a') do |f| f.puts f.puts line end end end Rails::Generator::Commands::Destroy.class_eval do def append_to(file, line) logger.remove "#{line} removed from #{file}" gsub_file file, "\n#{line}", '' unless options[:pretend] end end Rails::Generator::Commands::List.class_eval do def append_to(file, line) logger.insert "#{line} appended to #{file}" end end
Version data entries
18 entries across 18 versions & 1 rubygems