games_dice 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32e7a4b347340a1fce6ae0777e0e152ec0bd3f7c
4
- data.tar.gz: f38a06b757f67e7066a8ccd01a6ecf4978cfbb18
3
+ metadata.gz: d19dba764a16a41817baaa3ccfd957f79433c9b0
4
+ data.tar.gz: 29037036e7fe3d1f5456e66bec3d8675a2434eaa
5
5
  SHA512:
6
- metadata.gz: 6ada816ccb2d5a9930cc01617ec90847f3cd406a4b42e6cd27907fccd8df02a2564592e4eae67ebd375c6deb9b1034a177e001c5b25384906fc8c17d16ac86e0
7
- data.tar.gz: 452ef531000721460c09170aff72672e5d6909b253647f7203691a7d24eee8c3c300ee2703f8b3c68d628af91432b3feae5d3182d2c7db7085101d7547778078
6
+ metadata.gz: 8420089013a0439dd92199fc276bdb718ab4abb9e5cef872542b1d87d545ab53a9c382bb8ebb3d2fe7226816e3a1cd9b4a071e6659cc0ad7d0fbd959ef5135e8
7
+ data.tar.gz: 69c75770fc39c5d4ada410cf16397105e6020380a320a6023380786591b80a3a7f1ace3a00c3e0a21b665f1b6260303db5bfce223bc23d9712142ac3042190d1
@@ -1,10 +1,14 @@
1
1
  language: ruby
2
+ before_install:
3
+ - gem install bundler
2
4
  rvm:
3
- - "1.9.2"
4
- - "1.9.3"
5
5
  - "2.0.0"
6
6
  - "2.1.0"
7
7
  - "2.1.1"
