Module: Rails::ScriptRailsLoader
- Defined in:
- lib/rails/script_rails_loader.rb
Constant Summary collapse
- RUBY =
File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
- SCRIPT_RAILS =
File.join('script', 'rails')
Class Method Summary collapse
- .exec_script_rails! ⇒ Object
- .in_rails_application? ⇒ Boolean
- .in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd)) ⇒ Boolean
Class Method Details
.exec_script_rails! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails/script_rails_loader.rb', line 8 def self.exec_script_rails! cwd = Dir.pwd return unless in_rails_application? || in_rails_application_subdirectory? exec RUBY, SCRIPT_RAILS, *ARGV if in_rails_application? Dir.chdir("..") do # Recurse in a chdir block: if the search fails we want to be sure # the application is generated in the original working directory. exec_script_rails! unless cwd == Dir.pwd end rescue SystemCallError # could not chdir, no problem just return end |
.in_rails_application? ⇒ Boolean
21 22 23 |
# File 'lib/rails/script_rails_loader.rb', line 21 def self.in_rails_application? File.exists?(SCRIPT_RAILS) end |
.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd)) ⇒ Boolean
25 26 27 |
# File 'lib/rails/script_rails_loader.rb', line 25 def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd)) File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent) end |