acpc_poker_basic_proxy 3.0.2 → 3.0.3
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 +4 -4
- data/acpc_poker_basic_proxy.gemspec +1 -1
- data/lib/acpc_poker_basic_proxy/basic_proxy.rb +4 -1
- data/lib/acpc_poker_basic_proxy/dealer_stream.rb +3 -10
- data/lib/acpc_poker_basic_proxy/version.rb +1 -1
- data/spec/basic_proxy_spec.rb +2 -2
- data/spec/coverage/index.html +1 -1
- data/spec/dealer_stream_spec.rb +2 -13
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47020c0a9aa82a5b58e245fedcfbdb04d73d2aad
|
4
|
+
data.tar.gz: 6df9cf1e633ecb1b2a3b5138f99461eaf2f87ce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a7501ed9aa2e6e438990cc91d6e41cfb80d82cac8ee8620d6a9ab59d5ef19d6770ab8cb54abf908a546ee588bf6d11662fd7cdca9240914ab4bafb05ea42d98
|
7
|
+
data.tar.gz: 7e7861566bbbb349a0fc7afa6c37ec29d3330ef12af197446434ab0a14cf180fcb02f0d0aacbf9f82af9a77b4f424af1545817cd55ce8473ceea54ed29d7fc43
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'awesome_print', '~> 1.0'
|
26
26
|
s.add_development_dependency 'pry-rescue', '~> 1.0'
|
27
27
|
s.add_development_dependency 'simplecov', '~> 0.7'
|
28
|
-
s.add_development_dependency 'acpc_dealer', '~>
|
28
|
+
s.add_development_dependency 'acpc_dealer', '~> 2.0'
|
29
29
|
end
|
@@ -41,7 +41,10 @@ module AcpcPokerBasicProxy
|
|
41
41
|
|
42
42
|
# @param [AcpcDealer::ConnectionInformation] dealer_information Information about the dealer to which this bot should connect.
|
43
43
|
def initialize(dealer_information)
|
44
|
-
@dealer_communicator = DealerStream.new
|
44
|
+
@dealer_communicator = DealerStream.new(
|
45
|
+
dealer_information.port_number,
|
46
|
+
dealer_information.host_name
|
47
|
+
)
|
45
48
|
end
|
46
49
|
|
47
50
|
# @param [PokerAction] action The action to be sent.
|
@@ -59,19 +59,12 @@ module AcpcPokerBasicProxy
|
|
59
59
|
|
60
60
|
# @param [Integer] port The port on which to connect to the dealer.
|
61
61
|
# @param [String] host_name The host on which the dealer is running. Defaults to 'localhost'
|
62
|
-
# @param [Integer] millisecond_response_timeout The dealer's response timeout, in milliseconds.
|
63
62
|
# @raise AcpcDealerConnectionError, UnableToWriteToDealer
|
64
|
-
def initialize(port, host_name='localhost'
|
63
|
+
def initialize(port, host_name='localhost')
|
65
64
|
begin
|
66
65
|
@dealer_socket = TCPSocket.new(host_name, port)
|
67
66
|
super @dealer_socket
|
68
67
|
|
69
|
-
@response_timeout_in_seconds = if millisecond_response_timeout
|
70
|
-
millisecond_response_timeout/(10**3).to_r
|
71
|
-
else
|
72
|
-
nil
|
73
|
-
end
|
74
|
-
|
75
68
|
send_version_string_to_dealer
|
76
69
|
rescue UnableToWriteToDealer
|
77
70
|
raise
|
@@ -107,12 +100,12 @@ module AcpcPokerBasicProxy
|
|
107
100
|
|
108
101
|
# @see TCPSocket#ready_to_write?
|
109
102
|
def ready_to_write?
|
110
|
-
@dealer_socket.ready_to_write?
|
103
|
+
@dealer_socket.ready_to_write?
|
111
104
|
end
|
112
105
|
|
113
106
|
# @see TCPSocket#ready_to_read?
|
114
107
|
def ready_to_read?
|
115
|
-
@dealer_socket.ready_to_read?
|
108
|
+
@dealer_socket.ready_to_read?
|
116
109
|
end
|
117
110
|
|
118
111
|
private
|
data/spec/basic_proxy_spec.rb
CHANGED
@@ -17,10 +17,10 @@ describe BasicProxy do
|
|
17
17
|
port_number = 9001
|
18
18
|
host_name = 'localhost'
|
19
19
|
millisecond_response_timeout = 0
|
20
|
-
delaer_info = AcpcDealer::ConnectionInformation.new port_number, host_name
|
20
|
+
delaer_info = AcpcDealer::ConnectionInformation.new port_number, host_name
|
21
21
|
@dealer_communicator = mock 'DealerStream'
|
22
22
|
|
23
|
-
DealerStream.expects(:new).once.with(port_number, host_name
|
23
|
+
DealerStream.expects(:new).once.with(port_number, host_name).returns(@dealer_communicator)
|
24
24
|
|
25
25
|
@patient = BasicProxy.new delaer_info
|
26
26
|
|
data/spec/coverage/index.html
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
<img src="./assets/0.7.1/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="2013-
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2013-06-07T17:36:13-06:00">2013-06-07T17:36:13-06:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
data/spec/dealer_stream_spec.rb
CHANGED
@@ -24,10 +24,6 @@ describe DealerStream do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
describe "#ready_to_read?" do
|
27
|
-
it 'lets the caller know that there is not new input from the dealer' do
|
28
|
-
connect_successfully!
|
29
|
-
@patient.ready_to_read?.must_equal false
|
30
|
-
end
|
31
27
|
it 'lets the caller know that there is new input from the dealer' do
|
32
28
|
connect_successfully!
|
33
29
|
@client_connection.puts "New input"
|
@@ -55,12 +51,6 @@ describe DealerStream do
|
|
55
51
|
@client_connection.puts @match_state
|
56
52
|
@patient.gets.must_equal(@match_state)
|
57
53
|
end
|
58
|
-
it 'disconnects if the timeout is reached' do
|
59
|
-
[0, 100].each do |t|
|
60
|
-
start_test_connection! t
|
61
|
-
-> { @patient.gets }.must_raise DealerStream::UnableToGetFromDealer
|
62
|
-
end
|
63
|
-
end
|
64
54
|
end
|
65
55
|
|
66
56
|
def end_test_connection!
|
@@ -68,12 +58,11 @@ describe DealerStream do
|
|
68
58
|
@client_connection.close if @client_connection && !@client_connection.closed?
|
69
59
|
end
|
70
60
|
|
71
|
-
def start_test_connection!(
|
61
|
+
def start_test_connection!(port = 0)
|
72
62
|
fake_dealer = TCPServer.open(port)
|
73
63
|
@patient = DealerStream.new(
|
74
64
|
fake_dealer.addr[1],
|
75
|
-
'localhost'
|
76
|
-
millisecond_response_timeout
|
65
|
+
'localhost'
|
77
66
|
)
|
78
67
|
@client_connection = fake_dealer.accept
|
79
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acpc_poker_basic_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acpc_poker_types
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '2.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '2.0'
|
139
139
|
description: Basic proxy to connect to the ACPC Dealer.
|
140
140
|
email:
|
141
141
|
- morrill@ualberta.ca
|