lotto 0.3.0 → 0.4.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 +4 -4
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/lotto/draw.rb +9 -5
- data/lib/lotto/version.rb +1 -1
- metadata +2 -3
- data/.circleci/config.yml +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8e01e241857d917c0a09be0b01c92a25ab9d2836db5c098601a4ec73520643
|
4
|
+
data.tar.gz: c0490dfd1aba3178ef67bcf5332b776ce09e673f7981f1b6fd3d7b9416e15946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: affea015f2fd18ef205f908c33f5a5c7e22999e9f0bfd1a2ea682c707b4acd85b60251efe0b3269fa88f3b394c1b5fa4f92e40e7148aa9348db856e6fa90e15b
|
7
|
+
data.tar.gz: 8a388d28e5d2d9ba8bd260f282ea8bfc9380767d409badd669416560889ca2f4fd16b314e060ecddff8d6361be6817c22559b7011bf6de5d0a3aa7428890a99f
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Lotto
|
2
|
-
[](https://badge.fury.io/rb/lotto) [](https://coveralls.io/github/onurkucukkece/lotto?branch=master) [](https://travis-ci.org/onurkucukkece/lotto)
|
3
3
|
|
4
4
|
A customizable lottery gem
|
5
5
|
|
@@ -8,7 +8,7 @@ A customizable lottery gem
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'lotto', '~> 0.
|
11
|
+
gem 'lotto', '~> 0.4.0'
|
12
12
|
```
|
13
13
|
|
14
14
|
And then execute:
|
@@ -28,6 +28,9 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
# Multiple draws
|
30
30
|
lotto.play({ pick: 6, of: 49, for: 5 })
|
31
|
+
|
32
|
+
# Exclude numbers
|
33
|
+
lotto.play({ pick: 6, of: 49, exclude: [6, 23] })
|
31
34
|
````
|
32
35
|
|
33
36
|
## Development
|
data/lib/lotto/draw.rb
CHANGED
@@ -5,11 +5,6 @@ module Lotto
|
|
5
5
|
@options[:for].nil? ? draw : draw_multiple
|
6
6
|
end
|
7
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
8
|
def draw
|
14
9
|
drawns = []
|
15
10
|
@options[:pick].times{ drawns << pick(drawns) }
|
@@ -21,5 +16,14 @@ module Lotto
|
|
21
16
|
@options[:for].times{ coupons << draw }
|
22
17
|
coupons
|
23
18
|
end
|
19
|
+
|
20
|
+
def pick(drawns = [])
|
21
|
+
basket.reject { |n| drawns.include? n }.sample
|
22
|
+
end
|
23
|
+
|
24
|
+
def basket
|
25
|
+
return (1..@options[:of]).reject{ |n| @options[:exclude].include? n } unless @options[:exclude].nil?
|
26
|
+
(1..@options[:of])
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/lotto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onur Kucukkece
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,7 +73,6 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".circleci/config.yml"
|
77
76
|
- ".gitignore"
|
78
77
|
- ".rspec"
|
79
78
|
- ".travis.yml"
|
data/.circleci/config.yml
DELETED
@@ -1,54 +0,0 @@
|
|
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
|
-
echo "repo_token: $COVERALLS_TOKEN" > .coveralls.yml
|
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
|