date_period 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +17 -0
 - data/.rbenv-gemsets +2 -0
 - data/.rspec +2 -0
 - data/Gemfile +3 -11
 - data/LICENSE.txt +3 -1
 - data/README.md +59 -3
 - data/Rakefile +1 -45
 - data/date_period.gemspec +21 -56
 - data/lib/date_period.rb +7 -0
 - data/lib/date_period/month.rb +111 -0
 - data/lib/date_period/version.rb +3 -0
 - data/spec/date_period/month_spec.rb +113 -0
 - data/spec/spec_helper.rb +90 -0
 - metadata +35 -21
 - data/Gemfile.lock +0 -62
 - data/LICENSE +0 -20
 - data/README.rdoc +0 -19
 - data/VERSION +0 -1
 - data/test/helper.rb +0 -18
 - data/test/test_date_period.rb +0 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a5201bd511e2a5a9598ab737ae1fc78d930c632e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: dd397086bd2d51fb75f71a36d5d78464d7a29722
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e0a4539d29282802bbc930350fc00afd01c5980884e00964ea26249f3c35a182021831db3d12b115ac2c6a515287fff45fed92cdb39834da32678de88f115e9c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 80639aef9f9d5643fea39f3b49938a4e141aeec2d03bdbb3bcfa1962585ac139b2279526a221da2285f9541217ec83372360cb2fd9ab139e967df7ae2162a0f6
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rbenv-gemsets
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -1,12 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source  
     | 
| 
       2 
     | 
    
         
            -
            # Add dependencies required to use your gem here.
         
     | 
| 
       3 
     | 
    
         
            -
            # Example:
         
     | 
| 
       4 
     | 
    
         
            -
            #   gem "activesupport", ">= 2.3.5"
         
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
       5 
2 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            #  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            group :development do
         
     | 
| 
       9 
     | 
    
         
            -
              gem "bundler"
         
     | 
| 
       10 
     | 
    
         
            -
              gem "jeweler"
         
     | 
| 
       11 
     | 
    
         
            -
              gem "rspec"
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in date_period.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
            gemspec
         
     | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,60 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            ===========
         
     | 
| 
      
 1 
     | 
    
         
            +
            # DatePeriod
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            DatePeriod provides classes for date related periods.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            feb_1982 = DatePeriod::Month.new(year: 1982, month: 2) #=> Feb 1982
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # date/time period conversion
         
     | 
| 
      
 9 
     | 
    
         
            +
            feb_1982.date_period #=> Mon, 01 Feb 1982..Sun, 28 Feb 1982
         
     | 
| 
      
 10 
     | 
    
         
            +
            feb_1982.time_period #=> 1982-02-01 00:00:00..1982-02-28 23:59:59
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            # computability and comparability
         
     | 
| 
      
 13 
     | 
    
         
            +
            jan = feb_1982 - 1.month #=> Jan 1982
         
     | 
| 
      
 14 
     | 
    
         
            +
            mar = feb_1982 + 1.month #=> Mar 1982
         
     | 
| 
      
 15 
     | 
    
         
            +
            (jan + 2.months) == mar #=> true
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # rangeability
         
     | 
| 
      
 18 
     | 
    
         
            +
            year_1982 = DatePeriod::Month.new(year: 1982, month: 1) .. DatePeriod::Month.new(year: 1982, month: 12) #=> Jan 1982..Dec 1982
         
     | 
| 
      
 19 
     | 
    
         
            +
            year_1982.include? feb_1982 #=> true
         
     | 
| 
      
 20 
     | 
    
         
            +
            year_1982.include? Date.new(1982,2,19) #=> true
         
     | 
