games_dice 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/README.md +23 -5
- data/ext/games_dice/extconf.rb +24 -2
- data/games_dice.gemspec +9 -5
- data/lib/games_dice/probabilities.rb +1 -0
- data/lib/games_dice/version.rb +1 -1
- metadata +4 -4
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -17,18 +17,21 @@ The main features of GamesDice are:
|
|
17
17
|
* Counting number of "successes" from a set of dice
|
18
18
|
* Keeping the best, or worst, results from a set of dice
|
19
19
|
* Can explain how a result was achieved in terms of the individual die rolls
|
20
|
-
* Can calculate probabilities and expected values
|
20
|
+
* Can calculate probabilities and expected values
|
21
21
|
|
22
22
|
There are no game mechanics implemented in GamesDice, such as the chance to hit in a fantasy combat
|
23
23
|
game. There is no support for player interaction within a roll, such as player choice on whether or
|
24
24
|
not to re-roll a specific die within a combined set. These things are of course possible if you use the
|
25
25
|
gem as-is, and add them as features within your project code.
|
26
26
|
|
27
|
-
##
|
27
|
+
## Supported Ruby Versions
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
GamesDice is tested routinely on
|
30
|
+
|
31
|
+
* MRI Ruby 1.8.7, 1.9.3 and 2.0.0
|
32
|
+
* Rubinius 1.8 and 1.9
|
33
|
+
* JRuby in 1.8 and 1.9 modes
|
34
|
+
* Ruby Enterprise Edition
|
32
35
|
|
33
36
|
## Installation
|
34
37
|
|
@@ -44,6 +47,21 @@ Or install it yourself as:
|
|
44
47
|
|
45
48
|
$ gem install games_dice
|
46
49
|
|
50
|
+
When installed, GamesDice will attempt to install Ruby native extensions in C, for speeding up probabilities
|
51
|
+
calculations. However, all the features are available in pure Ruby, and the gem should fall back to that
|
52
|
+
automatically on installation if your system does not support C native extensions. You can verify which
|
53
|
+
is being installed by installing the gem in verbose mode:
|
54
|
+
|
55
|
+
$ gem install games_dice --verbose
|
56
|
+
|
57
|
+
You can also verify which version you are using in Ruby by calling the class method:
|
58
|
+
|
59
|
+
GamesDice::Probabilities.implemented_in
|
60
|
+
|
61
|
+
which will return either *:ruby* or *:c*. Other than this method, and a speed difference between
|
62
|
+
implementations, there should be no other difference. If you find one, then it will be considered
|
63
|
+
as a bug.
|
64
|
+
|
47
65
|
## Usage
|
48
66
|
|
49
67
|
require 'games_dice'
|
data/ext/games_dice/extconf.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
1
|
# ext/games_dice/extconf.rb
|
2
|
-
|
3
|
-
|
2
|
+
can_compile_extensions = false
|
3
|
+
want_extensions = true
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'mkmf'
|
7
|
+
can_compile_extensions = true
|
8
|
+
rescue Exception
|
9
|
+
# This will appear only in verbose mode.
|
10
|
+
$stderr.puts "Could not require 'mkmf'. Not fatal: The extensions are optional."
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
if can_compile_extensions && want_extensions
|
15
|
+
create_makefile( 'games_dice/games_dice' )
|
16
|
+
|
17
|
+
else
|
18
|
+
# Create a dummy Makefile, to satisfy Gem::Installer#install
|
19
|
+
mfile = open("Makefile", "wb")
|
20
|
+
mfile.puts '.PHONY: install'
|
21
|
+
mfile.puts 'install:'
|
22
|
+
mfile.puts "\t" + '@echo "Extensions not installed, falling back to pure Ruby version."'
|
23
|
+
mfile.close
|
24
|
+
|
25
|
+
end
|
data/games_dice.gemspec
CHANGED
@@ -19,11 +19,15 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency "yard", ">= 0.8.6"
|
20
20
|
gem.add_development_dependency "rake-compiler"
|
21
21
|
|
22
|
-
# Red Carpet
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
# Red Carpet renders README.md, and is optional even when developing the gem.
|
23
|
+
# However, it has a C extension, and v3.0.0 is does not compile for 1.8.7. This only affects the gem build process, so
|
24
|
+
# is only really used in environments like Travis, and is safe to wrap like this in the gemspec.
|
25
|
+
if RUBY_DESCRIPTION !~ /jruby/
|
26
|
+
if RUBY_VERSION < "1.9.0"
|
27
|
+
gem.add_development_dependency "redcarpet", ">=2.3.0", "<3.0.0"
|
28
|
+
else
|
29
|
+
gem.add_development_dependency "redcarpet", ">=2.3.0"
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
gem.add_dependency "parslet", ">= 1.5.0"
|
data/lib/games_dice/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: games_dice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -165,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
segments:
|
167
167
|
- 0
|
168
|
-
hash:
|
168
|
+
hash: 2590599779471533886
|
169
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
170
|
none: false
|
171
171
|
requirements:
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
segments:
|
176
176
|
- 0
|
177
|
-
hash:
|
177
|
+
hash: 2590599779471533886
|
178
178
|
requirements: []
|
179
179
|
rubyforge_project:
|
180
180
|
rubygems_version: 1.8.24
|