melatico 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +9 -0
- data/lib/melatico/version.rb +3 -0
- data/lib/melatico.rb +42 -0
- data/melatico.gemspec +25 -0
- data/spec/melatico/draw_spec.rb +63 -0
- data/spec/spec_helper.rb +8 -0
- metadata +113 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: bc9685541d2bd6319822d8dc648aec44b135b2a8
         | 
| 4 | 
            +
              data.tar.gz: ad205d16a7bd2ad071f7043aa788d625b005deb2
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: aacb4f412a3f41eec11f1f4ba39fa7f95faa08b2ec0de7bd3fcaf349dc5947f2971ef2ae4477e21853454eb0046dbeb7b927669eee21bc8e924fe2e7e52cfd84
         | 
| 7 | 
            +
              data.tar.gz: a69da5b9c0499dc06ba4b38361cdeddac827598954aaf4a4a88fe2ddd42387a59e2d5c7eda4cec0663f39c32c7254ce0ae568f6c9c91d303cae04e1dfc2319c7
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            *.gem
         | 
| 2 | 
            +
            *.rbc
         | 
| 3 | 
            +
            .bundle
         | 
| 4 | 
            +
            .config
         | 
| 5 | 
            +
            .yardoc
         | 
| 6 | 
            +
            Gemfile.lock
         | 
| 7 | 
            +
            InstalledFiles
         | 
| 8 | 
            +
            _yardoc
         | 
| 9 | 
            +
            coverage
         | 
| 10 | 
            +
            doc/
         | 
| 11 | 
            +
            lib/bundler/man
         | 
| 12 | 
            +
            pkg
         | 
| 13 | 
            +
            rdoc
         | 
| 14 | 
            +
            spec/reports
         | 
| 15 | 
            +
            test/tmp
         | 
| 16 | 
            +
            test/version_tmp
         | 
| 17 | 
            +
            tmp
         | 
| 18 | 
            +
            *.bundle
         | 
| 19 | 
            +
            *.so
         | 
| 20 | 
            +
            *.o
         | 
| 21 | 
            +
            *.a
         | 
