Sha256: e7b72e4a747c4fd1759871cdd07142bf69d560daaaec91bca57515904dc25c01

Contents?: true

Size: 889 Bytes

Versions: 279

Compression:

Stored size: 889 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}"
    unless options[:pretend] || file_contains?(file, line)
      File.open(file, "a") do |file|
        file.puts
        file.puts line
      end
    end
  end
end

Rails::Generator::Commands::Destroy.class_eval do
  def append_to(file, line)
    logger.remove "#{line} removed from #{file}"
    unless options[:pretend]
      gsub_file file, "\n#{line}", ''
    end
  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

279 entries across 279 versions & 16 rubygems

Version Path
web_translate_it-2.5.4 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.5.3 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.5.2 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.5.1 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.5.0 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.12 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.11 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.10 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.9 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.8 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.7 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.6 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.5 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.4 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.3 generators/webtranslateit/lib/insert_commands.rb
web_translate_it-2.4.2 generators/webtranslateit/lib/insert_commands.rb
airbrakeV4rails5-4.3.8 generators/airbrake/lib/insert_commands.rb
airbrake-4.3.8 generators/airbrake/lib/insert_commands.rb
airbrake-4.3.7 generators/airbrake/lib/insert_commands.rb
airbrake-4.3.6 generators/airbrake/lib/insert_commands.rb