acpc_poker_basic_proxy 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8830e03ad490d6a24dac3b73c647fee5988aea43
         | 
| 4 | 
            +
              data.tar.gz: e476afcc89336bd58bf33d5b2c2ae88776d9525d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3c160055f942244c12365e97893236e53c74acdb94329ebeedc41f53686eb535c4023fb33ba8fc142d2d8676666d1a228027636459dd530e9b8ecf6205fa13a2
         | 
| 7 | 
            +
              data.tar.gz: f98d89ceb150f1c073abbb9a0a32ce2a6f26a11a70daa68ef5bcdcb2ebcd2bc347dd5abd4787d1b60015ada37d40c97b189bf06c7315d9fc150ea705f6c5cffd
         | 
    
        data/Rakefile
    CHANGED
    
    
| @@ -63,6 +63,7 @@ module AcpcPokerBasicProxy | |
| 63 63 | 
             
                # @param [String] host_name The host on which the dealer is running. Defaults to 'localhost'
         | 
| 64 64 | 
             
                # @raise AcpcDealerConnectionError, UnableToWriteToDealer
         | 
| 65 65 | 
             
                def initialize(port, host_name='localhost')
         | 
| 66 | 
            +
                  @dealer_socket = nil
         | 
| 66 67 | 
             
                  begin
         | 
| 67 68 | 
             
                    @dealer_socket = TCPSocket.new(host_name, port)
         | 
| 68 69 | 
             
                    super @dealer_socket
         | 
| @@ -94,7 +95,7 @@ module AcpcPokerBasicProxy | |
| 94 95 | 
             
                # @raise UnableToWriteToDealer
         | 
| 95 96 | 
             
                def write(string)
         | 
| 96 97 | 
             
                  begin
         | 
| 97 | 
            -
                     | 
| 98 | 
            +
                    send_string_to_dealer string
         | 
| 98 99 | 
             
                  rescue => e
         | 
| 99 100 | 
             
                    handle_error UnableToWriteToDealer, "Unable to send the string, \"#{string}\", to the dealer", e
         | 
| 100 101 | 
             
                  end
         | 
    
        data/spec/basic_proxy_spec.rb
    CHANGED
    
    | @@ -163,7 +163,6 @@ describe BasicProxy do | |
| 163 163 | 
             
                          next unless match.current_hand.next_action
         | 
| 164 164 |  | 
| 165 165 | 
             
                          from_player_message = match.current_hand.next_action.state
         | 
| 166 | 
            -
                          seat_taking_action = match.current_hand.next_action.seat
         | 
| 167 166 | 
             
                          action = match.current_hand.next_action.action
         | 
| 168 167 |  | 
| 169 168 | 
             
                          action_that_should_be_sent = "#{from_player_message.to_s}:#{action.to_acpc}"
         | 
    
        data/spec/dealer_stream_spec.rb
    CHANGED
    
    | @@ -13,7 +13,6 @@ describe DealerStream do | |
| 13 13 | 
             
              end
         | 
| 14 14 | 
             
              describe '#new' do
         | 
| 15 15 | 
             
                it 'works properly' do
         | 
| 16 | 
            -
                  start_test_connection!
         | 
| 17 16 | 
             
                  end_test_connection!
         | 
| 18 17 | 
             
                end
         | 
| 19 18 | 
             
                it "fails if the port doesn't correspond to a running server" do
         | 
| @@ -23,56 +22,56 @@ describe DealerStream do | |
| 23 22 | 
             
                  -> { DealerStream.new(port) }.must_raise DealerStream::UnableToConnectToDealer
         | 
| 24 23 | 
             
                end
         | 
| 25 24 | 
             
              end
         | 
| 25 | 
            +
              let(:port) { 0 }
         | 
| 26 | 
            +
              let(:fake_dealer) { TCPServer.open(port) }
         | 
| 27 | 
            +
              let(:client_connection) { fake_dealer.accept }
         | 
| 28 | 
            +
              let(:patient) do
         | 
