rudil 0.0.1 → 1.0.0

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.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.0.0 2009-11-12
2
+
3
+ * 1 enhancement:
4
+ * renamed public method roll to throw_once to avoid
5
+ confusion beetween the roll and throw methods
6
+
1
7
  === 0.0.1 2009-10-11
2
8
 
3
9
  * 1 major enhancement:
data/Manifest.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  History.txt
2
2
  Manifest.txt
3
- README.rdoc
3
+ README.markdown
4
4
  Rakefile
5
5
  lib/rudil.rb
6
6
  lib/rudil/die.rb
data/README.markdown ADDED
@@ -0,0 +1,117 @@
1
+ rudil
2
+ =====
3
+
4
+ [rudil's homepage on github](http://github.com/sMAshdot/rudil)
5
+
6
+ DESCRIPTION
7
+ -----------
8
+
9
+ rudil is a dice library for the Ruby programming language.
10
+
11
+ FEATURES
12
+ --------
13
+
14
+ Roll dice with any number of sides.
15
+ Methods provided for single and multiple rolls.
16
+ Retrieve useful information about the rolls easily.
17
+
18
+ INSTALL
19
+ -------
20
+
21
+ Assuming you installed [Gemcutter](http://gemcutter.org), all you need to do is:
22
+
23
+ gem install rudil
24
+
25
+ SYNOPSIS
26
+ --------
27
+
28
+ ### Creating a die
29
+
30
+ require 'rudil'
31
+ die = Rudil::Die.new
32
+
33
+ or
34
+
35
+ require 'rudil'
36
+ include Rudil
37
+ die = Die.new
38
+
39
+ The die will have 6 sides per default. If you want another number of sides,
40
+ pass it as a parameter to the constructor:
41
+
42
+ die = Die.new(20)
43
+
44
+ ### Rolling the die
45
+
46
+ If you only need the result of a single throw, use the throw_once method:
47
+
48
+ die.throw_once
49
+ => 3
50
+
51
+ The throw method will return an array containing any number of throws:
52
+
53
+ die.throw(5)
54
+ => [6, 5, 3, 1, 3]
55
+
56
+ The die will be thrown once per default.
57
+
58
+ die.throw
59
+ => [4]
60
+
61
+ ### Analysing the results
62
+
63
+ A *Throw* is a subclass of array with a few convenience methods added.
64
+ To use it, collect the rolls in an instance of it:
65
+
66
+ throws = Throw.new( Die.new(20).throw(5) )
67
+ => [3, 6, 16, 13, 18]
68
+
69
+ You can get information about
70
+
71
+ * the lowest and the highest roll
72
+ * the mean (floating point)
73
+ * the number of rolls above a certain value (or equal and above)
74
+ * the number of rolls below a certain value (or equal and below)
75
+
76
+ like this:
77
+
78
+ throws.lowest
79
+ => 3
80
+ throws.highest
81
+ => 18
82
+ throws.mean
83
+ => 11.2
84
+ throws.above(13)
85
+ => 2
86
+ throws.eq_or_above(13)
87
+ => 3
88
+ throws.below 3
89
+ => 0
90
+ throws.eq_or_below(3)
91
+ => 1
92
+
93
+ LICENSE
94
+ -------
95
+
96
+ (The MIT License)
97
+
98
+ Copyright (c) 2009 Marc-Antonio Bisotti
99
+
100
+ Permission is hereby granted, free of charge, to any person obtaining
101
+ a copy of this software and associated documentation files (the
102
+ 'Software'), to deal in the Software without restriction, including
103
+ without limitation the rights to use, copy, modify, merge, publish,
104
+ distribute, sublicense, and/or sell copies of the Software, and to
105
+ permit persons to whom the Software is furnished to do so, subject to
106
+ the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be
109
+ included in all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
112
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
114
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
115
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
116
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
117
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -5,22 +5,16 @@ require 'fileutils'
5
5
  require './lib/rudil'
6
6
 
7
7
  Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
8
 
11
9
  # Generate all the Rake tasks
12
10
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
11
  $hoe = Hoe.spec 'rudil' do
14
12
  self.developer 'Marc-Antonio Bisotti', 'mail@marc-antonio.de'
15
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
- self.rubyforge_name = self.name # TODO this is default value
17
- # self.extra_deps = [['activesupport','>= 2.0.2']]
18
-
13
+ self.url = "http://github.com/sMAshdot/rudil"
14
+ self.summary = 'rudil is a dice library for the Ruby programming language.'
15
+ self.description = "Throw dice with any number of sides any number of times. Helps you to interpret the results."
16
+ self.readme_file = 'README.markdown'
19
17
  end
20
18
 
21
19
  require 'newgem/tasks'
22
20
  Dir['tasks/**/*.rake'].each { |t| load t }
23
-
24
- # TODO - want other tests/tasks run by default? Add them to the list
25
- # remove_task :default
26
- # task :default => [:spec, :features]
data/lib/rudil/die.rb CHANGED
@@ -19,10 +19,10 @@ module Rudil
19
19
  if times <= 0
20
20
  raise ArgumentError
21
21
  end
22
- Array.new(times).fill { roll }
22
+ Array.new(times).fill { throw_once }
23
23
  end
24
24
 
25
- def roll
25
+ def throw_once
26
26
  # the part where randomness happens has it's own method
27
27
  # to simplify unit-testing by permitting it to be stubbed.
28
28
  rand(@sides)+1
data/lib/rudil.rb CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(libdir) unless
4
4
  $LOAD_PATH.include?(libdir) || $LOAD_PATH.include?(File.expand_path(libdir))
5
5
 
6
6
  module Rudil
7
- VERSION = '0.0.1'
7
+ VERSION = '1.0.0'
8
8
  end
9
9
 
10
10
  require 'rudil/die'
data/spec/die_spec.rb CHANGED
@@ -19,24 +19,24 @@ describe Die do
19
19
 
20
20
  it "should roll an integer" do
21
21
  die = Die.new
22
- die.roll.class.should == Fixnum
22
+ die.throw_once.class.should == Fixnum
23
23
  end
24
24
 
25
25
  it "should not roll a number smaller than one" do
26
26
  die = Die.new
27
- collection = Array.new(NB_OF_ROLLS).fill { die.roll }
27
+ collection = Array.new(NB_OF_ROLLS).fill { die.throw_once }
28
28
  collection.sort[0].should == 1
29
29
  end
30
30
 
31
31
  it "should not roll a number bigger than 6 per default" do
32
32
  die = Die.new
33
- collection = Array.new(NB_OF_ROLLS).fill { die.roll }
33
+ collection = Array.new(NB_OF_ROLLS).fill { die.throw_once }
34
34
  collection.sort[NB_OF_ROLLS - 1].should == 6
35
35
  end
36
36
 
37
37
  it "should not roll a number bigger than the number of sides" do
38
38
  die = Die.new(20)
39
- collection = Array.new(NB_OF_ROLLS).fill { die.roll }
39
+ collection = Array.new(NB_OF_ROLLS).fill { die.throw_once }
40
40
  collection.sort[NB_OF_ROLLS - 1].should == 20
41
41
  end
42
42
 
@@ -58,14 +58,14 @@ describe Die do
58
58
 
59
59
  it "should return the result after it has been thrown once" do
60
60
  die = Die.new()
61
- die.stub!(:roll).and_return(6)
61
+ die.stub!(:throw_once).and_return(6)
62
62
  throw = die.throw(1)
63
63
  throw[0].should == 6
64
64
  end
65
65
 
66
66
  it "should return the result after it has been thrown any number of times" do
67
67
  die = Die.new()
68
- die.stub!(:roll).and_return(1,2,3,4,5,6)
68
+ die.stub!(:throw_once).and_return(1,2,3,4,5,6)
69
69
  throw = die.throw(6)
70
70
  throw[0].should == 1
71
71
  throw[5].should == 6
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-Antonio Bisotti
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-11 00:00:00 +02:00
12
+ date: 2009-11-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.3.3
24
24
  version:
25
- description: rudil is a dice library for ruby.
25
+ description: Throw dice with any number of sides any number of times. Helps you to interpret the results.
26
26
  email:
27
27
  - mail@marc-antonio.de
28
28
  executables: []
@@ -35,7 +35,7 @@ extra_rdoc_files:
35
35
  files:
36
36
  - History.txt
37
37
  - Manifest.txt
38
- - README.rdoc
38
+ - README.markdown
39
39
  - Rakefile
40
40
  - lib/rudil.rb
41
41
  - lib/rudil/die.rb
@@ -52,10 +52,10 @@ has_rdoc: true
52
52
  homepage: http://github.com/sMAshdot/rudil
53
53
  licenses: []
54
54
 
55
- post_install_message: PostInstall.txt
55
+ post_install_message:
56
56
  rdoc_options:
57
57
  - --main
58
- - README.rdoc
58
+ - README.markdown
59
59
  require_paths:
60
60
  - lib
61
61
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -76,6 +76,6 @@ rubyforge_project: rudil
76
76
  rubygems_version: 1.3.5
77
77
  signing_key:
78
78
  specification_version: 3
79
- summary: rudil is a dice library for ruby.
79
+ summary: rudil is a dice library for the Ruby programming language.
80
80
  test_files: []
81
81
 
data/README.rdoc DELETED
@@ -1,80 +0,0 @@
1
- = rudil
2
-
3
- * http://github.com/sMAshdot/rudil
4
-
5
- == DESCRIPTION:
6
-
7
- rudil is a dice library for ruby.
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- Roll dice with any number of sides.
12
- Methods for single and multiple rolls.
13
- Retrieve useful about the rolls easily.
14
-
15
- == SYNOPSIS:
16
-
17
- === simple rolling
18
-
19
- require 'rudil'
20
- die = Rudil::Die.new
21
- or
22
- require 'rudil'
23
- include Rudil
24
- die = Die.new
25
- creates a 6-sided die per default
26
- but you could also use Die.new(n) to
27
- obtain a die with more sides.
28
-
29
- die.roll
30
- => 3
31
- returns the result of a single roll
32
-
33
- die.throw(5)
34
- => [6, 5, 3, 1, 3]
35
- returns results of any number of rolls as array
36
-
37
- === analysing the results
38
-
39
- start with a die
40
- die = Die.new(20)
41
-
42
- collect the rolls in a throw
43
- throw = Throw.new( die.throw(5) )
44
-
45
- Throw is a subclass of array with a few convenience methods added.
46
- You can get information about
47
- - the lowest roll
48
- - the highest roll
49
- - the mean
50
- - the number of rolls above a certain value (or equal and above)
51
- - the number of rolls below a certain value (or equal and below) FIX (code sample of usage)
52
-
53
- == INSTALL:
54
-
55
- soon
56
-
57
- == LICENSE:
58
-
59
- (The MIT License)
60
-
61
- Copyright (c) 2009 FIXME full name
62
-
63
- Permission is hereby granted, free of charge, to any person obtaining
64
- a copy of this software and associated documentation files (the
65
- 'Software'), to deal in the Software without restriction, including
66
- without limitation the rights to use, copy, modify, merge, publish,
67
- distribute, sublicense, and/or sell copies of the Software, and to
68
- permit persons to whom the Software is furnished to do so, subject to
69
- the following conditions:
70
-
71
- The above copyright notice and this permission notice shall be
72
- included in all copies or substantial portions of the Software.
73
-
74
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
75
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
76
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
77
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
78
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
79
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
80
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.