Sha256: 877b2d09c57cbc785887c0fbc9e4d732570f75dfaf65fc530112276491d93146

Contents?: true

Size: 890 Bytes

Versions: 90

Compression:

Stored size: 890 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 insert_into(file, line)
    logger.insert "#{line} into #{file}"
    unless options[:pretend] || file_contains?(file, line)
      gsub_file file, /^(class|module|.*Routes).*$/ do |match|
        "#{match}\n  #{line}"
      end
    end
  end
end

Rails::Generator::Commands::Destroy.class_eval do
  def insert_into(file, line)
    logger.remove "#{line} from #{file}"
    unless options[:pretend]
      gsub_file file, "\n  #{line}", ''
    end
  end
end

Rails::Generator::Commands::List.class_eval do
  def insert_into(file, line)
    logger.insert "#{line} into #{file}"
  end
end

Version data entries

90 entries across 90 versions & 12 rubygems

Version Path
fbdoorman-0.9.3 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.9.2 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.9.1 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.9.0 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.98 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.97 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.95 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.94 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.93 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.92 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.91 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.9 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.8 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.7 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.6 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.5 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.4 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.2 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0.1 generators/fbdoorman/lib/insert_commands.rb
fbdoorman-0.8.0 generators/fbdoorman/lib/insert_commands.rb