acpc_poker_types 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: bfe40c1a733d3678c62f4de63c649864408ca8ff
4
- data.tar.gz: 75758c743dcdac65039dd7b369dcfe0f15dd2f94
3
+ metadata.gz: 621b7409ffa2bb10cfd149ea4095d18e01e2fb78
4
+ data.tar.gz: 7a6b6c71dafcea5276d4a0cbccf01e24b9621a03
5
5
  SHA512:
6
- metadata.gz: 840f979748a1d5bb9dff3ea26371f807835cb36a2179eee010929e786fa6fc16571a070c84a6ba0d8d3254f16f774447fa40520c3e75847c39705740a2c596bb
7
- data.tar.gz: 5463e698ad55cf608f8f79400b89015c030868ea80afdfca645efefa1a1d88e90d4e9bd63ffefd5ca5cd818d1902c5c0dc26b1f9eb42d22fef363db7c8482609
6
+ metadata.gz: 1b3f6989f5dbb77fac80ac711e0783928acb55345add460f42bb6d6860cf5c9bbaf233f6b36e69ec5c3a1a4050928f9b64bfa8a68f134683b272072355e4a858
7
+ data.tar.gz: 63face898038f4ff0a877aab6d0512af11c0a0f639db5d3e4455cb53e8a16d0d1d2ba1b686abb310c09162561f436d29150afe7f3178bedd44f2abb1e738e665
@@ -5,6 +5,31 @@ require 'acpc_poker_types/chip_stack'
5
5
  require 'contextual_exceptions'
6
6
  using ContextualExceptions::ClassRefinement
7
7
 
8
+ module BlankRefinement
9
+ refine Object do
10
+ def blank?
11
+ respond_to?(:empty?) ? empty? : !self
12
+ end
13
+ end
14
+ refine NilClass do
15
+ def blank?
16
+ true
17
+ end
18
+ def strip
19
+ self
20
+ end
21
+ end
22
+ refine Array do
23
+ alias_method :blank?, :empty?
24
+ end
25
+ refine String do
26
+ def blank?
27
+ self !~ /\S/
28
+ end
29
+ end
30
+ end
31
+ using BlankRefinement
32
+
8
33
  module AcpcPokerTypes
9
34
  class PokerAction
10
35
  exceptions :illegal_action, :illegal_modification
@@ -43,7 +68,7 @@ module AcpcPokerTypes
43
68
  # +:pot_gained_chips+, and +:cost+.
44
69
  # @raise IllegalAction
45
70
  def initialize(action, modifier: nil, cost: AcpcPokerTypes::ChipStack.new(0))
46
- validate_action!(action, modifier)
71
+ validate_action!(action, modifier.strip)
47
72
  @cost = cost
48
73
  end
49
74
 
@@ -71,7 +96,7 @@ module AcpcPokerTypes
71
96
 
72
97
  # @return [Boolean] +true+ if this action has a modifier, +false+ otherwise.
73
98
  def has_modifier?
74
- !@modifier.nil?
99
+ !@modifier.blank?
75
100
  end
76
101
 
77
102
  private
@@ -85,18 +110,18 @@ module AcpcPokerTypes
85
110
  raise IllegalAction if action_string.empty?
86
111
  @action = action_string[0]
87
112
  raise IllegalAction unless ACTIONS.include?(@action)
88
- @modifier = action_string[1..-1] unless action_string.length < 2
113
+ @modifier = action_string[1..-1].strip unless action_string.length < 2
89
114
 
90
- if given_modifier && @modifier && !@modifier.empty?
115
+ if !given_modifier.blank? && !@modifier.blank?
91
116
  raise(
92
117
  IllegalModification,
93
118
  "in-place modifier: #{@modifier}, explicit modifier: #{given_modifier}"
94
119
  )
95
120
  end
96
121
 
97
- @modifier = if @modifier && !@modifier.empty?
122
+ @modifier = if !@modifier.blank?
98
123
  @modifier
99
- elsif given_modifier
124
+ elsif !given_modifier.blank?
100
125
  given_modifier
101
126
  end
102
127
 
@@ -106,7 +131,7 @@ module AcpcPokerTypes
106
131
  end
107
132
 
108
133
  def validate_modifier
109
- raise(IllegalModification, "Illegal modifier: #{@modifier}") unless @modifier.nil? || AcpcPokerTypes::PokerAction::MODIFIABLE_ACTIONS.include?(@action)
134
+ raise(IllegalModification, "Illegal modifier: #{@modifier}") unless @modifier.blank? || AcpcPokerTypes::PokerAction::MODIFIABLE_ACTIONS.include?(@action)
110
135
  end
111
136
  end
112
137
  end
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '3.2.0'
2
+ VERSION = '3.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
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-05-16 00:00:00.000000000 Z
11
+ date: 2013-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: process_runner