8
- - jruby-19mode
9
- - jruby-head
8
+ - "2.1.4"
9
+ - "2.2.0"
10
+ - "2.3.1"
11
+ - "2.4.1"
12
+ - "2.4.2"
13
+ - jruby-9.0.5.0
10
14
 
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/games_dice.png)](http://badge.fury.io/rb/games_dice)
3
3
  [![Build Status](https://travis-ci.org/neilslater/games_dice.png?branch=master)](http://travis-ci.org/neilslater/games_dice)
4
4
  [![Coverage Status](https://coveralls.io/repos/neilslater/games_dice/badge.png?branch=master)](https://coveralls.io/r/neilslater/games_dice?branch=master)
5
+ [![Inline docs](http://inch-ci.org/github/neilslater/games_dice.png?branch=master)](http://inch-ci.org/github/neilslater/games_dice)
5
6
  [![Code Climate](https://codeclimate.com/github/neilslater/games_dice.png)](https://codeclimate.com/github/neilslater/games_dice)
6
7
  [![Dependency Status](https://gemnasium.com/neilslater/games_dice.png)](https://gemnasium.com/neilslater/games_dice)
7
8
 
@@ -29,12 +30,11 @@ gem as-is, and add them as features within your project code.
29
30
 
30
31
  ## Supported Ruby Versions
31
32
 
32
- GamesDice is tested routinely on
33
+ GamesDice is tested routinely on MRI Rubies 1.9.3, 2.0.0, 2.1.0, 2.1.1 and JRuby, and the
34
+ "build passing" badge is based on those tests.
33
35
 
34
- * MRI Ruby 1.8.7, 1.9.3 and 2.0.0
35
- * Rubinius 1.8 and 1.9
36
- * JRuby in 1.8 and 1.9 modes
37
- * Ruby Enterprise Edition
36
+ It *should* also work in versions from 1.8.7, in Ruby Enterprise and in Rubinius, but it
37
+ is not tested routinely on those Rubies.
38
38
 
39
39
  ## Installation
40
40
 
@@ -98,7 +98,7 @@ class GamesDice::Bunch
98
98
  # @return [Array<GamesDice::DieResult>, nil] Sequence of GamesDice::DieResult objects.
99
99
  def result_details
100
100
  return nil unless @raw_result_details
101
- @raw_result_details.map { |r| r.is_a?(Fixnum) ? GamesDice::DieResult.new(r) : r }
101
+ @raw_result_details.map { |r| r.is_a?(Integer) ? GamesDice::DieResult.new(r) : r }
102
102
  end
103
103
 
104
104
  # @!attribute [r] min
@@ -145,7 +145,7 @@ class GamesDice::DieResult
145
145
  end
146
146
 
147
147
  # @!visibility private
148
- # all coercions simply use #value (i.e. nil or a Fixnum)
148
+ # all coercions simply use #value (i.e. nil or a Integer)
149
149
  def coerce(thing)
150
150
  @value.coerce(thing)
151
151
  end
@@ -1,3 +1,3 @@
1
1
  module GamesDice
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.12"
3
3
  end
@@ -153,7 +153,7 @@ describe GamesDice::ComplexDie do
153
153
  die = GamesDice::ComplexDie.new(10, :rerolls => [GamesDice::RerollRule.new(10, :<=, :reroll_add)] )
154
154
  probs = die.probabilities.to_h
155
155
  probs[8].should be_within(1e-10).of 0.1
156
- probs[10].should be_false
156
+ probs[10].should be_nil
157
157
  probs[13].should be_within(1e-10).of 0.01
158
158
  probs[27].should be_within(1e-10).of 0.001
159
159
  probs.values.inject(:+).should be_within(1e-9).of 1.0
@@ -223,25 +223,25 @@ describe GamesDice::DieResult do
223
223
  it "should support comparison with >,<,>=,<= as if it were an integer, based on #value" do
224
224
  die_result = GamesDice::DieResult.new(7)
225
225
 
226
- (die_result > 3).should be_true
227
- (14 > die_result).should be_true
228
- (die_result >= 7).should be_true
229
- (9.5 >= die_result).should be_true
230
- (die_result < 3).should be_false
231
- (14 < die_result).should be_false
232
- (die_result <= 8).should be_true
233
- (14 <= die_result).should be_false
226
+ (die_result > 3).should == true
227
+ (14 > die_result).should == true
228
+ (die_result >= 7).should == true
229
+ (9.5 >= die_result).should == true
230
+ (die_result < 3).should == false
231
+ (14 < die_result).should == false
232
+ (die_result <= 8).should == true
233
+ (14 <= die_result).should == false
234
234
 
235
235
  other_die_result = GamesDice::DieResult.new(6)
236
236
  other_die_result.add_roll(6,:reroll_add)
237
- (die_result > other_die_result).should be_false
238
- (other_die_result > die_result).should be_true
239
- (die_result >= other_die_result).should be_false
240
- (other_die_result >= die_result).should be_true
241
- (die_result < other_die_result).should be_true
242
- (other_die_result < die_result).should be_false
243
- (die_result <= other_die_result).should be_true
244
- (other_die_result <= die_result).should be_false
237
+ (die_result > other_die_result).should == false
238
+ (other_die_result > die_result).should == true
239
+ (die_result >= other_die_result).should == false
240
+ (other_die_result >= die_result).should == true
241
+ (die_result < other_die_result).should == true
242
+ (other_die_result < die_result).should == false
243
+ (die_result <= other_die_result).should == true
244
+ (other_die_result <= die_result).should == false
245
245
 
246
246
  end
247
247
 
@@ -47,7 +47,7 @@ describe GamesDice::Die do
47
47
  it "should return the die's probability distribution as a GamesDice::Probabilities object" do
48
48
  die = GamesDice::Die.new(6)
49
49
  probs = die.probabilities
50
- probs.is_a?( GamesDice::Probabilities ).should be_true
50
+ probs.should be_a GamesDice::Probabilities
51
51
 
52
52
  probs.to_h.should be_valid_distribution
53
53
 
@@ -44,9 +44,9 @@ RSpec::Matchers.define :be_valid_distribution do
44
44
  @error = nil
45
45
  if ! given.is_a?(Hash)
46
46
  @error = "distribution should be a Hash, but it is a #{given.class}"
47
- elsif given.keys.any? { |k| ! k.is_a?(Fixnum) }
48
- bad_key = given.keys.first { |k| ! k.is_a?(Fixnum) }
49
- @error = "all keys should be Fixnums, but found '#{bad_key.inspect}' which is a #{bad_key.class}"
47
+ elsif given.keys.any? { |k| ! k.is_a?(Integer) }
48
+ bad_key = given.keys.first { |k| ! k.is_a?(Integer) }
49
+ @error = "all keys should be Integers, but found '#{bad_key.inspect}' which is a #{bad_key.class}"
50
50
  elsif given.values.any? { |v| ! v.is_a?(Float) }
51
51
  bad_value = given.values.find { |v| ! v.is_a?(Float) }
52
52
  @error = "all values should be Floats, but found '#{bad_value.inspect}' which is a #{bad_value.class}"
@@ -60,11 +60,11 @@ RSpec::Matchers.define :be_valid_distribution do
60
60
  ! @error
61
61
  end
62
62
 
63
- failure_message_for_should do |given|
63
+ failure_message do |given|
64
64
  @error ? @error : 'Distribution is valid and complete'
65
65
  end
66
66
 
67
- failure_message_for_should_not do |given|
67
+ failure_message_when_negated do |given|
68
68
  @error ? @error : 'Distribution is valid and complete'
69
69
  end
70
70
 
@@ -31,12 +31,12 @@ describe GamesDice::MapRule do
31
31
  rule.map_from(4).should == 3
32
32
  end
33
33
 
34
- it "should return false for no match" do
34
+ it "should return nil for no match" do
35
35
  rule = GamesDice::MapRule.new( 5, :>, -1 )
36
- rule.map_from(6).should be_false
36
+ rule.map_from(6).should be_nil
37
37
 
38
38
  rule = GamesDice::MapRule.new( (1..5), :member?, 3 )
39
- rule.map_from(6).should be_false
39
+ rule.map_from(6).should be_nil
40
40
  end
41
41
 
42
42
  end
@@ -163,7 +163,7 @@ describe GamesDice::Probabilities do
163
163
  it "should be either :c or :ruby" do
164
164
  lang = GamesDice::Probabilities.implemented_in
165
165
  lang.should be_a Symbol
166
- [:c, :ruby].member?( lang ).should be_true
166
+ [:c, :ruby].member?( lang ).should == true
167
167
  end
168
168
  end
169
169
  end # describe "class methods"
@@ -6,21 +6,21 @@ describe GamesDice do
6
6
  describe '#create' do
7
7
  it "converts a string such as '3d6+6' into a GamesDice::Dice object" do
8
8
  d = GamesDice.create '3d6+6'
9
- d.is_a?( GamesDice::Dice ).should be_true
9
+ d.should be_a GamesDice::Dice
10
10
  end
11
11
 
12
12
  it "takes a parameter 'dice_description', which is a string such as '3d6' or '2d4-1'" do
13
13
  d = GamesDice.create '3d6'
14
- d.is_a?( GamesDice::Dice ).should be_true
14
+ d.should be_a GamesDice::Dice
15
15
  d = GamesDice.create '2d4-1'
16
- d.is_a?( GamesDice::Dice ).should be_true
16
+ d.should be_a GamesDice::Dice
17
17
  end
18
18
 
19
19
  it "takes an optional parameter 'prng', which if provided it should be an object that has a method 'rand( integer )'" do
20
20
  prng = TestPRNG.new
21
21
 
22
22
  d = GamesDice.create '3d6', prng
23
- d.is_a?( GamesDice::Dice ).should be_true
23
+ d.should be_a GamesDice::Dice
24
24
 
25
25
  (0..5).each do |dresult|
26
26
  prng.stub( :rand ) { dresult }
@@ -103,7 +103,7 @@ describe GamesDice::Dice do
103
103
  describe "#probabilities" do
104
104
  it "calculates probability distribution for the dice" do
105
105
  pd = dice.probabilities
106
- pd.is_a?( GamesDice::Probabilities ).should be_true
106
+ pd.should be_a GamesDice::Probabilities
107
107
  pd.p_eql( 3).should be_within(1e-10).of 1.0/216
108
108
  pd.p_eql( 11 ).should be_within(1e-10).of 27.0/216
109
109
  end
@@ -25,18 +25,18 @@ describe GamesDice::RerollRule do
25
25
 
26
26
  it "should return true if a trigger condition is met" do
27
27
  rule = GamesDice::RerollRule.new( 5, :>, :reroll_subtract )
28
- rule.applies?(4).should be_true
28
+ rule.applies?(4).should == true
29
29
 
30
30
  rule = GamesDice::RerollRule.new( (1..5), :member?, :reroll_subtract )
31
- rule.applies?(4).should be_true
31
+ rule.applies?(4).should == true
32
32
  end
33
33
 
34
34
  it "should return false if a trigger condition is not met" do
35
35
  rule = GamesDice::RerollRule.new( 5, :>, :reroll_subtract )
36
- rule.applies?(7).should be_false
36
+ rule.applies?(7).should == false
37
37
 
38
38
  rule = GamesDice::RerollRule.new( (1..5), :member?, :reroll_subtract )
39
- rule.applies?(6).should be_false
39
+ rule.applies?(6).should == false
40
40
  end
41
41
 
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: games_dice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Slater
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.2.2
194
+ rubygems_version: 2.6.12
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Simulates and explains dice rolls from simple "1d6" to complex "roll 7 ten-sided