class TorqueBox::Rails

@api private

Public Class Methods

apply_template( root ) click to toggle source
# File lib/torquebox/rails.rb, line 45
def self.apply_template( root )
  print_rails_not_installed_and_exit unless rails_installed?
  require_generators
  if using_rails3_or_greater?
    generator = ::Rails::Generators::AppGenerator.new( [root], {}, :destination_root => root )
    Dir.chdir(root)
    generator.apply TorqueBox::Rails.template
  else
    ::Rails::TemplateRunner.new( TorqueBox::Rails.template )
  end
end
new_app( root ) click to toggle source
# File lib/torquebox/rails.rb, line 28
def self.new_app( root )
  print_rails_not_installed_and_exit unless rails_installed?
  require_generators
  # Ensure ARGV[0] has the application path
  if ARGV.empty? || ARGV[0] != root
    ARGV.unshift( root )
  end
  ARGV << [ "-m", TorqueBox::Rails.template ]
  ARGV.flatten!
  if using_rails3_or_greater?
    ::Rails::Generators::AppGenerator.start
  else
    ::Rails::Generator::Base.use_application_sources!
    ::Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app')
  end
end
print_rails_not_installed_and_exit() click to toggle source
rails_installed?() click to toggle source
# File lib/torquebox/rails.rb, line 63
def self.rails_installed?
  defined? ::Rails::VERSION
end
require_generators() click to toggle source
# File lib/torquebox/rails.rb, line 76
def self.require_generators
  if using_rails3_or_greater?
    require 'rails/generators'
    require 'rails/generators/rails/app/app_generator'
  else
    require 'rails_generator'
    require 'rails_generator/generators/applications/app/app_generator'
    require 'rails_generator/generators/applications/app/template_runner'
    require 'rails_generator/scripts/generate'
  end
end
template() click to toggle source
# File lib/torquebox/rails.rb, line 58
def self.template
  File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'share',
            'rails', 'template.rb')
end
using_rails3_or_greater?() click to toggle source
# File lib/torquebox/rails.rb, line 72
def self.using_rails3_or_greater?
  ::Rails::VERSION::MAJOR >= 3
end