| 
      
 21 
     | 
    
         
            +
            ```
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Implemented:
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            * `DatePeriod::Month`
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            Future implementation plans:
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            * `DatePeriod::Year`
         
     | 
| 
      
 30 
     | 
    
         
            +
            * `DatePeriod::Quarter`
         
     | 
| 
      
 31 
     | 
    
         
            +
            * `DatePeriod::Semi`
         
     | 
| 
      
 32 
     | 
    
         
            +
            * `DatePeriod::Week`
         
     | 
| 
      
 33 
     | 
    
         
            +
            * `DatePeriod::Decade`
         
     | 
| 
      
 34 
     | 
    
         
            +
            * `DatePeriod::Century`
         
     | 
| 
      
 35 
     | 
    
         
            +
            * `DatePeriod::Millenium`
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                gem 'date_period'
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                $ gem install date_period
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            1. Fork it
         
     | 
| 
      
 57 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 58 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 59 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 60 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,45 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'bundler'
         
     | 
| 
       5 
     | 
    
         
            -
            begin
         
     | 
| 
       6 
     | 
    
         
            -
              Bundler.setup(:default, :development)
         
     | 
| 
       7 
     | 
    
         
            -
            rescue Bundler::BundlerError => e
         
     | 
| 
       8 
     | 
    
         
            -
              $stderr.puts e.message
         
     | 
| 
       9 
     | 
    
         
            -
              $stderr.puts "Run `bundle install` to install missing gems"
         
     | 
| 
       10 
     | 
    
         
            -
              exit e.status_code
         
     | 
| 
       11 
     | 
    
         
            -
            end
         
     | 
| 
       12 
     | 
    
         
            -
            require 'rake'
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            require 'jeweler'
         
     | 
| 
       15 
     | 
    
         
            -
            Jeweler::Tasks.new do |gem|
         
     | 
| 
       16 
     | 
    
         
            -
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         
     | 
| 
       17 
     | 
    
         
            -
              gem.name = "date_period"
         
     | 
| 
       18 
     | 
    
         
            -
              gem.homepage = "http://github.com/more-ron/date_period"
         
     | 
| 
       19 
     | 
    
         
            -
              gem.license = "MIT"
         
     | 
| 
       20 
     | 
    
         
            -
              gem.summary = %Q{Date period}
         
     | 
| 
       21 
     | 
    
         
            -
              gem.description = %Q{Date period}
         
     | 
| 
       22 
     | 
    
         
            -
              gem.email = "more.ron.too@gmail.com"
         
     | 
| 
       23 
     | 
    
         
            -
              gem.authors = ["MoreRon"]
         
     | 
| 
       24 
     | 
    
         
            -
              # dependencies defined in Gemfile
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     | 
| 
       26 
     | 
    
         
            -
            Jeweler::RubygemsDotOrgTasks.new
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            require 'rake/testtask'
         
     | 
| 
       29 
     | 
    
         
            -
            Rake::TestTask.new(:test) do |test|
         
     | 
| 
       30 
     | 
    
         
            -
              test.libs << 'lib' << 'test'
         
     | 
| 
       31 
     | 
    
         
            -
              test.pattern = 'test/**/test_*.rb'
         
     | 
| 
       32 
     | 
    
         
            -
              test.verbose = true
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            task :default => :test
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
            require 'rdoc/task'
         
     | 
| 
       38 
     | 
    
         
            -
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
       39 
     | 
    
         
            -
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
       42 
     | 
    
         
            -
              rdoc.title = "date_period #{version}"
         
     | 
| 
       43 
     | 
    
         
            -
              rdoc.rdoc_files.include('README*')
         
     | 
| 
       44 
     | 
    
         
            -
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
       45 
     | 
    
         
            -
            end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
    
        data/date_period.gemspec
    CHANGED
    
    | 
         @@ -1,61 +1,26 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'date_period/version'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            Gem::Specification.new do | 
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "date_period"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = DatePeriod::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["MoreRon"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["more.ron.too@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.description   = "DatePeriod provides classes for date related periods."
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary       = "DatePeriod provides classes for date related periods."
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/more-ron/date_period"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
       9 
15 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
       13 
     | 
    
         
            -
               
     | 
| 
       14 
     | 
    
         
            -
              s.email = "more.ron.too@gmail.com"
         
     | 
| 
       15 
     | 
    
         
            -
              s.extra_rdoc_files = [
         
     | 
| 
       16 
     | 
    
         
            -
                "LICENSE",
         
     | 
| 
       17 
     | 
    
         
            -
                "LICENSE.txt",
         
     | 
| 
       18 
     | 
    
         
            -
                "README.md",
         
     | 
| 
       19 
     | 
    
         
            -
                "README.rdoc"
         
     | 
| 
       20 
     | 
    
         
            -
              ]
         
     | 
| 
       21 
     | 
    
         
            -
              s.files = [
         
     | 
| 
       22 
     | 
    
         
            -
                ".document",
         
     | 
| 
       23 
     | 
    
         
            -
                ".ruby-version",
         
     | 
| 
       24 
     | 
    
         
            -
                "Gemfile",
         
     | 
| 
       25 
     | 
    
         
            -
                "Gemfile.lock",
         
     | 
| 
       26 
     | 
    
         
            -
                "LICENSE",
         
     | 
| 
       27 
     | 
    
         
            -
                "LICENSE.txt",
         
     | 
| 
       28 
     | 
    
         
            -
                "README.md",
         
     | 
| 
       29 
     | 
    
         
            -
                "README.rdoc",
         
     | 
| 
       30 
     | 
    
         
            -
                "Rakefile",
         
     | 
| 
       31 
     | 
    
         
            -
                "VERSION",
         
     | 
| 
       32 
     | 
    
         
            -
                "date_period.gemspec",
         
     | 
| 
       33 
     | 
    
         
            -
                "lib/date_period.rb",
         
     | 
| 
       34 
     | 
    
         
            -
                "test/helper.rb",
         
     | 
| 
       35 
     | 
    
         
            -
                "test/test_date_period.rb"
         
     | 
| 
       36 
     | 
    
         
            -
              ]
         
     | 
| 
       37 
     | 
    
         
            -
              s.homepage = "http://github.com/more-ron/date_period"
         
     | 
| 
       38 
     | 
    
         
            -
              s.licenses = ["MIT"]
         
     | 
| 
       39 
     | 
    
         
            -
              s.require_paths = ["lib"]
         
     | 
| 
       40 
     | 
    
         
            -
              s.rubygems_version = "2.0.3"
         
     | 
| 
       41 
     | 
    
         
            -
              s.summary = "Date period"
         
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files`.split($/)
         
     | 