| 29 | 
            +
                DealerStream.new(
         | 
| 30 | 
            +
                  fake_dealer.addr[1],
         | 
| 31 | 
            +
                  'localhost'
         | 
| 32 | 
            +
                )
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
              let(:match_state) { 'MATCHSTATE:0:0::5d5c' }
         | 
| 35 | 
            +
             | 
| 26 36 | 
             
              describe "#ready_to_read?" do
         | 
| 27 37 | 
             
                it 'lets the caller know that there is new input from the dealer' do
         | 
| 28 38 | 
             
                  connect_successfully!
         | 
| 29 | 
            -
                   | 
| 30 | 
            -
                   | 
| 39 | 
            +
                  client_connection.puts "New input"
         | 
| 40 | 
            +
                  patient.ready_to_read?.must_equal true
         | 
| 31 41 | 
             
                end
         | 
| 32 42 | 
             
              end
         | 
| 33 43 | 
             
              describe "#ready_to_write?" do
         | 
| 34 44 | 
             
                it 'lets the caller know if the dealer is ready to receive data' do
         | 
| 35 45 | 
             
                  connect_successfully!
         | 
| 36 | 
            -
                   | 
| 46 | 
            +
                  patient.ready_to_write?.must_equal true
         | 
| 37 47 | 
             
                end
         | 
| 38 48 | 
             
              end
         | 
| 39 49 | 
             
              describe "#write" do
         | 
| 40 50 | 
             
                it "properly sends actions to the dealer" do
         | 
| 41 51 | 
             
                  connect_successfully!
         | 
| 42 | 
            -
                  action =  | 
| 43 | 
            -
                   | 
| 52 | 
            +
                  action = match_state + ':c'
         | 
| 53 | 
            +
                  patient.write action
         | 
| 44 54 |  | 
| 45 | 
            -
                   | 
| 55 | 
            +
                  client_connection.gets.chomp.must_equal(action)
         | 
| 46 56 | 
             
                end
         | 
| 47 57 | 
             
              end
         | 
| 48 58 | 
             
              describe "#gets" do
         | 
| 49 59 | 
             
                it "properly receives matchstate strings from the dealer" do
         | 
| 50 60 | 
             
                  connect_successfully!
         | 
| 51 | 
            -
                   | 
| 52 | 
            -
                   | 
| 61 | 
            +
                  client_connection.puts match_state
         | 
| 62 | 
            +
                  patient.gets.must_equal(match_state)
         | 
| 53 63 | 
             
                end
         | 
| 54 64 | 
             
              end
         | 
| 55 65 |  | 
| 56 66 | 
             
              def end_test_connection!
         | 
| 57 | 
            -
                 | 
| 58 | 
            -
                 | 
| 59 | 
            -
              end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
              def start_test_connection!(port = 0)
         | 
| 62 | 
            -
                fake_dealer = TCPServer.open(port)
         | 
| 63 | 
            -
                @patient = DealerStream.new(
         | 
| 64 | 
            -
                  fake_dealer.addr[1],
         | 
| 65 | 
            -
                  'localhost'
         | 
| 66 | 
            -
                )
         | 
| 67 | 
            -
                @client_connection = fake_dealer.accept
         | 
| 67 | 
            +
                patient.close if !patient.closed?
         | 
| 68 | 
            +
                client_connection.close if !client_connection.closed?
         | 
| 68 69 | 
             
              end
         | 
| 69 70 |  | 
| 70 71 | 
             
              def connect_successfully!
         | 
| 71 | 
            -
                 | 
| 72 | 
            -
                 | 
| 72 | 
            +
                patient
         | 
| 73 | 
            +
                client_connection.gets.chomp.must_equal(
         | 
| 73 74 | 
             
                  "#{DealerStream::VERSION_LABEL}:#{DealerStream::VERSION_NUMBERS[:major]}.#{DealerStream::VERSION_NUMBERS[:minor]}.#{DealerStream::VERSION_NUMBERS[:revision]}"
         | 
| 74 75 | 
             
                )
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                @match_state = 'MATCHSTATE:0:0::5d5c'
         | 
| 77 76 | 
             
              end
         | 
| 78 77 | 
             
            end
         |