rdc_lotto 0.0.1 → 0.0.2

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: c2d3c55dc5809c9e25c9115a05d678707a0b8e8d
4
- data.tar.gz: ba402321496ad531f3eca63eb07269ad5ea4b6a4
3
+ metadata.gz: 467ef64c339f275ef9eacd30d99b5c1d885430e7
4
+ data.tar.gz: 308a20ad0873accd63799af4f866c03e64244ae9
5
5
  SHA512:
6
- metadata.gz: b7fab285cd7a78f19ee68d3dc25906a4f6c62bc1b96d7d73a82c83eb0e2d526bcf4cdeb86d6eebc7a48cbc5abe07b06baf0a77593a5957abbac275d2df8b2cdd
7
- data.tar.gz: d3b5faaadb21f5c56e2c033afb34f730eebf338fb1ca134fa906d86e2900407f5dc33a27b67b461bae0ea17824c357ce4ad59b4f644a6b82a1d18b9a17635fe0
6
+ metadata.gz: a064b756bd09c4cdc3d059a07ab70ff75678dd47ccf995afecc6fe3906a63d3734434af914daf1f0f2eca8999b4cc6ea8412b3733abf4a54452f78b7fd660286
7
+ data.tar.gz: 84c479b54717038c21331a983cfa369fdd82743d6175b78f4c5d4bdbe12e5d649152a6eb63e6d8790a3c9d33f5102327479dd2ba9b332ff3d342b755b78bf66c
@@ -0,0 +1,10 @@
1
+ module RdcLotto
2
+ class Configuration
3
+ attr_accessor :drawing_count
4
+
5
+ def initialize
6
+ @drawing_count = 10
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module RdcLotto
2
+ class Drawing
3
+ attr_accessor :config
4
+
5
+ def initialize(config = Configuration.new)
6
+ @config = config
7
+ end
8
+
9
+ def draw
10
+ @config.drawing_count.times.map { draw_number }
11
+ end
12
+
13
+ private
14
+
15
+ def draw_number
16
+ rand(0..59)
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module RdcLotto
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/rdc_lotto.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  require "rdc_lotto/version"
2
+ require "rdc_lotto/configuration"
3
+ require "rdc_lotto/drawing"
2
4
 
3
5
  module RdcLotto
4
- class Drawing
5
- def draw
6
- 5.times.map { draw_number }
7
- end
6
+ class << self
7
+ attr_writer :configuration
8
+ end
8
9
 
9
- private
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
10
13
 
11
- def draw_number
12
- rand(0..60)
13
- end
14
- end
14
+ def self.configure
15
+ yield(configuration)
16
+ end
15
17
  end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ module RdcLotto
4
+ describe Configuration do
5
+ describe "#drawing_count" do
6
+ it "default value is 6" do
7
+ RdcLotto::Configuration.new.drawing_count = 10
8
+ end
9
+ end
10
+
11
+ describe "#drawing_count=" do
12
+ it "can set value" do
13
+ config = RdcLotto::Configuration.new
14
+ config.drawing_count = 10
15
+ expect(config.drawing_count).to eq(10)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,8 +9,8 @@ module RdcLotto
9
9
  expect(draw).to be_a(Array)
10
10
  end
11
11
 
12
- it "returns an array with 5 elements" do
13
- expect(draw.size).to eq(5)
12
+ it "returns an array with 10 elements" do
13
+ expect(draw.size).to eq(10)
14
14
  end
15
15
 
16
16
  it "each element is integer" do
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe RdcLotto do
4
+ describe "#configure" do
5
+ before :each do
6
+ RdcLotto.configure do |config|
7
+ config.drawing_count = 10
8
+ end
9
+ end
10
+
11
+ it "returns an array with 10 elements" do
12
+ draw = RdcLotto::Drawing.new.draw
13
+ expect(draw).to be_a(Array)
14
+ expect(draw.size).to eq(10)
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdc_lotto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Del Castillo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,13 @@ files:
66
66
  - README.md
67
67
  - Rakefile
68
68
  - lib/rdc_lotto.rb
69
+ - lib/rdc_lotto/configuration.rb
70
+ - lib/rdc_lotto/drawing.rb
69
71
  - lib/rdc_lotto/version.rb
70
72
  - rdc_lotto.gemspec
73
+ - spec/rdc_lotto/configuration_spec.rb
71
74
  - spec/rdc_lotto/drawing_spec.rb
75
+ - spec/rdc_lotto_spec.rb
72
76
  - spec/spec_helper.rb
73
77
  homepage: https://rubygems.org/gems/rdc_lotto
74
78
  licenses:
@@ -95,5 +99,7 @@ signing_key:
95
99
  specification_version: 4
96
100
  summary: A lotto gem
97
101
  test_files:
102
+ - spec/rdc_lotto/configuration_spec.rb
98
103
  - spec/rdc_lotto/drawing_spec.rb
104
+ - spec/rdc_lotto_spec.rb
99
105
  - spec/spec_helper.rb