date_discreter 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.
- data/.coveralls.yml +1 -0
 - data/.gitignore +14 -0
 - data/.hound.yml +25 -0
 - data/.rspec +2 -0
 - data/.travis.yml +25 -0
 - data/.yardopts +2 -0
 - data/Gemfile +6 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +90 -0
 - data/Rakefile +2 -0
 - data/date_discreter.gemspec +29 -0
 - data/lib/date_discreter/version.rb +3 -0
 - data/lib/date_discreter.rb +54 -0
 - data/spec/date_discreter_spec.rb +186 -0
 - data/spec/spec_helper.rb +116 -0
 - metadata +182 -0
 
    
        data/.coveralls.yml
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            repo_token: 8YcZSoBeStwUZ8Bpur4bSUtdQnPGks8hG
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.hound.yml
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Style/LineLength:
         
     | 
| 
      
 2 
     | 
    
         
            +
              Description: 'Limit lines to 130 characters.'
         
     | 
| 
      
 3 
     | 
    
         
            +
              Max: 130
         
     | 
| 
      
 4 
     | 
    
         
            +
            Style/SpaceInsideParens:
         
     | 
| 
      
 5 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 6 
     | 
    
         
            +
            Style/SpaceBeforeBlockBraces:
         
     | 
| 
      
 7 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 8 
     | 
    
         
            +
            StringLiterals:
         
     | 
| 
      
 9 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 10 
     | 
    
         
            +
            Style/TrailingComma:
         
     | 
| 
      
 11 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 12 
     | 
    
         
            +
            Style/BlockComments:
         
     | 
| 
      
 13 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 14 
     | 
    
         
            +
            Style/NilComparison:
         
     | 
| 
      
 15 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 16 
     | 
    
         
            +
            Style/Documentation:
         
     | 
| 
      
 17 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 18 
     | 
    
         
            +
            Style/RegexpLiteral:
         
     | 
| 
      
 19 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 20 
     | 
    
         
            +
            Style/SignalException:
         
     | 
| 
      
 21 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 22 
     | 
    
         
            +
            Style/CaseEquality:
         
     | 
| 
      
 23 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 24 
     | 
    
         
            +
            Style/SpaceBeforeComma:
         
     | 
| 
      
 25 
     | 
    
         
            +
              Enabled: false
         
     | 
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            language: ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            rvm:
         
     | 
| 
      
 3 
     | 
    
         
            +
            - 1.9
         
     | 
| 
      
 4 
     | 
    
         
            +
            - 2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            - 2.1
         
     | 
| 
      
 6 
     | 
    
         
            +
            - 2.2
         
     | 
| 
      
 7 
     | 
    
         
            +
            - ruby-head
         
     | 
| 
      
 8 
     | 
    
         
            +
            bundler_args: "--jobs=2"
         
     | 
| 
      
 9 
     | 
    
         
            +
            before_script:
         
     | 
| 
      
 10 
     | 
    
         
            +
            - export CODECLIMATE_REPO_TOKEN=ba1cb6377edbaa3baf183aad543a1db02e0f2b75fe676fa8b9db2294850af609
         
     | 
| 
      
 11 
     | 
    
         
            +
            - export COVERAGE=true
         
     | 
| 
      
 12 
     | 
    
         
            +
            script:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - bundle exec rspec
         
     | 
| 
      
 14 
     | 
    
         
            +
            - bundle exec rubydoctest README.md
         
     | 
| 
      
 15 
     | 
    
         
            +
            branches:
         
     | 
| 
      
 16 
     | 
    
         
            +
              only:
         
     | 
| 
      
 17 
     | 
    
         
            +
              - master
         
     | 
| 
      
 18 
     | 
    
         
            +
            notifications:
         
     | 
| 
      
 19 
     | 
    
         
            +
              email: false
         
     | 
| 
      
 20 
     | 
    
         
            +
              slack:
         
     | 
