Sha256: e76e3f1d94c7411c43a36bb4978210f93888a2eb48730dfb9007e8f435128131

Contents?: true

Size: 882 Bytes

Versions: 32

Compression:

Stored size: 882 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) .+$/ 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

32 entries across 32 versions & 8 rubygems

Version Path
jeffrafter-spreadhead-0.1.0 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.1.1 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.3.0 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.4.0 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.6.0 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.6.1 generators/spreadhead/lib/insert_commands.rb
jeffrafter-spreadhead-0.6.2 generators/spreadhead/lib/insert_commands.rb
peteonrails-simple_tooltips-0.0.1 generators/lib/insert_commands.rb
peteonrails-simple_tooltips-0.0.2 generators/lib/insert_commands.rb
peteonrails-simple_tooltips-0.0.3 generators/lib/insert_commands.rb
qrush-clearance-0.7.0 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.6.7 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.6.8 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.6.9 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.7.0 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.8.0 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.8.1 generators/clearance/lib/insert_commands.rb
thoughtbot-clearance-0.8.2 generators/clearance/lib/insert_commands.rb
tonkapark-clearance-0.6.9.1 generators/clearance/lib/insert_commands.rb
tonkapark-clearance-0.6.9.2 generators/clearance/lib/insert_commands.rb