Sha256: 09cf2adbdbf4983577ede0a44c1fb6f93ab8b8f0c0db82b0221f4ddd47b8c73a

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require "spring-jruby/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
        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

    def pool_min_free_workers
      2
    end

    def pool_spawn_parallel
      true
    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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spring-jruby-1.4.3 lib/spring-jruby/configuration.rb