Sha256: 8a238cd2f1b28f0fcd5bfde1d4414f55fd1095a66a5f9542dc76702bdd71d61d

Contents?: true

Size: 1.64 KB

Versions: 9

Compression:

Stored size: 1.64 KB

Contents

module JsTestCore
  class Server
    class << self
      attr_accessor :instance

      def run(spec_root_path, implementation_root_path, public_path, server_options = {})
        server_options[:Host] ||= DEFAULT_HOST
        server_options[:Port] ||= DEFAULT_PORT
        @instance = new(spec_root_path, implementation_root_path, public_path, server_options[:Host], server_options[:Port])
        instance.run server_options
      end

      def spec_root_path; instance.spec_root_path; end
      def implementation_root_path; instance.implementation_root_path; end
      def public_path; instance.public_path; end
      def core_path; instance.core_path; end
      def request; instance.request; end
      def response; instance.response; end
      def root_url; instance.root_url; end
    end

    attr_reader :host, :port, :spec_root_path, :implementation_root_path, :public_path

    def initialize(spec_root_path, implementation_root_path, public_path, host=DEFAULT_HOST, port=DEFAULT_PORT)
      dir = ::File.dirname(__FILE__)
      @spec_root_path = ::File.expand_path(spec_root_path)
      @implementation_root_path = ::File.expand_path(implementation_root_path)
      @public_path = ::File.expand_path(public_path)
      @host = host
      @port = port
    end

    def run(options)
      server = ::Thin::Server.new(options[:Host], options[:Port]) do
        use Rack::CommonLogger
      end
      server.backend = ::Thin::Backends::JsTestCoreServer.new(options[:Host], options[:Port])
      server.backend.server = server
      server.start!
    end

    def root_url
      "http://#{host}:#{port}"
    end

    def core_path
      JsTestCore.core_path
    end
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
pivotal-screw-unit-0.4.0 vendor/js-test-core/lib/js_test_core/server.rb
pivotal-screw-unit-0.4.1 vendor/js-test-core/lib/js_test_core/server.rb
pivotal-screw-unit-0.4.2 vendor/js-test-core/lib/js_test_core/server.rb
pivotal-screw-unit-0.4.3 vendor/js-test-core/lib/js_test_core/server.rb
js_spec-0.3.2 vendor/js-test-core/lib/js_test_core/server.rb
js_spec-0.3.3 vendor/js-test-core/lib/js_test_core/server.rb
js_test_core-0.2.0 lib/js_test_core/server.rb
screw-unit-0.3.3 vendor/js-test-core/lib/js_test_core/server.rb
screw-unit-0.3.1 vendor/js-test-core/lib/js_test_core/server.rb