Sha256: ffe28deda34438a13ffb9cd5e406a576308b0b1628a5b8ba7a2384eaefebe5e5

Contents?: true

Size: 1021 Bytes

Versions: 35

Compression:

Stored size: 1021 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 press_any_key(read_me="Where's the any key?")
    puts read_me
    gets
  end
  
  def insert_into(file, line)
    logger.insert "#{line} into #{file}"
    unless options[:pretend] || file_contains?(file, line)
      gsub_file file, /^(class|module) .+$/ do |match|
        "#{match}\n  #{line}"
      end
    end
  end
  
end

Rails::Generator::Commands::Destroy.class_eval do
  
  def press_any_key
    # do ni
  end

  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

35 entries across 35 versions & 2 rubygems

Version Path
beef-admin_area-0.1.0 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.1 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.2 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.3 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.4 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.6 generators/admin_area_files/lib/insert_commands.rb
beef-admin_area-0.1.7 generators/admin_area_files/lib/insert_commands.rb
noodall-ui-0.0.13 generators/node/lib/insert_commands.rb
noodall-ui-0.0.12 generators/node/lib/insert_commands.rb
noodall-ui-0.0.11 generators/node/lib/insert_commands.rb
noodall-ui-0.0.10 generators/node/lib/insert_commands.rb
noodall-ui-0.0.9 generators/node/lib/insert_commands.rb
noodall-ui-0.0.8 generators/node/lib/insert_commands.rb
beef-admin_area-0.3.9 generators/admin_area_files/lib/insert_commands.rb
noodall-ui-0.0.7 generators/node/lib/insert_commands.rb
noodall-ui-0.0.6 generators/node/lib/insert_commands.rb
noodall-ui-0.0.5 generators/node/lib/insert_commands.rb
noodall-ui-0.0.4 generators/node/lib/insert_commands.rb
noodall-ui-0.0.3 generators/node/lib/insert_commands.rb
noodall-ui-0.0.2 generators/node/lib/insert_commands.rb