Class: TorqueBox::Rails Private
- Inherits:
-
Object
- Object
- TorqueBox::Rails
- Defined in:
- lib/torquebox/rails.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .apply_template(root) ⇒ Object private
- .new_app(root) ⇒ Object private
- .print_rails_not_installed_and_exit ⇒ Object private
- .rails_installed? ⇒ Boolean private
- .require_generators ⇒ Object private
- .template ⇒ Object private
- .using_rails3_or_greater? ⇒ Boolean private
Class Method Details
.apply_template(root) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 52 53 54 55 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 |
# File 'lib/torquebox/rails.rb', line 67 def self.print_rails_not_installed_and_exit $stderr.puts "Rails not installed. Unable to load generators" exit 1 end |
.rails_installed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/torquebox/rails.rb', line 63 def self.rails_installed? defined? ::Rails::VERSION end |
.require_generators ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 81 82 83 84 85 86 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 |
# File 'lib/torquebox/rails.rb', line 58 def self.template File.join(File.(File.dirname(__FILE__)), '..', '..', 'share', 'rails', 'template.rb') end |
.using_rails3_or_greater? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 |
# File 'lib/torquebox/rails.rb', line 72 def self.using_rails3_or_greater? ::Rails::VERSION::MAJOR >= 3 end |