| 
      
 21 
     | 
    
         
            +
                secure: dJhFmNRz7dtbnspVC0FYcdDhX/HAjTTbPRBa4GXtyDH5UUU9PqltcKfj2/ZG/28gktvO3Av1yoLP7sEAPNzkCSEjGMc5pT3hAeKub4WC/2OQ/eb19lBMupz3amJeZd7CWv6vHwYhyU2VFXpFa4AIn7WnR+XDHu7S3+ScQNJuz4E=
         
     | 
| 
      
 22 
     | 
    
         
            +
            matrix:
         
     | 
| 
      
 23 
     | 
    
         
            +
              allow_failures:
         
     | 
| 
      
 24 
     | 
    
         
            +
              - rvm: 2.2
         
     | 
| 
      
 25 
     | 
    
         
            +
              - rvm: ruby-head
         
     | 
    
        data/.yardopts
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 sue445
         
     | 
| 
      
 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,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # DateDiscreter
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Check discrete of months, days and hours
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://travis-ci.org/sue445/date_discreter)
         
     | 
| 
      
 6 
     | 
    
         
            +
            [](https://gemnasium.com/sue445/date_discreter)
         
     | 
| 
      
 7 
     | 
    
         
            +
            [](https://codeclimate.com/github/sue445/date_discreter)
         
     | 
| 
      
 8 
     | 
    
         
            +
            [](https://coveralls.io/r/sue445/date_discreter)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ## Requirements
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            * ruby 1.9+
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 19 
     | 
    
         
            +
            gem 'date_discreter'
         
     | 
| 
      
 20 
     | 
    
         
            +
            ```
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                $ gem install date_discreter
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 32 
     | 
    
         
            +
            >> require "date_discreter"
         
     | 
| 
      
 33 
     | 
    
         
            +
            ```
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            ### discrete_months / continuous_months?
         
     | 
| 
      
 36 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 37 
     | 
    
         
            +
            >> continuous_months = [Date.parse("2014-10-01"), Date.parse("2014-11-01"), Date.parse("2014-12-01")]
         
     | 
| 
      
 38 
     | 
    
         
            +
            >> DateDiscreter.discrete_months(continuous_months)
         
     | 
| 
      
 39 
     | 
    
         
            +
            => []
         
     | 
| 
      
 40 
     | 
    
         
            +
            >> DateDiscreter.continuous_months?(continuous_months)
         
     | 
| 
      
 41 
     | 
    
         
            +
            => true
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            >> discrete_months = [Date.parse("2014-10-01"), Date.parse("2014-12-01")]
         
     | 
| 
      
 44 
     | 
    
         
            +
            >> DateDiscreter.discrete_months(discrete_months)
         
     | 
| 
      
 45 
     | 
    
         
            +
            => [Date.parse("2014-11-01")]
         
     | 
| 
      
 46 
     | 
    
         
            +
            >> DateDiscreter.continuous_months?(discrete_months)
         
     | 
| 
      
 47 
     | 
    
         
            +
            => false
         
     | 
| 
      
 48 
     | 
    
         
            +
            ```
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            ### discrete_days / continuous_days?
         
     | 
| 
      
 51 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 52 
     | 
    
         
            +
            >> continuous_days = [Date.parse("2014-12-01"), Date.parse("2014-12-02"), Date.parse("2014-12-03")]
         
     | 
| 
      
 53 
     | 
    
         
            +
            >> DateDiscreter.discrete_days(continuous_days)
         
     | 
| 
      
 54 
     | 
    
         
            +
            => []
         
     | 
| 
      
 55 
     | 
    
         
            +
            >> DateDiscreter.continuous_days?(continuous_days)
         
     | 
| 
      
 56 
     | 
    
         
            +
            => true
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            >> discrete_days = [Date.parse("2014-12-01"), Date.parse("2014-12-03")]
         
     | 
| 
      
 59 
     | 
    
         
            +
            >> DateDiscreter.discrete_days(discrete_days)
         
     | 
| 
      
 60 
     | 
    
         
            +
            => [Date.parse("2014-12-02")]
         
     | 
| 
      
 61 
     | 
    
         
            +
            >> DateDiscreter.continuous_days?(discrete_days)
         
     | 
| 
      
 62 
     | 
    
         
            +
            => false
         
     | 
| 
      
 63 
     | 
    
         
            +
            ```
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            ### discrete_hours / continuous_hours?
         
     | 
| 
      
 66 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 67 
     | 
    
         
            +
            >> continuous_hours = [Time.parse("2014-12-01 00:00:00"), Time.parse("2014-12-01 01:00:00"), Time.parse("2014-12-01 02:00:00")]
         
     | 
| 
      
 68 
     | 
    
         
            +
            >> DateDiscreter.discrete_hours(continuous_hours)
         
     | 
| 
      
 69 
     | 
    
         
            +
            => []
         
     | 
| 
      
 70 
     | 
    
         
            +
            >> DateDiscreter.continuous_hours?(continuous_hours)
         
     | 
| 
      
 71 
     | 
    
         
            +
            => true
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            >> discrete_hours = [Time.parse("2014-12-01 00:00:00"), Time.parse("2014-12-01 02:00:00")]
         
     | 
| 
      
 74 
     | 
    
         
            +
            >> DateDiscreter.discrete_hours(discrete_hours)
         
     | 
| 
      
 75 
     | 
    
         
            +
            => [Time.parse("2014-12-01 01:00:00")]
         
     | 
| 
      
 76 
     | 
    
         
            +
            >> DateDiscreter.continuous_hours?(discrete_hours)
         
     | 
| 
      
 77 
     | 
    
         
            +
            => false
         
     | 
| 
      
 78 
     | 
    
         
            +
            ```
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            1. Fork it ( https://github.com/sue445/date_discreter/fork )
         
     | 
| 
      
 83 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 84 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 85 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 86 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            [](https://bitdeli.com/free "Bitdeli Badge")
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'date_discreter/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "date_discreter"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = DateDiscreter::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["sue445"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["sue445@sue445.net"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Check discrete of months, days and hours}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{Check discrete of months, days and hours}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/sue445/date_discreter"
         
     | 
| 
      
 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_dependency 'activesupport'
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency "bundler", ">= 1.5"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "codeclimate-test-reporter"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "coveralls"
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 27 
     | 
    
         
            +
              spec.add_development_dependency "rspec"
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_development_dependency "yard"
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "date_discreter/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'active_support/all'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module DateDiscreter
         
     | 
| 
      
 5 
     | 
    
         
            +
              module_function
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              # return discrete of arg months
         
     | 
| 
      
 8 
     | 
    
         
            +
              # @param months [Array<Date,Time>]
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @return [Array<Date>] if arg is continuous return empty array.
         
     | 
| 
      
 10 
     | 
    
         
            +
              def discrete_months(months)
         
     | 
| 
      
 11 
     | 
    
         
            +
                discrete_times(months, 1.month)
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # return discrete of arg days
         
     | 
| 
      
 15 
     | 
    
         
            +
              # @param dates [Array<Date,Time>]
         
     | 
| 
      
 16 
     | 
    
         
            +
              # @return [Array<Date>] if arg is continuous return empty array.
         
     | 
| 
      
 17 
     | 
    
         
            +
              def discrete_days(dates)
         
     | 
| 
      
 18 
     | 
    
         
            +
                discrete_times(dates, 1.day)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              # return discrete of arg hours
         
     | 
| 
      
 22 
     | 
    
         
            +
              # @param hours [Array<Time>]
         
     | 
| 
      
 23 
     | 
    
         
            +
              # @return [Array<Time>] if arg is continuous return empty array.
         
     | 
| 
      
 24 
     | 
    
         
            +
              def discrete_hours(hours)
         
     | 
| 
      
 25 
     | 
    
         
            +
                discrete_times(hours, 1.hour)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def discrete_times(target_times, degree)
         
     | 
| 
      
 29 
     | 
    
         
            +
                res = []
         
     | 
| 
      
 30 
     | 
    
         
            +
                target_times.sort.each_cons(2) do |this_time, next_time|
         
     | 
| 
      
 31 
     | 
    
         
            +
                  res << this_time + degree unless this_time + degree == next_time
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
                res
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
              private_class_method :discrete_times
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              # whether arg months are continuous
         
     | 
| 
      
 38 
     | 
    
         
            +
              # @param months [Array<Date>]
         
     | 
| 
      
 39 
     | 
    
         
            +
              def continuous_months?(months)
         
     | 
| 
      
 40 
     | 
    
         
            +
                discrete_months(months).empty?
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              # whether arg months are continuous
         
     | 
| 
      
 44 
     | 
    
         
            +
              # @param dates [Array<Date>]
         
     | 
| 
      
 45 
     | 
    
         
            +
              def continuous_days?(dates)
         
     | 
| 
      
 46 
     | 
    
         
            +
                discrete_days(dates).empty?
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              # whether arg months are continuous
         
     | 
| 
      
 50 
     | 
    
         
            +
              # @param hours [Array<Date>]
         
     | 
| 
      
 51 
     | 
    
         
            +
              def continuous_hours?(hours)
         
     | 
| 
      
 52 
     | 
    
         
            +
                discrete_hours(hours).empty?
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,186 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            describe DateDiscreter do
         
     | 
| 
      
 2 
     | 
    
         
            +
              let(:continuous_months) do
         
     | 
| 
      
 3 
     | 
    
         
            +
                [
         
     | 
| 
      
 4 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 5 
     | 
    
         
            +
                  to_time("2013-11-01 00:00:00"),
         
     | 
| 
      
 6 
     | 
    
         
            +
                  to_time("2013-12-01 00:00:00"),
         
     | 
| 
      
 7 
     | 
    
         
            +
                  to_time("2014-01-01 00:00:00"),
         
     | 
| 
      
 8 
     | 
    
         
            +
                  to_time("2014-02-01 00:00:00"),
         
     | 
| 
      
 9 
     | 
    
         
            +
                ]
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              let(:discrete_months) do
         
     | 
| 
      
 13 
     | 
    
         
            +
                [
         
     | 
| 
      
 14 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 15 
     | 
    
         
            +
                  to_time("2013-12-01 00:00:00"),
         
     | 
| 
      
 16 
     | 
    
         
            +
                  to_time("2014-01-01 00:00:00"),
         
     | 
| 
      
 17 
     | 
    
         
            +
                  to_time("2014-02-01 00:00:00"),
         
     | 
| 
      
 18 
     | 
    
         
            +
                ]
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              let(:continuous_days) do
         
     | 
| 
      
 22 
     | 
    
         
            +
                [
         
     | 
| 
      
 23 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 24 
     | 
    
         
            +
                  to_time("2013-10-02 00:00:00"),
         
     | 
| 
      
 25 
     | 
    
         
            +
                  to_time("2013-10-03 00:00:00"),
         
     | 
| 
      
 26 
     | 
    
         
            +
                  to_time("2013-10-04 00:00:00"),
         
     | 
| 
      
 27 
     | 
    
         
            +
                  to_time("2013-10-05 00:00:00"),
         
     | 
| 
      
 28 
     | 
    
         
            +
                ]
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              let(:discrete_days) do
         
     | 
| 
      
 32 
     | 
    
         
            +
                [
         
     | 
| 
      
 33 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 34 
     | 
    
         
            +
                  to_time("2013-10-02 00:00:00"),
         
     | 
| 
      
 35 
     | 
    
         
            +
                  to_time("2013-10-04 00:00:00"),
         
     | 
| 
      
 36 
     | 
    
         
            +
                  to_time("2013-10-05 00:00:00"),
         
     | 
| 
      
 37 
     | 
    
         
            +
                ]
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              let(:continuous_hours) do
         
     | 
| 
      
 41 
     | 
    
         
            +
                [
         
     | 
| 
      
 42 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 43 
     | 
    
         
            +
                  to_time("2013-10-01 01:00:00"),
         
     | 
| 
      
 44 
     | 
    
         
            +
                  to_time("2013-10-01 02:00:00"),
         
     | 
| 
      
 45 
     | 
    
         
            +
                  to_time("2013-10-01 03:00:00"),
         
     | 
| 
      
 46 
     | 
    
         
            +
                  to_time("2013-10-01 04:00:00"),
         
     | 
| 
      
 47 
     | 
    
         
            +
                ]
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              let(:discrete_hours) do
         
     | 
| 
      
 51 
     | 
    
         
            +
                [
         
     | 
| 
      
 52 
     | 
    
         
            +
                  to_time("2013-10-01 00:00:00"),
         
     | 
| 
      
 53 
     | 
    
         
            +
                  to_time("2013-10-01 01:00:00"),
         
     | 
| 
      
 54 
     | 
    
         
            +
                  to_time("2013-10-01 02:00:00"),
         
     | 
| 
      
 55 
     | 
    
         
            +
                  to_time("2013-10-01 04:00:00"),
         
     | 
| 
      
 56 
     | 
    
         
            +
                ]
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              describe "#discrete_months" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                subject{ DateDiscreter.discrete_months(months) }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  context "with time array" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                    let(:months){ continuous_months }
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                    it{ should eq [] }
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  context "with date array" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                    let(:months){ continuous_months.map(&:to_date) }
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                    it{ should eq [] }
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  context "with time array" do
         
     | 
| 
      
 78 
     | 
    
         
            +
                    let(:months){ discrete_months }
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    it{ should eq [to_time("2013-11-01 00:00:00")] }
         
     | 
| 
      
 81 
     | 
    
         
            +
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  context "with date array" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                    let(:months){ discrete_months.map(&:to_date) }
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                    it{ should eq [to_date("2013-11-01")] }
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              describe "#discrete_days" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                subject{ DateDiscreter.discrete_days(days) }
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 95 
     | 
    
         
            +
                  context "with time array" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                    let(:days){ continuous_days }
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                    it{ should eq [] }
         
     | 
| 
      
 99 
     | 
    
         
            +
                  end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                  context "with date array" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                    let(:days){ continuous_days.map(&:to_date) }
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    it{ should eq [] }
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                  context "with time array" do
         
     | 
| 
      
 110 
     | 
    
         
            +
                    let(:days){ discrete_days }
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    it{ should eq [to_time("2013-10-03 00:00:00")] }
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  context "with date array" do
         
     | 
| 
      
 116 
     | 
    
         
            +
                    let(:days){ discrete_days.map(&:to_date) }
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                    it{ should eq [to_date("2013-10-03")] }
         
     | 
| 
      
 119 
     | 
    
         
            +
                  end
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
              describe "#discrete_hours" do
         
     | 
| 
      
 124 
     | 
    
         
            +
                subject{ DateDiscreter.discrete_hours(hours) }
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 127 
     | 
    
         
            +
                  let(:hours){ continuous_hours }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  it{ should eq [] }
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  let(:hours){ discrete_hours }
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                  it{ should eq [to_time("2013-10-01 03:00:00")] }
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              describe "#continuous_months?" do
         
     | 
| 
      
 140 
     | 
    
         
            +
                subject{ DateDiscreter.continuous_months?(months) }
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 143 
     | 
    
         
            +
                  let(:months){ continuous_months }
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                  it{ should be true }
         
     | 
| 
      
 146 
     | 
    
         
            +
                end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 149 
     | 
    
         
            +
                  let(:months){ discrete_months }
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                  it{ should be false }
         
     | 
| 
      
 152 
     | 
    
         
            +
                end
         
     | 
| 
      
 153 
     | 
    
         
            +
              end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
              describe "#continuous_days?" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                subject{ DateDiscreter.continuous_days?(days) }
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 159 
     | 
    
         
            +
                  let(:days){ continuous_days }
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                  it{ should be true }
         
     | 
| 
      
 162 
     | 
    
         
            +
                end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 165 
     | 
    
         
            +
                  let(:days){ discrete_days }
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                  it{ should be false }
         
     | 
| 
      
 168 
     | 
    
         
            +
                end
         
     | 
| 
      
 169 
     | 
    
         
            +
              end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
              describe "#continuous_hours?" do
         
     | 
| 
      
 172 
     | 
    
         
            +
                subject{ DateDiscreter.continuous_hours?(hours) }
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                context "with continuous" do
         
     | 
| 
      
 175 
     | 
    
         
            +
                  let(:hours){ continuous_hours }
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                  it{ should be true }
         
     | 
| 
      
 178 
     | 
    
         
            +
                end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                context "without continuous" do
         
     | 
| 
      
 181 
     | 
    
         
            +
                  let(:hours){ discrete_hours }
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                  it{ should be false }
         
     | 
| 
      
 184 
     | 
    
         
            +
                end
         
     | 
| 
      
 185 
     | 
    
         
            +
              end
         
     | 
| 
      
 186 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,116 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            if ENV["COVERAGE"]
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'simplecov'
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'coveralls'
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'codeclimate-test-reporter'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
         
     | 
| 
      
 7 
     | 
    
         
            +
                CodeClimate::TestReporter::Formatter,
         
     | 
| 
      
 8 
     | 
    
         
            +
                Coveralls::SimpleCov::Formatter
         
     | 
| 
      
 9 
     | 
    
         
            +
              ]
         
     | 
| 
      
 10 
     | 
    
         
            +
              SimpleCov.start
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
         
     | 
| 
      
 14 
     | 
    
         
            +
            require "date_discreter"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 19 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 20 
     | 
    
         
            +
            # The generated `.rspec` file contains `--require spec_helper` which will cause this
         
     | 
| 
      
 21 
     | 
    
         
            +
            # file to always be loaded, without a need to explicitly require it in any files.
         
     | 
| 
      
 22 
     | 
    
         
            +
            #
         
     | 
| 
      
 23 
     | 
    
         
            +
            # Given that it is always loaded, you are encouraged to keep this file as
         
     | 
| 
      
 24 
     | 
    
         
            +
            # light-weight as possible. Requiring heavyweight dependencies from this file
         
     | 
| 
      
 25 
     | 
    
         
            +
            # will add to the boot time of your test suite on EVERY test run, even for an
         
     | 
| 
      
 26 
     | 
    
         
            +
            # individual file that may not need all of that loaded. Instead, consider making
         
     | 
| 
      
 27 
     | 
    
         
            +
            # a separate helper file that requires the additional dependencies and performs
         
     | 
| 
      
 28 
     | 
    
         
            +
            # the additional setup, and require it from the spec files that actually need it.
         
     | 
| 
      
 29 
     | 
    
         
            +
            #
         
     | 
| 
      
 30 
     | 
    
         
            +
            # The `.rspec` file also contains a few flags that are not defaults but that
         
     | 
| 
      
 31 
     | 
    
         
            +
            # users commonly want.
         
     | 
| 
      
 32 
     | 
    
         
            +
            #
         
     | 
| 
      
 33 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 34 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 35 
     | 
    
         
            +
              # rspec-expectations config goes here. You can use an alternate
         
     | 
| 
      
 36 
     | 
    
         
            +
              # assertion/expectation library such as wrong or the stdlib/minitest
         
     | 
| 
      
 37 
     | 
    
         
            +
              # assertions if you prefer.
         
     | 
| 
      
 38 
     | 
    
         
            +
              config.expect_with :rspec do |expectations|
         
     | 
| 
      
 39 
     | 
    
         
            +
                # This option will default to `true` in RSpec 4. It makes the `description`
         
     | 
| 
      
 40 
     | 
    
         
            +
                # and `failure_message` of custom matchers include text for helper methods
         
     | 
| 
      
 41 
     | 
    
         
            +
                # defined using `chain`, e.g.:
         
     | 
| 
      
 42 
     | 
    
         
            +
                # be_bigger_than(2).and_smaller_than(4).description
         
     | 
| 
      
 43 
     | 
    
         
            +
                #   # => "be bigger than 2 and smaller than 4"
         
     | 
| 
      
 44 
     | 
    
         
            +
                # ...rather than:
         
     | 
| 
      
 45 
     | 
    
         
            +
                #   # => "be bigger than 2"
         
     | 
| 
      
 46 
     | 
    
         
            +
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              # rspec-mocks config goes here. You can use an alternate test double
         
     | 
| 
      
 50 
     | 
    
         
            +
              # library (such as bogus or mocha) by changing the `mock_with` option here.
         
     | 
| 
      
 51 
     | 
    
         
            +
              config.mock_with :rspec do |mocks|
         
     | 
| 
      
 52 
     | 
    
         
            +
                # Prevents you from mocking or stubbing a method that does not exist on
         
     | 
| 
      
 53 
     | 
    
         
            +
                # a real object. This is generally recommended, and will default to
         
     | 
| 
      
 54 
     | 
    
         
            +
                # `true` in RSpec 4.
         
     | 
| 
      
 55 
     | 
    
         
            +
                mocks.verify_partial_doubles = true
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            # The settings below are suggested to provide a good initial experience
         
     | 
| 
      
 59 
     | 
    
         
            +
            # with RSpec, but feel free to customize to your heart's content.
         
     | 
| 
      
 60 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 61 
     | 
    
         
            +
              # These two settings work together to allow you to limit a spec run
         
     | 
| 
      
 62 
     | 
    
         
            +
              # to individual examples or groups you care about by tagging them with
         
     | 
| 
      
 63 
     | 
    
         
            +
              # `:focus` metadata. When nothing is tagged with `:focus`, all examples
         
     | 
| 
      
 64 
     | 
    
         
            +
              # get run.
         
     | 
| 
      
 65 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 66 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              # Limits the available syntax to the non-monkey patched syntax that is recommended.
         
     | 
| 
      
 69 
     | 
    
         
            +
              # For more details, see:
         
     | 
| 
      
 70 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
         
     | 
| 
      
 71 
     | 
    
         
            +
              #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
         
     | 
| 
      
 72 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
         
     | 
| 
      
 73 
     | 
    
         
            +
              config.disable_monkey_patching!
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              # This setting enables warnings. It's recommended, but in some cases may
         
     | 
| 
      
 76 
     | 
    
         
            +
              # be too noisy due to issues in dependencies.
         
     | 
| 
      
 77 
     | 
    
         
            +
              config.warnings = true
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              # Many RSpec users commonly either run the entire suite or an individual
         
     | 
| 
      
 80 
     | 
    
         
            +
              # file, and it's useful to allow more verbose output when running an
         
     | 
| 
      
 81 
     | 
    
         
            +
              # individual spec file.
         
     | 
| 
      
 82 
     | 
    
         
            +
              if config.files_to_run.one?
         
     | 
| 
      
 83 
     | 
    
         
            +
                # Use the documentation formatter for detailed output,
         
     | 
| 
      
 84 
     | 
    
         
            +
                # unless a formatter has already been configured
         
     | 
| 
      
 85 
     | 
    
         
            +
                # (e.g. via a command-line flag).
         
     | 
| 
      
 86 
     | 
    
         
            +
                config.default_formatter = 'doc'
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              # Print the 10 slowest examples and example groups at the
         
     | 
| 
      
 90 
     | 
    
         
            +
              # end of the spec run, to help surface which specs are running
         
     | 
| 
      
 91 
     | 
    
         
            +
              # particularly slow.
         
     | 
| 
      
 92 
     | 
    
         
            +
              config.profile_examples = 10
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 95 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 96 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 97 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 98 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              # Seed global randomization in this process using the `--seed` CLI option.
         
     | 
| 
      
 101 
     | 
    
         
            +
              # Setting this allows you to use `--seed` to deterministically reproduce
         
     | 
| 
      
 102 
     | 
    
         
            +
              # test failures related to randomization by passing the same `--seed` value
         
     | 
| 
      
 103 
     | 
    
         
            +
              # as the one that triggered the failure.
         
     | 
| 
      
 104 
     | 
    
         
            +
              Kernel.srand config.seed
         
     | 
| 
      
 105 
     | 
    
         
            +
            =end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 108 
     | 
    
         
            +
            end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
            def to_time(str)
         
     | 
| 
      
 111 
     | 
    
         
            +
              Time.parse(str)
         
     | 
| 
      
 112 
     | 
    
         
            +
            end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            def to_date(str)
         
     | 
| 
      
 115 
     | 
    
         
            +
              Date.parse(str)
         
     | 
| 
      
 116 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,182 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: date_discreter
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - sue445
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2014-11-30 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 30 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 31 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 32 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 33 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 34 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 36 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 38 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 46 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 47 
     | 
    
         
            +
              name: codeclimate-test-reporter
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 55 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 63 
     | 
    
         
            +
              name: coveralls
         
     | 
| 
      
 64 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 66 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 67 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 68 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 69 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 70 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 71 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 72 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 73 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 74 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 75 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 76 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 77 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 78 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 79 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 80 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 81 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 82 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 83 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 84 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 85 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 86 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 87 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 88 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 89 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 90 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 91 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 92 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 93 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 94 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 95 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 96 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 97 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 98 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 99 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 100 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 101 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 102 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 103 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 104 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 105 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 106 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 107 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 108 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 109 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 110 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 111 
     | 
    
         
            +
              name: yard
         
     | 
| 
      
 112 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 113 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 118 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 119 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 120 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 122 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 123 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 124 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 125 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 126 
     | 
    
         
            +
            description: Check discrete of months, days and hours
         
     | 
| 
      
 127 
     | 
    
         
            +
            email:
         
     | 
| 
      
 128 
     | 
    
         
            +
            - sue445@sue445.net
         
     | 
| 
      
 129 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 130 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 131 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 132 
     | 
    
         
            +
            files:
         
     | 
| 
      
 133 
     | 
    
         
            +
            - .coveralls.yml
         
     | 
| 
      
 134 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 135 
     | 
    
         
            +
            - .hound.yml
         
     | 
| 
      
 136 
     | 
    
         
            +
            - .rspec
         
     | 
| 
      
 137 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
      
 138 
     | 
    
         
            +
            - .yardopts
         
     | 
| 
      
 139 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 140 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 141 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 142 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 143 
     | 
    
         
            +
            - date_discreter.gemspec
         
     | 
| 
      
 144 
     | 
    
         
            +
            - lib/date_discreter.rb
         
     | 
| 
      
 145 
     | 
    
         
            +
            - lib/date_discreter/version.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - spec/date_discreter_spec.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 148 
     | 
    
         
            +
            homepage: https://github.com/sue445/date_discreter
         
     | 
| 
      
 149 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 150 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 151 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 152 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 153 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 154 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 155 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 156 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 157 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 158 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 159 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 160 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 161 
     | 
    
         
            +
                  segments:
         
     | 
| 
      
 162 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 163 
     | 
    
         
            +
                  hash: 2815363592125099921
         
     | 
| 
      
 164 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 165 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 166 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 167 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 168 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 169 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 170 
     | 
    
         
            +
                  segments:
         
     | 
| 
      
 171 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 172 
     | 
    
         
            +
                  hash: 2815363592125099921
         
     | 
| 
      
 173 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 174 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 175 
     | 
    
         
            +
            rubygems_version: 1.8.23.2
         
     | 
| 
      
 176 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 177 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 178 
     | 
    
         
            +
            summary: Check discrete of months, days and hours
         
     | 
| 
      
 179 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 180 
     | 
    
         
            +
            - spec/date_discreter_spec.rb
         
     | 
| 
      
 181 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 182 
     | 
    
         
            +
            has_rdoc: 
         
     |