lotto 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18232f89a50c71dda45c4d99d25687487be3eb9a877340532f582b83bd4af887
4
- data.tar.gz: 7e9a111e126d811f48dcbff3acd86240acfab06e2da6ca6a90bf95491a5d7b4e
3
+ metadata.gz: 6d796e6c0590d5377579f4d128564ca3429fd3bb339373529567977f78a9f1ed
4
+ data.tar.gz: fde17fa4dd669399e217a439c316d5b028e99a859391fbbb706ec8f2f644052e
5
5
  SHA512:
6
- metadata.gz: 5d0af0a40c14314e883a1644d57fcec225f8088b48e23c5e652f71a4459fded2b24c9e0b55a17064eb81358043c705f169001dd4afe097b6cbd1b5e9b797f302
7
- data.tar.gz: 902fa057244102ab00fc5ec17a45799595252fa437e838726908b4f7ea42ea735f25776a5017eb0797bb41b40036e94e3f8bf47f93ae961caee2f9290e6f854b
6
+ metadata.gz: 426e38ab95d59e31057342d77f45bcc43d563537aa659ccb663db77e780014965f623238a359949d582277ff270816a1bacb82abb54c2457a49b618df76e6c19
7
+ data.tar.gz: 40ad39b58ab74f7a078358c3e50ba336d65dfa96586109df404948845bee46e468f7b88be90024442aa9435c2814f307cafd62fac292539fb88f27f3f913c8fd
@@ -0,0 +1,54 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.5.1-node-browsers
11
+
12
+ # Specify service dependencies here if necessary
13
+ # CircleCI maintains a library of pre-built images
14
+ # documented at https://circleci.com/docs/2.0/circleci-images/
15
+ # - image: circleci/postgres:9.4
16
+
17
+ working_directory: ~/repo
18
+
19
+ steps:
20
+ - checkout
21
+
22
+ # Download and cache dependencies
23
+ - restore_cache:
24
+ keys:
25
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
26
+ # fallback to using the latest cache if no exact match is found
27
+ - v1-dependencies-
28
+
29
+ - run:
30
+ name: install dependencies
31
+ command: |
32
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
33
+
34
+ - save_cache:
35
+ paths:
36
+ - ./vendor/bundle
37
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
38
+
39
+ # run tests!
40
+ - run:
41
+ name: run tests
42
+ command: |
43
+ mkdir /tmp/test-results
44
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
45
+
46
+ bundle exec rspec --format progress \
47
+ $TEST_FILES
48
+
49
+ # collect reports
50
+ - store_test_results:
51
+ path: /tmp/test-results
52
+ - store_artifacts:
53
+ path: /tmp/test-results
54
+ destination: test-results
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: $COVERALLS_TOKEN
data/Gemfile.lock CHANGED
@@ -1,12 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lotto (0.1.0)
4
+ lotto (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ coveralls (0.8.21)
10
+ json (>= 1.8, < 3)
11
+ simplecov (~> 0.14.1)
12
+ term-ansicolor (~> 1.3)
13
+ thor (~> 0.19.4)
14
+ tins (~> 1.6)
9
15
  diff-lcs (1.3)
16
+ docile (1.1.5)
17
+ json (2.1.0)
10
18
  rake (10.5.0)
11
19
  rspec (3.7.0)
12
20
  rspec-core (~> 3.7.0)
@@ -21,12 +29,22 @@ GEM
21
29
  diff-lcs (>= 1.2.0, < 2.0)
22
30
  rspec-support (~> 3.7.0)
23
31
  rspec-support (3.7.1)
32
+ simplecov (0.14.1)
33
+ docile (~> 1.1.0)
34
+ json (>= 1.8, < 3)
35
+ simplecov-html (~> 0.10.0)
36
+ simplecov-html (0.10.2)
37
+ term-ansicolor (1.6.0)
38
+ tins (~> 1.0)
39
+ thor (0.19.4)
40
+ tins (1.16.3)
24
41
 
25
42
  PLATFORMS
26
43
  ruby
27
44
 
28
45
  DEPENDENCIES
29
46
  bundler (~> 1.16)
47
+ coveralls
30
48
  lotto!
31
49
  rake (~> 10.0)
32
50
  rspec (~> 3.0)
data/README.md CHANGED
@@ -22,7 +22,14 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ```ruby
26
+ lotto = Lotto::Draw.new
27
+ lotto.play({ pick: 6, of: 49 }) # will return an array
28
+ lotto.play({ pick: 6, of: 49 }).sort.join(' - ')
29
+
30
+ # Multiple draws
31
+ lotto.play({ pick: 6, of: 49, for: 5 })
32
+ ````
26
33
 
27
34
  ## Development
28
35
 
data/lib/lotto/draw.rb ADDED
@@ -0,0 +1,25 @@
1
+ module Lotto
2
+ class Draw
3
+ def play(options)
4
+ @options = options
5
+ @options[:for].nil? ? draw : draw_multiple
6
+ end
7
+
8
+ def pick(drawns=[])
9
+ return rand(1..@options[:of]) if drawns.length == 0
10
+ (1..@options[:of]).reject{ |n| drawns.include? n }.sample
11
+ end
12
+
13
+ def draw
14
+ drawns = []
15
+ @options[:pick].times{ drawns << pick(drawns) }
16
+ drawns
17
+ end
18
+
19
+ def draw_multiple
20
+ coupons = []
21
+ @options[:for].times{ coupons << draw }
22
+ coupons
23
+ end
24
+ end
25
+ end
data/lib/lotto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lotto
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/lotto.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "lotto/version"
2
+ require "lotto/draw"
2
3
 
3
4
  module Lotto
4
5
  # Your code goes here...
data/lotto.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.16"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "coveralls"
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lotto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onur Kucukkece
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description:
56
70
  email:
57
71
  - onurkucukkece@gmail.com
@@ -59,6 +73,8 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".circleci/config.yml"
77
+ - ".coveralls.yml"
62
78
  - ".gitignore"
63
79
  - ".rspec"
64
80
  - ".travis.yml"
@@ -71,6 +87,7 @@ files:
71
87
  - bin/console
72
88
  - bin/setup
73
89
  - lib/lotto.rb
90
+ - lib/lotto/draw.rb
74
91
  - lib/lotto/version.rb
75
92
  - lotto.gemspec
76
93
  homepage: https://github.com/onurkucukkece/lotto