Sha256: 262a88cb5fc793ee9cd89e68419113fdc55294526b2d16c8113df50104be8086

Contents?: true

Size: 1018 Bytes

Versions: 226

Compression:

Stored size: 1018 Bytes

Contents

require 'pathname'

module Rails
  module ScriptRailsLoader
    RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
    SCRIPT_RAILS = File.join('script', 'rails')

    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

    def self.in_rails_application?
      File.exists?(SCRIPT_RAILS)
    end

    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
  end
end

Version data entries

226 entries across 187 versions & 19 rubygems

Version Path
railties-3.2.22.5 lib/rails/script_rails_loader.rb
railties-3.2.22.4 lib/rails/script_rails_loader.rb
railties-3.2.22.3 lib/rails/script_rails_loader.rb
railties-3.2.22.2 lib/rails/script_rails_loader.rb
railties-3.2.22.1 lib/rails/script_rails_loader.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/script_rails_loader.rb
railties-3.2.22 lib/rails/script_rails_loader.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/railties-3.2.12/lib/rails/script_rails_loader.rb
railties-3.2.21 lib/rails/script_rails_loader.rb
railties-3.2.20 lib/rails/script_rails_loader.rb
railties-3.2.19 lib/rails/script_rails_loader.rb
railties-3.2.18 lib/rails/script_rails_loader.rb
railties-3.2.17 lib/rails/script_rails_loader.rb
railties-3.2.16 lib/rails/script_rails_loader.rb
railties-3.2.15 lib/rails/script_rails_loader.rb
railties-3.2.15.rc3 lib/rails/script_rails_loader.rb
railties-3.2.15.rc2 lib/rails/script_rails_loader.rb
railties-3.2.15.rc1 lib/rails/script_rails_loader.rb
railties-3.2.14 lib/rails/script_rails_loader.rb
railties-3.2.14.rc2 lib/rails/script_rails_loader.rb