rdice 0.0.3 → 0.0.4

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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - 1.9.3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Dice
1
+ # RDice [![Build Status](https://secure.travis-ci.org/detierno/dice.png?branch=master)](http://travis-ci.org/detierno/dice)
2
2
 
3
- This gem was created with studies purpose. It simple create a dice and let you roll one or more dices with different faces.
3
+ This gem was created with studies purpose. It simple create a dice and let you roll one or more dices with different sides.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,13 +10,13 @@ Add to your Gemfile and run the `bundle` command to install it.
10
10
  gem "rdice"
11
11
  ```
12
12
 
13
- **Requires Ruby 1.9.3 or later.**
13
+ **Tested with Ruby 1.9.3**
14
14
 
15
15
 
16
16
  ## Usage
17
17
 
18
18
 
19
- Them most basic use you can create a new instance of Dice and perform some rolls
19
+ Them most basic use you can create a new instance of Dice and perform some rolls. The returned value is a integer containing the sum of all dices rolled
20
20
 
21
21
  ```ruby
22
22
  dice = Dice.new
@@ -34,12 +34,17 @@ If you call roll with only the number of times you want to roll it will roll the
34
34
 
35
35
  ## Changing the defaults
36
36
 
37
- When you call *.roll* method this roll a dice with the defaults faces and dices number (6 and 1). If you want to change the defaults you can in the class creation
37
+ When you call *.roll* method this roll a dice with the defaults sides and dices number (6 and 1). If you want to change the defaults you can in the class creation
38
38
 
39
39
  ```ruby
40
40
  dice = Dice.new(20,2)
41
41
 
42
- dice.roll # will roll two d20 by default
42
+ dice.roll # rolls two d20 by default
43
+ dice.roll_two # rolls two d20
44
+ dice.roll_four # rolls four d20
45
+ dice.roll_d20 # rolls two d20
46
+ dice.roll_three_d8 # rolls three d8
47
+ dice.roll_10_d3 # rolls 10 d3
43
48
  ```
44
49
 
45
50
  ## License
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
7
+
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.version = Dice::VERSION
8
8
  s.authors = ["Denis"]
9
9
  s.email = ["de.tierno@gmail.com"]
10
- s.homepage = ""
11
- s.summary = %q{Roll dices with different faces}
12
- s.description = %q{This gem allow you to set dices and roll it lots of times}
10
+ s.homepage = "https://github.com/detierno/dice"
11
+ s.summary = %q{Roll dices with different sides}
12
+ s.description = %q{This gem allow you to set dices and roll it. You can set custom defaults and change behavior to fit you purpose }
13
13
 
14
14
  s.rubyforge_project = "rdice"
15
15
 
@@ -18,8 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
21
  s.add_development_dependency "rspec"
23
22
  s.add_development_dependency "rake"
24
- # s.add_runtime_dependency "rest-client"
25
23
  end
@@ -1,11 +1,11 @@
1
1
  class Dice
2
2
  class Config
3
- def self.faces
4
- @faces
3
+ def self.sides
4
+ @sides
5
5
  end
6
6
 
7
- def self.faces=(faces)
8
- @faces = faces
7
+ def self.sides=(sides)
8
+ @sides = sides
9
9
  end
10
10
 
11
11
  def self.dices
@@ -1,11 +1,11 @@
1
1
  class Dice
2
- def initialize(faces=6, dices=1)
3
- Dice::Config.faces = faces
2
+ def initialize(sides=6, dices=1)
3
+ Dice::Config.sides = sides
4
4
  Dice::Config.dices = dices
5
5
  end
6
6
 
7
- def roll(faces=preferred_faces, dices=preferred_dices)
8
- get_result(faces, dices)
7
+ def roll(sides=preferred_sides, dices=preferred_dices)
8
+ get_result(sides, dices)
9
9
  end
10
10
 
11
11
  def method_missing(method, *args, &block)
@@ -14,7 +14,7 @@ class Dice
14
14
  elsif method =~ /roll_(\w+)_d(\w+)/
15
15
  roll($2.to_i, translate_value($1))
