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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc64ed19340ddcccf7815fc2aaaf074c63b40546bd6eae9187ec4732a3df164
4
- data.tar.gz: 7fa4239c14f203900feb652629ebc496e17c334dc8c191445fe8273b09664b68
3
+ metadata.gz: ac8e01e241857d917c0a09be0b01c92a25ab9d2836db5c098601a4ec73520643
4
+ data.tar.gz: c0490dfd1aba3178ef67bcf5332b776ce09e673f7981f1b6fd3d7b9416e15946
5
5
  SHA512:
6
- metadata.gz: 524879b450da306baa8830f51c715ddd7182b80c3590208a2576365a116138f24a03245e84c400fef6ba0aa087c89ee23e9db705056ec751d6959d395229b370
7
- data.tar.gz: f51693751b6c3197e523a030352a9a1ebf231ed7e0b96316fb712cd4f147ccf99ca2973cd83a9f6612d02efc2ea99948d57fa1e3441acb81a185bf894b9efdb9
6
+ metadata.gz: affea015f2fd18ef205f908c33f5a5c7e22999e9f0bfd1a2ea682c707b4acd85b60251efe0b3269fa88f3b394c1b5fa4f92e40e7148aa9348db856e6fa90e15b
7
+ data.tar.gz: 8a388d28e5d2d9ba8bd260f282ea8bfc9380767d409badd669416560889ca2f4fd16b314e060ecddff8d6361be6817c22559b7011bf6de5d0a3aa7428890a99f
data/.travis.yml CHANGED
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.1
5
+ - 2.4.3
6
+ - 2.3.6
5
7
  before_install: gem install bundler -v 1.16.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lotto (0.3.0)
4
+ lotto (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Lotto
2
- [![Coverage Status](https://coveralls.io/repos/github/onurkucukkece/lotto/badge.svg?branch=feature%2Fimproved_specs)](https://coveralls.io/github/onurkucukkece/lotto?branch=feature%2Fimproved_specs) [![CircleCI](https://circleci.com/gh/onurkucukkece/lotto/tree/master.svg?style=svg)](https://circleci.com/gh/onurkucukkece/lotto/tree/master)
2
+ [![Gem Version](https://badge.fury.io/rb/lotto.svg)](https://badge.fury.io/rb/lotto) [![Coverage Status](https://coveralls.io/repos/github/onurkucukkece/lotto/badge.svg?branch=master)](https://coveralls.io/github/onurkucukkece/lotto?branch=master) [![Build Status](https://travis-ci.org/onurkucukkece/lotto.svg?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.3.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
@@ -1,3 +1,3 @@
1
1
  module Lotto
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04-29 00:00:00.000000000 Z
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