Sha256: 781a3571a2adfef93347368d6eb7a4ebbb6ce5e49d05aa1cde7d28dd2328040f

Contents?: true

Size: 940 Bytes

Versions: 6

Compression:

Stored size: 940 Bytes

Contents

require "spring/errors"

module Spring
  class << self
    attr_accessor :application_root

    def gemfile
      ENV['BUNDLE_GEMFILE'] || "Gemfile"
    end

    def after_fork_callbacks
      @after_fork_callbacks ||= []
    end

    def after_fork(&block)
      after_fork_callbacks << block
    end

    def verify_environment
      application_root_path
    end

    def application_root_path
      @application_root_path ||= begin
        path = Pathname.new(File.expand_path(application_root || find_project_root))
        raise MissingApplication.new(path) unless path.join("config/application.rb").exist?
        path
      end
    end

    private

    def find_project_root(current_dir = Pathname.new(Dir.pwd))
      if current_dir.join(gemfile).exist?
        current_dir
      elsif current_dir.root?
        raise UnknownProject.new(Dir.pwd)
      else
        find_project_root(current_dir.parent)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spring-1.1.0.beta1 lib/spring/configuration.rb
spring-1.0.0 lib/spring/configuration.rb
spring-0.9.2 lib/spring/configuration.rb
spring-0.9.1 lib/spring/configuration.rb
spring-0.9.0 lib/spring/configuration.rb
spring-0.0.11 lib/spring/configuration.rb