class CompassAeStarterKit::CompassAE

Public Class Methods

banner() click to toggle source
run() click to toggle source
# File lib/compass_ae_starter_kit/commands/compass_ae.rb, line 20
  def run
  #Get rails version
  major, minor, tiny = `rails -v`.gsub!('Rails ', '').gsub!("\n",'').split('.').collect{|version| version.to_i}
  if version_allowed?(RAILS_MAJOR, major) and version_allowed?(RAILS_MINOR, minor) and version_allowed?(RAILS_TINY, tiny)
    template_path = File.join(File.dirname(__FILE__), '../templates/default_template.rb')
  
    if ARGV.first != "new" and ARGV.first != "dev"
      ARGV[0] = "--help"
    end
  
    if ARGV.first == "dev"
      template_path = File.join(File.dirname(__FILE__), '../templates/development_template.rb')
      ARGV[0] = "new"
    end

    command = ARGV.shift
    case command
    when '--help'
      puts self.banner
    when 'new'
      app_name = ARGV.shift
      raise "The application name is missing!" if app_name.nil?
      puts 'Generating Rails infrastructure...'
      system "rails new #{app_name} #{ARGV * ' '} -m #{template_path}"
      Dir.chdir app_name
      puts 'Installing CompassAE migrations and data migrations...'
      system "rake compass_ae:install:all_migrations"
      puts 'Migrating a fresh database...'
      system "rake db:migrate"
      system "rake db:migrate_data"
    end
  else
    puts "Installed Rails version is not compatible #{[major, minor, tiny].compact.join('.')}, please install #{[RAILS_MAJOR, RAILS_MINOR, RAILS_TINY].compact.join('.')}"
  end

end
version_allowed?(allowed_version, version) click to toggle source
# File lib/compass_ae_starter_kit/commands/compass_ae.rb, line 57
def version_allowed?(allowed_version, version)
  result = true
  unless(allowed_version == '*')
    result = (allowed_version == version)
  end
  result
end