<commit_before>def y?(s)
  yes? "\n#{s} (y/n)", :yellow
end

def maybe_update_file(options = {})
  old_contents = File.read options[:file]
  look_for = options[:after] || options[:before] # but not both!
  return if options[:unless_present] && old_contents =~ options[:unless_present]

  if options[:action].nil? || y?("Should I #{options[:action]} to #{options[:file]}?")
    File.open(options[:file], "w") do |file|
      file.print old_contents.sub(look_for, "#{look_for}\n#{options[:content]}") if options[:after]
      file.print old_contents.sub(look_for, "#{options[:content]}\n#{look_for}") if options[:before]
    end

    if old_contents.scan(look_for).length > 1
      puts "\nNOTE: #{options[:file]} may not have been updated correctly, so please take a look at it.\n"
    end
  end
end

@templates_path = "https://github.com/benlangfeld/rails-templates/raw/master"

gem "nifty-generators"

apply "#{@templates_path}/rvm.rb"

run "bundle install"

git :init

apply "#{@templates_path}/cleanup.rb"

git :add => ".", :commit => "-m 'Base Rails app (with nifty generators)'"

apply "#{@templates_path}/database.rb"
apply "#{@templates_path}/testing.rb"
apply "#{@templates_path}/authorization.rb"
apply "#{@templates_path}/views.rb"

if y?("Use has_scope?")
  gem "has_scope"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use has_scope'"
end

if y?("Use simple_enum?")
  gem "simple_enum"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use simple_enum'"
end

if y?("Use andand?")
  gem "andand"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use andand'"
end

if y?("Annotate your models?")
  gem "annotate-models"
  run "bundle install"
  run "annotate"
  git :add => ".", :commit => "-m 'Annotate models'"
end

if y?("Host on GitHub?")
  apply "#{@templates_path}/github.rb"
end<commit_msg>Allow adding an Adhearsion app<commit_after>def y?(s)
  yes? "\n#{s} (y/n)", :yellow
end

def maybe_update_file(options = {})
  old_contents = File.read options[:file]
  look_for = options[:after] || options[:before] # but not both!
  return if options[:unless_present] && old_contents =~ options[:unless_present]

  if options[:action].nil? || y?("Should I #{options[:action]} to #{options[:file]}?")
    File.open(options[:file], "w") do |file|
      file.print old_contents.sub(look_for, "#{look_for}\n#{options[:content]}") if options[:after]
      file.print old_contents.sub(look_for, "#{options[:content]}\n#{look_for}") if options[:before]
    end

    if old_contents.scan(look_for).length > 1
      puts "\nNOTE: #{options[:file]} may not have been updated correctly, so please take a look at it.\n"
    end
  end
end

@templates_path = "https://github.com/benlangfeld/rails-templates/raw/master"

gem "nifty-generators"

apply "#{@templates_path}/rvm.rb"

run "bundle install"

git :init

apply "#{@templates_path}/cleanup.rb"

git :add => ".", :commit => "-m 'Base Rails app (with nifty generators)'"

apply "#{@templates_path}/database.rb"
apply "#{@templates_path}/testing.rb"
apply "#{@templates_path}/authorization.rb"
apply "#{@templates_path}/views.rb"

if y?("Use has_scope?")
  gem "has_scope"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use has_scope'"
end

if y?("Use simple_enum?")
  gem "simple_enum"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use simple_enum'"
end

if y?("Use andand?")
  gem "andand"
  run "bundle install"
  git :add => ".", :commit => "-m 'Use andand'"
end

if y?("Annotate your models?")
  gem "annotate-models"
  run "bundle install"
  run "annotate"
  git :add => ".", :commit => "-m 'Annotate models'"
end

if y?("Use Adhearsion?")
  gem "adhearsion"
  gem "rubigen"
  gem "ahn-rails"
  run "bundle install"
  run "ahn create adhearsion"
  git :add => ".", :commit => "-m 'Add an Adhearsion app'"
end

if y?("Host on GitHub?")
  apply "#{@templates_path}/github.rb"
end
{'fraction_non_alphanumeric': 0.18547140649149924, 'fraction_numerical': 0.0005151983513652757, 'mean_word_length': 4.430769230769231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1123777', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1392, 'n_words': 364}