| 
      
 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"]
         
     | 
| 
       42 
20 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
               
     | 
| 
       44 
     | 
    
         
            -
                s.specification_version = 4
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_runtime_dependency "activesupport"
         
     | 
| 
       45 
22 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                  s.add_development_dependency(%q<rspec>, [">= 0"])
         
     | 
| 
       50 
     | 
    
         
            -
                else
         
     | 
| 
       51 
     | 
    
         
            -
                  s.add_dependency(%q<bundler>, [">= 0"])
         
     | 
| 
       52 
     | 
    
         
            -
                  s.add_dependency(%q<jeweler>, [">= 0"])
         
     | 
| 
       53 
     | 
    
         
            -
                  s.add_dependency(%q<rspec>, [">= 0"])
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
     | 
    
         
            -
              else
         
     | 
| 
       56 
     | 
    
         
            -
                s.add_dependency(%q<bundler>, [">= 0"])
         
     | 
| 
       57 
     | 
    
         
            -
                s.add_dependency(%q<jeweler>, [">= 0"])
         
     | 
| 
       58 
     | 
    
         
            -
                s.add_dependency(%q<rspec>, [">= 0"])
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.3"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "rake"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "rspec"
         
     | 
| 
       60 
26 
     | 
    
         
             
            end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
    
        data/lib/date_period.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,111 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "active_support/core_ext"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class DatePeriod::Month
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              include Comparable
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 8 
     | 
    
         
            +
                def including(datish)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  date = datish.to_date
         
     | 
| 
      
 10 
     | 
    
         
            +
                  new year: date.year, month: date.month
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def current
         
     | 
| 
      
 14 
     | 
    
         
            +
                  including Date.current
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def load(serialized_month)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  data = JSON.load serialized_month
         
     | 
| 
      
 19 
     | 
    
         
            +
                  new year: data["year"], month: data["month"]
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                def dump(month)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  JSON.dump("year" => month.year, "month" => month.month)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              attr_reader :year, :month
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def initialize(year: Date.current.year, month: Date.current.month)
         
     | 
| 
      
 30 
     | 
    
         
            +
                @year = year
         
     | 
| 
      
 31 
     | 
    
         
            +
                @month = month
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              def succ
         
     | 
| 
      
 35 
     | 
    
         
            +
                self.class.new year: year, month: month + 1
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
              alias :next :succ
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def prev
         
     | 
| 
      
 40 
     | 
    
         
            +
                self.class.new year: year, month: month - 1
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def <=>(other)
         
     | 
| 
      
 44 
     | 
    
         
            +
                [year, month] <=> [other.year, other.month]
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              def +(duration)
         
     | 
| 
      
 48 
     | 
    
         
            +
                self.class.including(first_day + Duration(duration))
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def -(duration)
         
     | 
| 
      
 52 
     | 
    
         
            +
                self.class.including(first_day - Duration(duration))
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              def date_period
         
     | 
| 
      
 56 
     | 
    
         
            +
                first_day .. ((self + 1).first_day - 1.day)
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def to_date
         
     | 
| 
      
 60 
     | 
    
         
            +
                first_day
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def eql?(other)
         
     | 
| 
      
 64 
     | 
    
         
            +
                hash == other.hash
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              def first_day
         
     | 
| 
      
 68 
     | 
    
         
            +
                Date.new(year, month, 1)
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              def last_day
         
     | 
| 
      
 72 
     | 
    
         
            +
                first_day.end_of_month
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              def date_period
         
     | 
| 
      
 76 
     | 
    
         
            +
                first_day .. last_day
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              def first_moment(zone: Time.zone)
         
     | 
| 
      
 80 
     | 
    
         
            +
                Time.use_zone(zone){ first_day.beginning_of_day }
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              def last_moment(zone: Time.zone)
         
     | 
| 
      
 84 
     | 
    
         
            +
                Time.use_zone(zone){ last_day.end_of_day }
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              def time_period
         
     | 
| 
      
 88 
     | 
    
         
            +
                first_moment .. last_moment
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              def include?(datish)
         
     | 
| 
      
 92 
     | 
    
         
            +
                datish.year == year && datish.month == month
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              def inspect
         
     | 
| 
      
 96 
     | 
    
         
            +
                first_day.strftime "%b %Y"
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              protected
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              def hash
         
     | 
| 
      
 102 
     | 
    
         
            +
                @hash ||= [self.class, year, month].hash
         
     | 
| 
      
 103 
     | 
    
         
            +
              end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              private
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              def Duration(duration)
         
     | 
| 
      
 108 
     | 
    
         
            +
                duration.kind_of?(ActiveSupport::Duration) ? duration : duration.month
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,113 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe DatePeriod::Month do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              subject(:prev_month) { described_class.new(year: 1982, month: 1) }
         
     | 
