Sha256: b33c45a93d46674459fe2698003d4b1529b6c59b3a5793fddcd2a303a9344e0e

Contents?: true

Size: 799 Bytes

Versions: 34

Compression:

Stored size: 799 Bytes

Contents

require 'drb/drb'
DRBURI="druby://localhost:8787"

module DrbMockServer
  extend self

  def start_client
    # JRuby doesn't support fork
    if defined? JRUBY_VERSION
      @server = MockServer.new(2)
      at_exit { @server.stop }
    else
      child_pid = Process.fork do
        start_server
      end
      sleep 1
      at_exit { Process.kill("HUP", child_pid); Process.wait2 }
      DRb.start_service
      @server = DRbObject.new_with_uri(DRBURI)
      sleep 1
    end
    true
  end

  def maybe_start
    start_client unless @server
  end

  def method_missing(meth, *args, &block)
    @server.send(meth, *args, &block)
  end

  def start_server
    server = MockServer.new
    DRb.start_service(DRBURI, server)
    Signal.trap("HUP") { server.stop; exit }
    DRb.thread.join
  end
end

Version data entries

34 entries across 24 versions & 2 rubygems

Version Path
riak-client-1.0.2 pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb
riak-client-1.0.2 pkg/riak-client-1.0.1/spec/support/drb_mock_server.rb
riak-client-1.0.2 spec/support/drb_mock_server.rb
riak-client-1.0.0 spec/support/drb_mock_server.rb
seomoz-riak-client-1.0.0.pre spec/support/drb_mock_server.rb
riak-client-1.0.0.beta spec/support/drb_mock_server.rb
riak-client-0.9.8 spec/support/drb_mock_server.rb
riak-client-0.9.5 spec/support/drb_mock_server.rb
riak-client-0.9.4 spec/support/drb_mock_server.rb
riak-client-0.9.3 spec/support/drb_mock_server.rb
riak-client-0.9.2 spec/support/drb_mock_server.rb
riak-client-0.9.1 spec/support/drb_mock_server.rb
riak-client-0.9.0 spec/support/drb_mock_server.rb
riak-client-0.9.0.beta2 spec/support/drb_mock_server.rb