Sha256: a2bc710a032cd1011ad04c3d77baee48250aa1c91893e5c201b8248fba4347a3

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

require "spring/errors"

module Spring
  class << self
    attr_accessor :application_root, :quiet

    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
        if application_root
          path = Pathname.new(File.expand_path(application_root))
        else
          path = project_root_path
        end

        raise MissingApplication.new(path) unless path.join("config/application.rb").exist?
        path
      end
    end

    def project_root_path
      @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
    end

    private

    def find_project_root(current_dir)
      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

  self.quiet = false
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/spring-2.1.0/lib/spring/configuration.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/spring-2.1.0/lib/spring/configuration.rb
spring-2.1.0 lib/spring/configuration.rb
spring-2.0.2 lib/spring/configuration.rb
spring-2.0.1 lib/spring/configuration.rb
spring-2.0.0 lib/spring/configuration.rb
spring-1.7.2 lib/spring/configuration.rb
spring-1.7.1 lib/spring/configuration.rb
spring-1.7.0 lib/spring/configuration.rb
spring-1.6.4 lib/spring/configuration.rb
spring-1.6.3 lib/spring/configuration.rb
spring-1.6.2 lib/spring/configuration.rb
spring-1.6.1 lib/spring/configuration.rb
spring-1.6.0 lib/spring/configuration.rb