| 
      
 6 
     | 
    
         
            +
              subject(:month) { described_class.new(year: 1982, month: 2) }
         
     | 
| 
      
 7 
     | 
    
         
            +
              subject(:next_month) { described_class.new(year: 1982, month: 3) }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              describe '.including' do
         
     | 
| 
      
 10 
     | 
    
         
            +
                it { expect(DatePeriod::Month.including "1982-01-15").to eq prev_month }
         
     | 
| 
      
 11 
     | 
    
         
            +
                it { expect(DatePeriod::Month.including "1982-02-15").to eq month }
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              describe '.current' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                it { expect(DatePeriod::Month.current).to include Date.current }
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              describe '.load' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                it { expect(DatePeriod::Month.load '{"year":1982,"month":2}').to eq month }
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              describe '.dump' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                it { expect(DatePeriod::Month.dump month).to eq '{"year":1982,"month":2}' }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              describe '#first_day' do
         
     | 
| 
      
 27 
     | 
    
         
            +
                it { expect(month.first_day).to eq "1982-02-01".to_date }
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              describe '#last_day' do
         
     | 
| 
      
 31 
     | 
    
         
            +
                it { expect(month.last_day).to eq "1982-02-28".to_date }
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              describe '#date_period' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                it { expect(month.date_period).to eq ("1982-02-01".to_date .. "1982-02-28".to_date) }
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              describe '#first_moment' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                it { expect(month.first_moment).to eq "1982-02-01".to_date.beginning_of_day }
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              describe '#last_moment' do
         
     | 
