Sha256: 3cf86f78adf4ed2e2f6d935061ff5809298cfbfd75f7bf74ec7d35281061f151

Contents?: true

Size: 806 Bytes

Versions: 27

Compression:

Stored size: 806 Bytes

Contents

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) .+$/ 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

27 entries across 27 versions & 2 rubygems

Version Path
ds-kitsune-0.2.5 generators/kitsune/lib/insert_commands.rb
ds-kitsune-0.2.3 generators/kitsune/lib/insert_commands.rb
kitsune-0.2.1 generators/kitsune/lib/insert_commands.rb
kitsune-0.2.0 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.5 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.4 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.3 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.2 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.1 generators/kitsune/lib/insert_commands.rb
kitsune-0.1.0 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.19 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.18 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.17 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.16 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.14 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.13 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.12 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.11 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.10 generators/kitsune/lib/insert_commands.rb
kitsune-0.0.9 generators/kitsune/lib/insert_commands.rb