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

Version Path
web_translate_it-2.8.3 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.8.2 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.8.1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.8.0 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.8.0.pre.1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.6 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.5 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.4 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.3 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.2 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.7.0 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.4 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.3 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.3.pre1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.2 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.6.0 generators/webtranslateit/lib/insert_commands.rb