| 22 | 
            +
            mkmf.log
         | 
    
        data/.rspec
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2014 Antonio Antillon
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            # Melatico
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Simple ruby library to generate Melate (Mexico's Lotto) combinations.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                gem 'melatico'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            And then execute:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                $ bundle
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Or install it yourself as:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ gem install melatico
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ```ruby
         | 
| 22 | 
            +
            Melatico.draw
         | 
| 23 | 
            +
            #=> [17, 31, 39, 44, 47, 48]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            # Want to generate a full sheet?
         | 
| 26 | 
            +
            Melatico.draw(5)
         | 
| 27 | 
            +
            # [
         | 
| 28 | 
            +
            #   [16, 19, 46, 49, 51, 53],
         | 
| 29 | 
            +
            #   [1, 7, 34, 42, 43, 50],
         | 
| 30 | 
            +
            #   [2, 16, 26, 27, 35, 48],
         | 
| 31 | 
            +
            #   [18, 28, 35, 45, 52, 53],
         | 
| 32 | 
            +
            #   [20, 23, 27, 33, 35, 50]
         | 
| 33 | 
            +
            # ]
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            # Or generate any number of combinations
         | 
| 36 | 
            +
            Melatico.draw(3)
         | 
| 37 | 
            +
            # [
         | 
| 38 | 
            +
            #   [4, 5, 8, 12, 41, 48],
         | 
| 39 | 
            +
            #   [17, 32, 35, 38, 51, 54],
         | 
| 40 | 
            +
            #   [2, 36, 40, 41, 45, 52]
         | 
| 41 | 
            +
            # ]
         | 
| 42 | 
            +
            ```
         | 
| 43 | 
            +
             | 
| 44 | 
            +
             | 
| 45 | 
            +
            ## Contributing
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            1. Fork it ( https://github.com/[my-github-username]/melatico/fork )
         | 
| 48 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 49 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 50 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 51 | 
            +
            5. Create a new Pull Request
         | 
| 52 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    
    
        data/lib/melatico.rb
    ADDED
    
    | @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            require "melatico/version"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Melatico
         | 
| 4 | 
            +
              PICKS = 6
         | 
| 5 | 
            +
              NUMBERS_RANGE = (1..56)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def self.draw(sets = 1)
         | 
| 8 | 
            +
                return pick_numbers if sets == 1
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                sets.times.map { pick_numbers }
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              private
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def self.pick_numbers
         | 
| 16 | 
            +
                results = []
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                PICKS.times do
         | 
| 19 | 
            +
                  pick = rand(NUMBERS_RANGE)
         | 
| 20 | 
            +
                  add_to_results(pick, results)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                results.sort
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def self.add_to_results(number, collection)
         | 
| 27 | 
            +
                number = confirm_uniqueness(number, collection)
         | 
| 28 | 
            +
                collection << number
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def self.confirm_uniqueness(number, collection)
         | 
| 32 | 
            +
                until is_unique?(number, collection)
         | 
| 33 | 
            +
                  number = rand(NUMBERS_RANGE)
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                number
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def self.is_unique?(number, collection)
         | 
| 40 | 
            +
                not collection.include?(number)
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
    
        data/melatico.gemspec
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'melatico/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "melatico"
         | 
| 8 | 
            +
              spec.version       = Melatico::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Antonio Antillon"]
         | 
| 10 | 
            +
              spec.email         = ["antillas21@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = %q{Simple ruby library to generate Melate (Mexico's Lotto) combinations.}
         | 
| 12 | 
            +
              spec.description   = %q{Simple ruby library to generate Melate (Mexico's Lotto) combinations.}
         | 
| 13 | 
            +
              spec.homepage      = ""
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_development_dependency "bundler", "~> 1.6"
         | 
| 22 | 
            +
              spec.add_development_dependency "rake"
         | 
| 23 | 
            +
              spec.add_development_dependency "rspec", "~> 2.14.1"
         | 
| 24 | 
            +
              spec.add_development_dependency "pry"
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Melatico do
         | 
| 4 | 
            +
              describe '.draw' do
         | 
| 5 | 
            +
                let(:drawing) { Melatico.draw }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                it 'returns an Array with results' do
         | 
| 8 | 
            +
                  expect(drawing).to be_a(Array)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it 'results in the returned array are integers' do
         | 
| 12 | 
            +
                  drawing.each do |num|
         | 
| 13 | 
            +
                    expect(num).to be_a(Integer)
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                it 'returned array has 6 elements' do
         | 
| 18 | 
            +
                  expect(drawing.size).to eq(6)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'each integer in the array is any number from 1 to 56' do
         | 
| 22 | 
            +
                  1_000.times do
         | 
| 23 | 
            +
                    drawing = Melatico.draw
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    drawing.each do |num|
         | 
| 26 | 
            +
                      expect(num).to be <= 56
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                it 'cannot have duplicate numbers in the array' do
         | 
| 32 | 
            +
                  1_000.times do
         | 
| 33 | 
            +
                    drawing = Melatico.draw
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    drawing.each_with_index do |item, idx|
         | 
| 36 | 
            +
                      next_item = drawing[idx + 1]
         | 
| 37 | 
            +
                      prev_item = drawing[idx - 1]
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                      expect(item).to_not eq(next_item)
         | 
| 40 | 
            +
                      expect(item).to_not eq(prev_item)
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                context 'number of drawings' do
         | 
| 46 | 
            +
                  let(:drawing) { Melatico.draw(3) }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  it 'returns a 2D array' do
         | 
| 49 | 
            +
                    expect(drawing).to be_a(Array)
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  it 'size depends on number passed as argument' do
         | 
| 53 | 
            +
                    expect(drawing.size).to eq(3)
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  it 'contents are arrays' do
         | 
| 57 | 
            +
                    drawing.each do |draw|
         | 
| 58 | 
            +
                      expect(draw).to be_a(Array)
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,113 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: melatico
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Antonio Antillon
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-06-11 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ~>
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.6'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ~>
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.6'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - '>='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ~>
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 2.14.1
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ~>
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 2.14.1
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: pry
         | 
| 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'
         | 
| 69 | 
            +
            description: Simple ruby library to generate Melate (Mexico's Lotto) combinations.
         | 
| 70 | 
            +
            email:
         | 
| 71 | 
            +
            - antillas21@gmail.com
         | 
| 72 | 
            +
            executables: []
         | 
| 73 | 
            +
            extensions: []
         | 
| 74 | 
            +
            extra_rdoc_files: []
         | 
| 75 | 
            +
            files:
         | 
| 76 | 
            +
            - .gitignore
         | 
| 77 | 
            +
            - .rspec
         | 
| 78 | 
            +
            - Gemfile
         | 
| 79 | 
            +
            - LICENSE.txt
         | 
| 80 | 
            +
            - README.md
         | 
| 81 | 
            +
            - Rakefile
         | 
| 82 | 
            +
            - lib/melatico.rb
         | 
| 83 | 
            +
            - lib/melatico/version.rb
         | 
| 84 | 
            +
            - melatico.gemspec
         | 
| 85 | 
            +
            - spec/melatico/draw_spec.rb
         | 
| 86 | 
            +
            - spec/spec_helper.rb
         | 
| 87 | 
            +
            homepage: ''
         | 
| 88 | 
            +
            licenses:
         | 
| 89 | 
            +
            - MIT
         | 
| 90 | 
            +
            metadata: {}
         | 
| 91 | 
            +
            post_install_message: 
         | 
| 92 | 
            +
            rdoc_options: []
         | 
| 93 | 
            +
            require_paths:
         | 
| 94 | 
            +
            - lib
         | 
| 95 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 96 | 
            +
              requirements:
         | 
| 97 | 
            +
              - - '>='
         | 
| 98 | 
            +
                - !ruby/object:Gem::Version
         | 
| 99 | 
            +
                  version: '0'
         | 
| 100 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 101 | 
            +
              requirements:
         | 
| 102 | 
            +
              - - '>='
         | 
| 103 | 
            +
                - !ruby/object:Gem::Version
         | 
| 104 | 
            +
                  version: '0'
         | 
| 105 | 
            +
            requirements: []
         | 
| 106 | 
            +
            rubyforge_project: 
         | 
| 107 | 
            +
            rubygems_version: 2.1.11
         | 
| 108 | 
            +
            signing_key: 
         | 
| 109 | 
            +
            specification_version: 4
         | 
| 110 | 
            +
            summary: Simple ruby library to generate Melate (Mexico's Lotto) combinations.
         | 
| 111 | 
            +
            test_files:
         | 
| 112 | 
            +
            - spec/melatico/draw_spec.rb
         | 
| 113 | 
            +
            - spec/spec_helper.rb
         |