<commit_before>EDGE = "EDGE"
TOG_RELEASE = EDGE
#TOG_RELEASE = "v0.5.4"

APP_NAME = @root.split('/').last

module Colored
  extend self
  COLORS = { 'green'   => 32, 'yellow'  => 33,'blue'    => 34}
  EXTRAS = {'clear'     => 0, 'bold'      => 1}
  
  COLORS.each do |color, value|
    define_method(color) { colorize(self, :foreground => color) }
    define_method("on_#{color}") { colorize(self, :background => color) }
    COLORS.each do |highlight, value|
      next if color == highlight
      define_method("#{color}_on_#{highlight}") { colorize(self, :foreground => color, :background => highlight) }
    end
  end
  EXTRAS.each do |extra, value|
    next if extra == 'clear'
    define_method(extra) { colorize(self, :extra => extra) }
  end
  define_method(:to_eol) do
    tmp = sub(/^(\e\[[\[\e0-9;m]+m)/, "\\1\e[2K")
    if tmp == self
      return "\e[2K" << self
    end
    tmp
  end
  def colorize(string, options = {})
    colored = [color(options[:foreground]), color("on_#{options[:background]}"), extra(options[:extra])].compact * ''
    colored << string
    colored << extra(:clear)
  end
  def colors
    @@colors ||= COLORS.keys.sort
  end
  def extra(extra_name)
    extra_name = extra_name.to_s
    "\e[#{EXTRAS[extra_name]}m" if EXTRAS[extra_name]
  end
  def color(color_name)
    background = color_name.to_s =~ /on_/
    color_name = color_name.to_s.sub('on_', '')
    return unless color_name && COLORS[color_name]
    "\e[#{COLORS[color_name] + (background ? 10 : 0)}m" 
  end
end unless Object.const_defined? :Colored
String.send(:include, Colored)

require 'open3'

def silence!
#  Rails::Generator::Base.logger.quiet = true
end
def verbum!
#  Rails::Generator::Base.logger.quiet = false
end

def add_desert_require
  sentinel = 'Rails::Initializer.run do |config|'
  gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi, "\nrequire 'desert'\n\\1" 
end

def install_require_gems
  run "gem sources -a http://gems.github.com"
  
  gem 'desert', :lib => 'desert', :version => '0.5.2'
  gem 'mislav-will_paginate', :lib => 'will_paginate', :version => '~> 2.3.6'
  gem 'tog-tog', :lib => 'tog', :version => '>= 0.5'
  gem 'thoughtbot-factory_girl', :lib => 'factory_girl'
  gem 'jackdempsey-acts_as_commentable', :lib => 'acts_as_commentable', :version => '2.0.1'
  gem "mreinsch-acts_as_rateable", :lib => "acts_as_rateable", :version => '2.0.1'
  gem 'RedCloth', :lib => 'redcloth', :version => '4.2.0'
  gem "mbleigh-acts-as-taggable-on", :lib => "acts-as-taggable-on", :version => '1.0.5'
  gem "linkingpaths-acts_as_abusable", :lib => "acts_as_abusable", :version => '0.0.2'
  gem 'rubyist-aasm', :version => '~> 2.1.1', :lib => 'aasm'
  
  puts "\n"
  if yes?("Install required gems as root? (y/n). If you are using Windows, please, answer 'n'. If installing gems as superuser you could be asked to enter your password.") 
    rake "gems:install", :sudo => true<commit_msg>updated desert version to >= 0.5.2<commit_after>EDGE = "EDGE"
TOG_RELEASE = EDGE
#TOG_RELEASE = "v0.5.4"

APP_NAME = @root.split('/').last

module Colored
  extend self
  COLORS = { 'green'   => 32, 'yellow'  => 33,'blue'    => 34}
  EXTRAS = {'clear'     => 0, 'bold'      => 1}
  
  COLORS.each do |color, value|
    define_method(color) { colorize(self, :foreground => color) }
    define_method("on_#{color}") { colorize(self, :background => color) }
    COLORS.each do |highlight, value|
      next if color == highlight
      define_method("#{color}_on_#{highlight}") { colorize(self, :foreground => color, :background => highlight) }
    end
  end
  EXTRAS.each do |extra, value|
    next if extra == 'clear'
    define_method(extra) { colorize(self, :extra => extra) }
  end
  define_method(:to_eol) do
    tmp = sub(/^(\e\[[\[\e0-9;m]+m)/, "\\1\e[2K")
    if tmp == self
      return "\e[2K" << self
    end
    tmp
  end
  def colorize(string, options = {})
    colored = [color(options[:foreground]), color("on_#{options[:background]}"), extra(options[:extra])].compact * ''
    colored << string
    colored << extra(:clear)
  end
  def colors
    @@colors ||= COLORS.keys.sort
  end
  def extra(extra_name)
    extra_name = extra_name.to_s
    "\e[#{EXTRAS[extra_name]}m" if EXTRAS[extra_name]
  end
  def color(color_name)
    background = color_name.to_s =~ /on_/
    color_name = color_name.to_s.sub('on_', '')
    return unless color_name && COLORS[color_name]
    "\e[#{COLORS[color_name] + (background ? 10 : 0)}m" 
  end
end unless Object.const_defined? :Colored
String.send(:include, Colored)

require 'open3'

def silence!
#  Rails::Generator::Base.logger.quiet = true
end
def verbum!
#  Rails::Generator::Base.logger.quiet = false
end

def add_desert_require
  sentinel = 'Rails::Initializer.run do |config|'
  gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi, "\nrequire 'desert'\n\\1" 
end

def install_require_gems
  run "gem sources -a http://gems.github.com"
  
  gem 'desert', :lib => 'desert', :version => '>= 0.5.2'
  gem 'mislav-will_paginate', :lib => 'will_paginate', :version => '~> 2.3.6'
  gem 'tog-tog', :lib => 'tog', :version => '>= 0.5'
  gem 'thoughtbot-factory_girl', :lib => 'factory_girl'
  gem 'jackdempsey-acts_as_commentable', :lib => 'acts_as_commentable', :version => '2.0.1'
  gem "mreinsch-acts_as_rateable", :lib => "acts_as_rateable", :version => '2.0.1'
  gem 'RedCloth', :lib => 'redcloth', :version => '4.2.0'
  gem "mbleigh-acts-as-taggable-on", :lib => "acts-as-taggable-on", :version => '1.0.5'
  gem "linkingpaths-acts_as_abusable", :lib => "acts_as_abusable", :version => '0.0.2'
  gem 'rubyist-aasm', :version => '~> 2.1.1', :lib => 'aasm'
  
  puts "\n"
  if yes?("Install required gems as root? (y/n). If you are using Windows, please, answer 'n'. If installing gems as superuser you could be asked to enter your password.") 
    rake "gems:install", :sudo => true
{'fraction_non_alphanumeric': 0.180858310626703, 'fraction_numerical': 0.01651907356948229, 'mean_word_length': 3.7786818551668024, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 71, 'https://': 0, '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': '1597536', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2206, 'n_words': 499}