16
16
  elsif method =~ /roll_(\w+)/
17
- roll(preferred_faces,translate_value($1))
17
+ roll(preferred_sides,translate_value($1))
18
18
  else
19
19
  super
20
20
  end
@@ -22,16 +22,16 @@ class Dice
22
22
 
23
23
  private
24
24
 
25
- def preferred_faces
26
- Dice::Config.faces
25
+ def preferred_sides
26
+ Dice::Config.sides
27
27
  end
28
28
 
29
29
  def preferred_dices
30
30
  Dice::Config.dices
31
31
  end
32
32
 
33
- def get_result(faces, dices)
34
- (1..dices).inject(0) {|a, b| a + rand(faces) + 1 }
33
+ def get_result(sides, dices)
34
+ (1..dices).inject(0) {|a, b| a + rand(sides) + 1 }
35
35
  end
36
36
 
37
37
  def translate_value(number)
@@ -1,3 +1,3 @@
1
1
  class Dice
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,15 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Dice::Config do
4
- it "have dices as 1 and faces as 6 as default" do
4
+ it "have dices as 1 and sides as 6 as default" do
5
5
  dice = Dice.new
6
- Dice::Config.faces.should == 6
6
+ Dice::Config.sides.should == 6
7
7
  Dice::Config.dices.should == 1
8
8
  end
9
9
 
10
- it "set dices and faces as requested" do
10
+ it "set dices and sides as requested" do
11
11
  dice = Dice.new(12,3)
12
- Dice::Config.faces.should == 12
12
+ Dice::Config.sides.should == 12
13
13
  Dice::Config.dices.should == 3
14
14
  end
15
15
  end
@@ -64,7 +64,7 @@ describe Dice do
64
64
 
65
65
  end
66
66
 
67
- describe "new with 12 faces and 3 dices" do
67
+ describe "new with 12 sides and 3 dices" do
68
68
 
69
69
  describe ".roll" do
70
70
  let(:dice) { Dice.new(12,3) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70293146228280 !ruby/object:Gem::Requirement
16
+ requirement: &70335605167600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70293146228280
24
+ version_requirements: *70335605167600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70293146227360 !ruby/object:Gem::Requirement
27
+ requirement: &70335605166720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,8 +32,9 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70293146227360
36
- description: This gem allow you to set dices and roll it lots of times
35
+ version_requirements: *70335605166720
36
+ description: ! 'This gem allow you to set dices and roll it. You can set custom defaults
37
+ and change behavior to fit you purpose '
37
38
  email:
38
39
  - de.tierno@gmail.com
39
40
  executables: []
@@ -41,6 +42,8 @@ extensions: []
41
42
  extra_rdoc_files: []
42
43
  files:
43
44
  - .gitignore
45
+ - .rspec
46
+ - .travis.yml
44
47
  - Gemfile
45
48
  - README.md
46
49
  - Rakefile
@@ -52,7 +55,7 @@ files:
52
55
  - spec/config_spec.rb
53
56
  - spec/dice_spec.rb
54
57
  - spec/spec_helper.rb
55
- homepage: ''
58
+ homepage: https://github.com/detierno/dice
56
59
  licenses: []
57
60
  post_install_message:
58
61
  rdoc_options: []
@@ -66,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
69
  version: '0'
67
70
  segments:
68
71
  - 0
69
- hash: -645987200912169816
72
+ hash: 97332267924461556
70
73
  required_rubygems_version: !ruby/object:Gem::Requirement
71
74
  none: false
72
75
  requirements:
@@ -75,13 +78,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
78
  version: '0'
76
79
  segments:
77
80
  - 0
78
- hash: -645987200912169816
81
+ hash: 97332267924461556
79
82
  requirements: []
80
83
  rubyforge_project: rdice
81
84
  rubygems_version: 1.8.10
82
85
  signing_key:
83
86
  specification_version: 3
84
- summary: Roll dices with different faces
87
+ summary: Roll dices with different sides
85
88
  test_files:
86
89
  - spec/config_spec.rb
87
90
  - spec/dice_spec.rb