Sha256: 91c35f31a130ed33b46651e83c803655b598a7f9d5ac50375f31fe630bb29a85

Contents?: true

Size: 891 Bytes

Versions: 26

Compression:

Stored size: 891 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|.*Routing).*$/ 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

26 entries across 26 versions & 4 rubygems

Version Path
headstart-0.11.2 generators/headstart_admin/lib/insert_commands.rb
headstart-0.11.1 generators/headstart_admin/lib/insert_commands.rb
headstart-0.9.2 generators/headstart_admin/lib/insert_commands.rb
headstart-0.9.1 generators/headstart_admin/lib/insert_commands.rb
headstart-0.9.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.8.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.7.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.6.2 generators/headstart_admin/lib/insert_commands.rb
headstart-0.6.1 generators/headstart_admin/lib/insert_commands.rb
headstart-0.6.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.5 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.4 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.3 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.2 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.1 generators/headstart_admin/lib/insert_commands.rb
headstart-0.5.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.4.2 generators/headstart_admin/lib/insert_commands.rb
headstart-0.4.1 generators/headstart_admin/lib/insert_commands.rb
headstart-0.4.0 generators/headstart_admin/lib/insert_commands.rb
headstart-0.3.0 generators/headstart_admin/lib/insert_commands.rb