| 
      
 43 
     | 
    
         
            +
                it { expect(month.last_moment).to eq "1982-02-28".to_date.end_of_day }
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              describe '#time_period' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                it { expect(month.time_period.begin).to eq (Time.use_zone(Time.zone) { "1982-02-01".to_date.beginning_of_day }) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                it { expect(month.time_period.end).to eq (Time.use_zone(Time.zone) { "1982-02-28".to_date.end_of_day }) }
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              describe '#prev' do
         
     | 
| 
      
 52 
     | 
    
         
            +
                it { expect(month.prev).to eq prev_month }
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              describe '#next' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                it { expect(month.next).to eq next_month }
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              describe '#include?' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                it { expect(month).to include "1982-02-15".to_date }
         
     | 
| 
      
 61 
     | 
    
         
            +
                it { expect(month).not_to include "1982-01-15".to_date }
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              describe '#to_date' do
         
     | 
| 
      
 65 
     | 
    
         
            +
                it { expect(month.to_date).to eq "1982-02-01".to_date }
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              describe '#date_period' do
         
     | 
| 
      
 69 
     | 
    
         
            +
                it { expect(month.date_period).to eq ("1982-02-01".to_date .. "1982-02-28".to_date) }
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              describe 'rangeability' do
         
     | 
| 
      
 73 
     | 
    
         
            +
                it { expect { prev_month .. next_month }.to_not raise_error }
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              describe 'comparability' do
         
     | 
| 
      
 77 
     | 
    
         
            +
                it { expect(month).to eq described_class.new(year: 1982, month: 2) }
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              describe 'computability' do
         
     | 
| 
      
 81 
     | 
    
         
            +
                it { expect(month + 1.month).to eq next_month }
         
     | 
| 
      
 82 
     | 
    
         
            +
                it { expect(month + 1).to eq next_month }
         
     | 
| 
      
 83 
     | 
    
         
            +
                it { expect(month - 1.month).to eq prev_month }
         
     | 
| 
      
 84 
     | 
    
         
            +
                it { expect(month - 1).to eq prev_month }
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              describe 'groupability' do
         
     | 
| 
      
 88 
     | 
    
         
            +
                let(:item_1) { double(:item, id: 1, month: DatePeriod::Month.new(year: 1982, month: 1)) }
         
     | 
| 
      
 89 
     | 
    
         
            +
                let(:item_2) { double(:item, id: 2, month: DatePeriod::Month.new(year: 1982, month: 1)) }
         
     | 
| 
      
 90 
     | 
    
         
            +
                let(:item_3) { double(:item, id: 3, month: DatePeriod::Month.new(year: 1982, month: 2)) }
         
     | 
| 
      
 91 
     | 
    
         
            +
                let(:item_4) { double(:item, id: 4, month: DatePeriod::Month.new(year: 1982, month: 2)) }
         
     | 
| 
      
 92 
     | 
    
         
            +
                let(:item_5) { double(:item, id: 5, month: DatePeriod::Month.new(year: 1982, month: 3)) }
         
     | 
| 
      
 93 
     | 
    
         
            +
                let(:item_6) { double(:item, id: 6, month: DatePeriod::Month.new(year: 1982, month: 3)) }
         
     | 
| 
      
 94 
     | 
    
         
            +
                
         
     | 
| 
      
 95 
     | 
    
         
            +
                let(:collection) {[
         
     | 
| 
      
 96 
     | 
    
         
            +
                  item_1,
         
     | 
| 
      
 97 
     | 
    
         
            +
                  item_2,
         
     | 
| 
      
 98 
     | 
    
         
            +
                  item_3,
         
     | 
| 
      
 99 
     | 
    
         
            +
                  item_4,
         
     | 
| 
      
 100 
     | 
    
         
            +
                  item_5,
         
     | 
| 
      
 101 
     | 
    
         
            +
                  item_6,
         
     | 
| 
      
 102 
     | 
    
         
            +
                ]}
         
     | 
| 
      
 103 
     | 
    
         
            +
                
         
     | 
| 
      
 104 
     | 
    
         
            +
                example {
         
     | 
| 
      
 105 
     | 
    
         
            +
                  groups = collection.group_by(&:month)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  expect(groups[DatePeriod::Month.new(year: 1982, month: 2)]).not_to include item_2
         
     | 
| 
      
 107 
     | 
    
         
            +
                  expect(groups[DatePeriod::Month.new(year: 1982, month: 2)]).to include item_3
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(groups[DatePeriod::Month.new(year: 1982, month: 2)]).to include item_4
         
     | 
| 
      
 109 
     | 
    
         
            +
                  expect(groups[DatePeriod::Month.new(year: 1982, month: 2)]).not_to include item_5
         
     | 
| 
      
 110 
     | 
    
         
            +
                }
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "date_period"
         
     | 
| 
      
 2 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 3 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # The generated `.rspec` file contains `--require spec_helper` which will cause this
         
     | 
| 
      
 5 
     | 
    
         
            +
            # file to always be loaded, without a need to explicitly require it in any files.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # Given that it is always loaded, you are encouraged to keep this file as
         
     | 
| 
      
 8 
     | 
    
         
            +
            # light-weight as possible. Requiring heavyweight dependencies from this file
         
     | 
| 
      
 9 
     | 
    
         
            +
            # will add to the boot time of your test suite on EVERY test run, even for an
         
     | 
| 
      
 10 
     | 
    
         
            +
            # individual file that may not need all of that loaded. Instead, consider making
         
     | 
| 
      
 11 
     | 
    
         
            +
            # a separate helper file that requires the additional dependencies and performs
         
     | 
| 
      
 12 
     | 
    
         
            +
            # the additional setup, and require it from the spec files that actually need it.
         
     | 
| 
      
 13 
     | 
    
         
            +
            #
         
     | 
| 
      
 14 
     | 
    
         
            +
            # The `.rspec` file also contains a few flags that are not defaults but that
         
     | 
| 
      
 15 
     | 
    
         
            +
            # users commonly want.
         
     | 
| 
      
 16 
     | 
    
         
            +
            #
         
     | 
| 
      
 17 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 18 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 19 
     | 
    
         
            +
              # rspec-expectations config goes here. You can use an alternate
         
     | 
| 
      
 20 
     | 
    
         
            +
              # assertion/expectation library such as wrong or the stdlib/minitest
         
     | 
| 
      
 21 
     | 
    
         
            +
              # assertions if you prefer.
         
     | 
| 
      
 22 
     | 
    
         
            +
              config.expect_with :rspec do |expectations|
         
     | 
| 
      
 23 
     | 
    
         
            +
                # This option will default to `true` in RSpec 4. It makes the `description`
         
     | 
| 
      
 24 
     | 
    
         
            +
                # and `failure_message` of custom matchers include text for helper methods
         
     | 
| 
      
 25 
     | 
    
         
            +
                # defined using `chain`, e.g.:
         
     | 
| 
      
 26 
     | 
    
         
            +
                # be_bigger_than(2).and_smaller_than(4).description
         
     | 
| 
      
 27 
     | 
    
         
            +
                #   # => "be bigger than 2 and smaller than 4"
         
     | 
| 
      
 28 
     | 
    
         
            +
                # ...rather than:
         
     | 
| 
      
 29 
     | 
    
         
            +
                #   # => "be bigger than 2"
         
     | 
| 
      
 30 
     | 
    
         
            +
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              # rspec-mocks config goes here. You can use an alternate test double
         
     | 
| 
      
 34 
     | 
    
         
            +
              # library (such as bogus or mocha) by changing the `mock_with` option here.
         
     | 
| 
      
 35 
     | 
    
         
            +
              config.mock_with :rspec do |mocks|
         
     | 
| 
      
 36 
     | 
    
         
            +
                # Prevents you from mocking or stubbing a method that does not exist on
         
     | 
| 
      
 37 
     | 
    
         
            +
                # a real object. This is generally recommended, and will default to
         
     | 
| 
      
 38 
     | 
    
         
            +
                # `true` in RSpec 4.
         
     | 
| 
      
 39 
     | 
    
         
            +
                mocks.verify_partial_doubles = true
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            # The settings below are suggested to provide a good initial experience
         
     | 
| 
      
 43 
     | 
    
         
            +
            # with RSpec, but feel free to customize to your heart's content.
         
     | 
| 
      
 44 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 45 
     | 
    
         
            +
              # These two settings work together to allow you to limit a spec run
         
     | 
| 
      
 46 
     | 
    
         
            +
              # to individual examples or groups you care about by tagging them with
         
     | 
| 
      
 47 
     | 
    
         
            +
              # `:focus` metadata. When nothing is tagged with `:focus`, all examples
         
     | 
| 
      
 48 
     | 
    
         
            +
              # get run.
         
     | 
| 
      
 49 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 50 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              # Limits the available syntax to the non-monkey patched syntax that is recommended.
         
     | 
| 
      
 53 
     | 
    
         
            +
              # For more details, see:
         
     | 
| 
      
 54 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
         
     | 
| 
      
 55 
     | 
    
         
            +
              #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
         
     | 
| 
      
 56 
     | 
    
         
            +
              #   - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
         
     | 
| 
      
 57 
     | 
    
         
            +
              config.disable_monkey_patching!
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              # This setting enables warnings. It's recommended, but in some cases may
         
     | 
| 
      
 60 
     | 
    
         
            +
              # be too noisy due to issues in dependencies.
         
     | 
| 
      
 61 
     | 
    
         
            +
              config.warnings = true
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              # Many RSpec users commonly either run the entire suite or an individual
         
     | 
| 
      
 64 
     | 
    
         
            +
              # file, and it's useful to allow more verbose output when running an
         
     | 
| 
      
 65 
     | 
    
         
            +
              # individual spec file.
         
     | 
| 
      
 66 
     | 
    
         
            +
              if config.files_to_run.one?
         
     | 
| 
      
 67 
     | 
    
         
            +
                # Use the documentation formatter for detailed output,
         
     | 
| 
      
 68 
     | 
    
         
            +
                # unless a formatter has already been configured
         
     | 
| 
      
 69 
     | 
    
         
            +
                # (e.g. via a command-line flag).
         
     | 
| 
      
 70 
     | 
    
         
            +
                config.default_formatter = 'doc'
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              # Print the 10 slowest examples and example groups at the
         
     | 
| 
      
 74 
     | 
    
         
            +
              # end of the spec run, to help surface which specs are running
         
     | 
| 
      
 75 
     | 
    
         
            +
              # particularly slow.
         
     | 
| 
      
 76 
     | 
    
         
            +
              config.profile_examples = 10
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 79 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 80 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 81 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 82 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              # Seed global randomization in this process using the `--seed` CLI option.
         
     | 
| 
      
 85 
     | 
    
         
            +
              # Setting this allows you to use `--seed` to deterministically reproduce
         
     | 
| 
      
 86 
     | 
    
         
            +
              # test failures related to randomization by passing the same `--seed` value
         
     | 
| 
      
 87 
     | 
    
         
            +
              # as the one that triggered the failure.
         
     | 
| 
      
 88 
     | 
    
         
            +
              Kernel.srand config.seed
         
     | 
| 
      
 89 
     | 
    
         
            +
            =end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,23 +1,23 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: date_period
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - MoreRon
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-10-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name:  
     | 
| 
      
 14 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - '>='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
19 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       20 
     | 
    
         
            -
              type: : 
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
         @@ -25,7 +25,21 @@ dependencies: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name:  
     | 
| 
      
 28 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
       29 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
45 
     | 
    
         
             
                - - '>='
         
     | 
| 
         @@ -52,31 +66,29 @@ dependencies: 
     | 
|
| 
       52 
66 
     | 
    
         
             
                - - '>='
         
     | 
| 
       53 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
     | 
    
         
            -
            description:  
     | 
| 
       56 
     | 
    
         
            -
            email: 
     | 
| 
      
 69 
     | 
    
         
            +
            description: DatePeriod provides classes for date related periods.
         
     | 
| 
      
 70 
     | 
    
         
            +
            email:
         
     | 
| 
      
 71 
     | 
    
         
            +
            - more.ron.too@gmail.com
         
     | 
| 
       57 
72 
     | 
    
         
             
            executables: []
         
     | 
| 
       58 
73 
     | 
    
         
             
            extensions: []
         
     | 
| 
       59 
     | 
    
         
            -
            extra_rdoc_files:
         
     | 
| 
       60 
     | 
    
         
            -
            - LICENSE
         
     | 
| 
       61 
     | 
    
         
            -
            - LICENSE.txt
         
     | 
| 
       62 
     | 
    
         
            -
            - README.md
         
     | 
| 
       63 
     | 
    
         
            -
            - README.rdoc
         
     | 
| 
      
 74 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
       64 
75 
     | 
    
         
             
            files:
         
     | 
| 
       65 
76 
     | 
    
         
             
            - .document
         
     | 
| 
      
 77 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 78 
     | 
    
         
            +
            - .rbenv-gemsets
         
     | 
| 
      
 79 
     | 
    
         
            +
            - .rspec
         
     | 
| 
       66 
80 
     | 
    
         
             
            - .ruby-version
         
     | 
| 
       67 
81 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       68 
     | 
    
         
            -
            - Gemfile.lock
         
     | 
| 
       69 
     | 
    
         
            -
            - LICENSE
         
     | 
| 
       70 
82 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       71 
83 
     | 
    
         
             
            - README.md
         
     | 
| 
       72 
     | 
    
         
            -
            - README.rdoc
         
     | 
| 
       73 
84 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       74 
     | 
    
         
            -
            - VERSION
         
     | 
| 
       75 
85 
     | 
    
         
             
            - date_period.gemspec
         
     | 
| 
       76 
86 
     | 
    
         
             
            - lib/date_period.rb
         
     | 
| 
       77 
     | 
    
         
            -
            -  
     | 
| 
       78 
     | 
    
         
            -
            -  
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
            - lib/date_period/month.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - lib/date_period/version.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - spec/date_period/month_spec.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            homepage: https://github.com/more-ron/date_period
         
     | 
| 
       80 
92 
     | 
    
         
             
            licenses:
         
     | 
| 
       81 
93 
     | 
    
         
             
            - MIT
         
     | 
| 
       82 
94 
     | 
    
         
             
            metadata: {}
         
     | 
| 
         @@ -99,5 +111,7 @@ rubyforge_project: 
     | 
|
| 
       99 
111 
     | 
    
         
             
            rubygems_version: 2.0.3
         
     | 
| 
       100 
112 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       101 
113 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       102 
     | 
    
         
            -
            summary:  
     | 
| 
       103 
     | 
    
         
            -
            test_files: 
     | 
| 
      
 114 
     | 
    
         
            +
            summary: DatePeriod provides classes for date related periods.
         
     | 
| 
      
 115 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 116 
     | 
    
         
            +
            - spec/date_period/month_spec.rb
         
     | 
| 
      
 117 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
    
        data/Gemfile.lock
    DELETED
    
    | 
         @@ -1,62 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            GEM
         
     | 
| 
       2 
     | 
    
         
            -
              remote: http://rubygems.org/
         
     | 
| 
       3 
     | 
    
         
            -
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                addressable (2.3.5)
         
     | 
| 
       5 
     | 
    
         
            -
                builder (3.2.2)
         
     | 
| 
       6 
     | 
    
         
            -
                diff-lcs (1.2.5)
         
     | 
| 
       7 
     | 
    
         
            -
                faraday (0.8.8)
         
     | 
| 
       8 
     | 
    
         
            -
                  multipart-post (~> 1.2.0)
         
     | 
| 
       9 
     | 
    
         
            -
                git (1.2.6)
         
     | 
| 
       10 
     | 
    
         
            -
                github_api (0.10.1)
         
     | 
| 
       11 
     | 
    
         
            -
                  addressable
         
     | 
| 
       12 
     | 
    
         
            -
                  faraday (~> 0.8.1)
         
     | 
| 
       13 
     | 
    
         
            -
                  hashie (>= 1.2)
         
     | 
| 
       14 
     | 
    
         
            -
                  multi_json (~> 1.4)
         
     | 
| 
       15 
     | 
    
         
            -
                  nokogiri (~> 1.5.2)
         
     | 
| 
       16 
     | 
    
         
            -
                  oauth2
         
     | 
| 
       17 
     | 
    
         
            -
                hashie (2.0.5)
         
     | 
| 
       18 
     | 
    
         
            -
                highline (1.6.20)
         
     | 
| 
       19 
     | 
    
         
            -
                httpauth (0.2.0)
         
     | 
| 
       20 
     | 
    
         
            -
                jeweler (1.8.8)
         
     | 
| 
       21 
     | 
    
         
            -
                  builder
         
     | 
| 
       22 
     | 
    
         
            -
                  bundler (~> 1.0)
         
     | 
| 
       23 
     | 
    
         
            -
                  git (>= 1.2.5)
         
     | 
| 
       24 
     | 
    
         
            -
                  github_api (= 0.10.1)
         
     | 
| 
       25 
     | 
    
         
            -
                  highline (>= 1.6.15)
         
     | 
| 
       26 
     | 
    
         
            -
                  nokogiri (= 1.5.10)
         
     | 
| 
       27 
     | 
    
         
            -
                  rake
         
     | 
| 
       28 
     | 
    
         
            -
                  rdoc
         
     | 
| 
       29 
     | 
    
         
            -
                json (1.8.1)
         
     | 
| 
       30 
     | 
    
         
            -
                jwt (0.1.8)
         
     | 
| 
       31 
     | 
    
         
            -
                  multi_json (>= 1.5)
         
     | 
| 
       32 
     | 
    
         
            -
                multi_json (1.8.2)
         
     | 
| 
       33 
     | 
    
         
            -
                multi_xml (0.5.5)
         
     | 
| 
       34 
     | 
    
         
            -
                multipart-post (1.2.0)
         
     | 
| 
       35 
     | 
    
         
            -
                nokogiri (1.5.10)
         
     | 
| 
       36 
     | 
    
         
            -
                oauth2 (0.9.2)
         
     | 
| 
       37 
     | 
    
         
            -
                  faraday (~> 0.8)
         
     | 
| 
       38 
     | 
    
         
            -
                  httpauth (~> 0.2)
         
     | 
| 
       39 
     | 
    
         
            -
                  jwt (~> 0.1.4)
         
     | 
| 
       40 
     | 
    
         
            -
                  multi_json (~> 1.0)
         
     | 
| 
       41 
     | 
    
         
            -
                  multi_xml (~> 0.5)
         
     | 
| 
       42 
     | 
    
         
            -
                  rack (~> 1.2)
         
     | 
| 
       43 
     | 
    
         
            -
                rack (1.5.2)
         
     | 
| 
       44 
     | 
    
         
            -
                rake (10.1.0)
         
     | 
| 
       45 
     | 
    
         
            -
                rdoc (3.12.2)
         
     | 
| 
       46 
     | 
    
         
            -
                  json (~> 1.4)
         
     | 
| 
       47 
     | 
    
         
            -
                rspec (2.14.1)
         
     | 
| 
       48 
     | 
    
         
            -
                  rspec-core (~> 2.14.0)
         
     | 
| 
       49 
     | 
    
         
            -
                  rspec-expectations (~> 2.14.0)
         
     | 
| 
       50 
     | 
    
         
            -
                  rspec-mocks (~> 2.14.0)
         
     | 
| 
       51 
     | 
    
         
            -
                rspec-core (2.14.7)
         
     | 
| 
       52 
     | 
    
         
            -
                rspec-expectations (2.14.4)
         
     | 
| 
       53 
     | 
    
         
            -
                  diff-lcs (>= 1.1.3, < 2.0)
         
     | 
| 
       54 
     | 
    
         
            -
                rspec-mocks (2.14.4)
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
            PLATFORMS
         
     | 
| 
       57 
     | 
    
         
            -
              ruby
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            DEPENDENCIES
         
     | 
| 
       60 
     | 
    
         
            -
              bundler
         
     | 
| 
       61 
     | 
    
         
            -
              jeweler
         
     | 
| 
       62 
     | 
    
         
            -
              rspec
         
     | 
    
        data/LICENSE
    DELETED
    
    | 
         @@ -1,20 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            The MIT License (MIT)
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            Copyright (c) 2013 MoreRon
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            Permission is hereby granted, free of charge, to any person obtaining a copy of
         
     | 
| 
       6 
     | 
    
         
            -
            this software and associated documentation files (the "Software"), to deal in
         
     | 
| 
       7 
     | 
    
         
            -
            the Software without restriction, including without limitation the rights to
         
     | 
| 
       8 
     | 
    
         
            -
            use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
         
     | 
| 
       9 
     | 
    
         
            -
            the Software, and to permit persons to whom the Software is furnished to do so,
         
     | 
| 
       10 
     | 
    
         
            -
            subject to the following conditions:
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
       13 
     | 
    
         
            -
            copies or substantial portions of the Software.
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
       16 
     | 
    
         
            -
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
         
     | 
| 
       17 
     | 
    
         
            -
            FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
         
     | 
| 
       18 
     | 
    
         
            -
            COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
         
     | 
| 
       19 
     | 
    
         
            -
            IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
         
     | 
| 
       20 
     | 
    
         
            -
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    DELETED
    
    | 
         @@ -1,19 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            = date_period
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            Description goes here.
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            == Contributing to date_period
         
     | 
| 
       6 
     | 
    
         
            -
             
         
     | 
| 
       7 
     | 
    
         
            -
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
         
     | 
| 
       8 
     | 
    
         
            -
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
         
     | 
| 
       9 
     | 
    
         
            -
            * Fork the project.
         
     | 
| 
       10 
     | 
    
         
            -
            * Start a feature/bugfix branch.
         
     | 
| 
       11 
     | 
    
         
            -
            * Commit and push until you are happy with your contribution.
         
     | 
| 
       12 
     | 
    
         
            -
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         
     | 
| 
       13 
     | 
    
         
            -
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            == Copyright
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            Copyright (c) 2013 MoreRon. See LICENSE.txt for
         
     | 
| 
       18 
     | 
    
         
            -
            further details.
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
    
        data/VERSION
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0.0
         
     | 
    
        data/test/helper.rb
    DELETED
    
    | 
         @@ -1,18 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'bundler'
         
     | 
| 
       3 
     | 
    
         
            -
            begin
         
     | 
| 
       4 
     | 
    
         
            -
              Bundler.setup(:default, :development)
         
     | 
| 
       5 
     | 
    
         
            -
            rescue Bundler::BundlerError => e
         
     | 
| 
       6 
     | 
    
         
            -
              $stderr.puts e.message
         
     | 
| 
       7 
     | 
    
         
            -
              $stderr.puts "Run `bundle install` to install missing gems"
         
     | 
| 
       8 
     | 
    
         
            -
              exit e.status_code
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
            require 'test/unit'
         
     | 
| 
       11 
     | 
    
         
            -
            require 'shoulda'
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
       14 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
       15 
     | 
    
         
            -
            require 'date_period'
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            class Test::Unit::TestCase
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     |