chronic_duration 0.9.2 → 0.9.3
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/Gemfile +8 -0
- data/Gemfile.lock +28 -0
- data/Rakefile +24 -28
- data/VERSION +1 -1
- data/chronic_duration.gemspec +26 -16
- data/lib/chronic_duration.rb +6 -2
- data/spec/chronic_duration_spec.rb +16 -2
- metadata +57 -14
- data/.gitignore +0 -3
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: http://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                diff-lcs (1.1.2)
         | 
| 5 | 
            +
                git (1.2.5)
         | 
| 6 | 
            +
                jeweler (1.5.2)
         | 
| 7 | 
            +
                  bundler (~> 1.0.0)
         | 
| 8 | 
            +
                  git (>= 1.2.5)
         | 
| 9 | 
            +
                  rake
         | 
| 10 | 
            +
                rake (0.8.7)
         | 
| 11 | 
            +
                rcov (0.9.9)
         | 
| 12 | 
            +
                rspec (2.3.0)
         | 
| 13 | 
            +
                  rspec-core (~> 2.3.0)
         | 
| 14 | 
            +
                  rspec-expectations (~> 2.3.0)
         | 
| 15 | 
            +
                  rspec-mocks (~> 2.3.0)
         | 
| 16 | 
            +
                rspec-core (2.3.1)
         | 
| 17 | 
            +
                rspec-expectations (2.3.0)
         | 
| 18 | 
            +
                  diff-lcs (~> 1.1.2)
         | 
| 19 | 
            +
                rspec-mocks (2.3.0)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            PLATFORMS
         | 
| 22 | 
            +
              ruby
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            DEPENDENCIES
         | 
| 25 | 
            +
              bundler (~> 1.0.0)
         | 
| 26 | 
            +
              jeweler (~> 1.5.2)
         | 
| 27 | 
            +
              rcov
         | 
| 28 | 
            +
              rspec (~> 2.3.0)
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,46 +1,42 @@ | |
| 1 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
         | 
| 2 10 | 
             
            require 'rake'
         | 
| 3 11 |  | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
                gem.add_development_dependency "rspec"
         | 
| 14 | 
            -
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
              Jeweler::GemcutterTasks.new
         | 
| 17 | 
            -
            rescue LoadError
         | 
| 18 | 
            -
              puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
         | 
| 12 | 
            +
            require 'jeweler'
         | 
| 13 | 
            +
            Jeweler::Tasks.new do |gem|
         | 
| 14 | 
            +
              gem.name = "chronic_duration"
         | 
| 15 | 
            +
              gem.summary = %Q{A Ruby natural language parser for elapsed time}
         | 
| 16 | 
            +
              gem.license = "MIT"
         | 
| 17 | 
            +
              gem.description = %Q{A simple Ruby natural language parser for elapsed time. (For example, 4 hours and 30 minutes, 6 minutes 4 seconds, 3 days, etc.) Returns all results in seconds. Will return an integer unless you get tricky and need a float. (4 minutes and 13.47 seconds, for example.) The reverse can also be performed via the output method.}
         | 
| 18 | 
            +
              gem.email = "hpoydar@gmail.com"
         | 
| 19 | 
            +
              gem.homepage = "http://github.com/hpoydar/chronic_duration"
         | 
| 20 | 
            +
              gem.authors = ["hpoydar"]
         | 
| 19 21 | 
             
            end
         | 
| 22 | 
            +
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 20 23 |  | 
| 21 | 
            -
            require ' | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
              spec. | 
| 24 | 
            +
            require 'rspec/core'
         | 
| 25 | 
            +
            require 'rspec/core/rake_task'
         | 
| 26 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 27 | 
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 25 28 | 
             
            end
         | 
| 26 29 |  | 
| 27 | 
            -
             | 
| 28 | 
            -
              spec.libs << 'lib' << 'spec'
         | 
| 30 | 
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         | 
| 29 31 | 
             
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 30 32 | 
             
              spec.rcov = true
         | 
| 31 33 | 
             
            end
         | 
| 32 34 |  | 
| 33 | 
            -
            task :spec => :check_dependencies
         | 
| 34 | 
            -
             | 
| 35 35 | 
             
            task :default => :spec
         | 
| 36 36 |  | 
| 37 37 | 
             
            require 'rake/rdoctask'
         | 
| 38 38 | 
             
            Rake::RDocTask.new do |rdoc|
         | 
| 39 | 
            -
               | 
| 40 | 
            -
                version = File.read('VERSION')
         | 
| 41 | 
            -
              else
         | 
| 42 | 
            -
                version = ""
         | 
| 43 | 
            -
              end
         | 
| 39 | 
            +
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         | 
| 44 40 |  | 
| 45 41 | 
             
              rdoc.rdoc_dir = 'rdoc'
         | 
| 46 42 | 
             
              rdoc.title = "chronic_duration #{version}"
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.9. | 
| 1 | 
            +
            0.9.3
         | 
    
        data/chronic_duration.gemspec
    CHANGED
    
    | @@ -1,33 +1,34 @@ | |
| 1 1 | 
             
            # Generated by jeweler
         | 
| 2 2 | 
             
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            -
            # Instead, edit Jeweler::Tasks in Rakefile, and run  | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 4 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{chronic_duration}
         | 
| 8 | 
            -
              s.version = "0.9. | 
| 8 | 
            +
              s.version = "0.9.3"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["hpoydar"]
         | 
| 12 | 
            -
              s.date = %q{ | 
| 12 | 
            +
              s.date = %q{2011-03-29}
         | 
| 13 13 | 
             
              s.description = %q{A simple Ruby natural language parser for elapsed time. (For example, 4 hours and 30 minutes, 6 minutes 4 seconds, 3 days, etc.) Returns all results in seconds. Will return an integer unless you get tricky and need a float. (4 minutes and 13.47 seconds, for example.) The reverse can also be performed via the output method.}
         | 
| 14 14 | 
             
              s.email = %q{hpoydar@gmail.com}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
| 16 16 | 
             
                "README.rdoc"
         | 
| 17 17 | 
             
              ]
         | 
| 18 18 | 
             
              s.files = [
         | 
| 19 | 
            -
                " | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 19 | 
            +
                "Gemfile",
         | 
| 20 | 
            +
                "Gemfile.lock",
         | 
| 21 | 
            +
                "MIT-LICENSE",
         | 
| 22 | 
            +
                "README.rdoc",
         | 
| 23 | 
            +
                "Rakefile",
         | 
| 24 | 
            +
                "VERSION",
         | 
| 25 | 
            +
                "chronic_duration.gemspec",
         | 
| 26 | 
            +
                "lib/chronic_duration.rb",
         | 
| 27 | 
            +
                "lib/numerizer.rb",
         | 
| 28 | 
            +
                "spec/chronic_duration_spec.rb"
         | 
| 28 29 | 
             
              ]
         | 
| 29 30 | 
             
              s.homepage = %q{http://github.com/hpoydar/chronic_duration}
         | 
| 30 | 
            -
              s. | 
| 31 | 
            +
              s.licenses = ["MIT"]
         | 
| 31 32 | 
             
              s.require_paths = ["lib"]
         | 
| 32 33 | 
             
              s.rubygems_version = %q{1.3.7}
         | 
| 33 34 | 
             
              s.summary = %q{A Ruby natural language parser for elapsed time}
         | 
| @@ -40,12 +41,21 @@ Gem::Specification.new do |s| | |
| 40 41 | 
             
                s.specification_version = 3
         | 
| 41 42 |  | 
| 42 43 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 43 | 
            -
                  s.add_development_dependency(%q<rspec>, [" | 
| 44 | 
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 45 | 
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 46 | 
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 47 | 
            +
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         | 
| 44 48 | 
             
                else
         | 
| 45 | 
            -
                  s.add_dependency(%q<rspec>, [" | 
| 49 | 
            +
                  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 50 | 
            +
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 51 | 
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 52 | 
            +
                  s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 46 53 | 
             
                end
         | 
| 47 54 | 
             
              else
         | 
| 48 | 
            -
                s.add_dependency(%q<rspec>, [" | 
| 55 | 
            +
                s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 56 | 
            +
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 57 | 
            +
                s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 58 | 
            +
                s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 49 59 | 
             
              end
         | 
| 50 60 | 
             
            end
         | 
| 51 61 |  | 
    
        data/lib/chronic_duration.rb
    CHANGED
    
    | @@ -31,6 +31,8 @@ module ChronicDuration | |
| 31 31 |  | 
| 32 32 | 
             
                years = months = days = hours = minutes = 0
         | 
| 33 33 |  | 
| 34 | 
            +
                decimal_places = seconds.to_s.split('.').last.length if seconds.is_a?(Float)
         | 
| 35 | 
            +
             | 
| 34 36 | 
             
                if seconds >= 60
         | 
| 35 37 | 
             
                  minutes = (seconds / 60).to_i 
         | 
| 36 38 | 
             
                  seconds = seconds % 60
         | 
| @@ -86,9 +88,11 @@ module ChronicDuration | |
| 86 88 |  | 
| 87 89 | 
             
                result = []
         | 
| 88 90 | 
             
                [:years, :months, :days, :hours, :minutes, :seconds].each do |t|
         | 
| 89 | 
            -
                   | 
| 91 | 
            +
                  num = eval(t.to_s)
         | 
| 92 | 
            +
                  num = ("%.#{decimal_places}f" % num) if num.is_a?(Float) && t == :seconds 
         | 
| 93 | 
            +
                  result << humanize_time_unit( num, dividers[t], dividers[:pluralize], dividers[:keep_zero] )
         | 
| 90 94 | 
             
                end
         | 
| 91 | 
            -
             | 
| 95 | 
            +
             | 
| 92 96 | 
             
                result = result.join(joiner).squeeze(' ').strip
         | 
| 93 97 |  | 
| 94 98 | 
             
                if process
         | 
| @@ -43,8 +43,6 @@ describe ChronicDuration, '.parse' do | |
| 43 43 | 
             
                ChronicDuration.parse('12 mins 3 seconds').is_a?(Integer).should be_true
         | 
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 | 
            -
              
         | 
| 47 | 
            -
              
         | 
| 48 46 | 
             
              @exemplars.each do |k, v|
         | 
| 49 47 | 
             
                it "should properly parse a duration like #{k}" do
         | 
| 50 48 | 
             
                  ChronicDuration.parse(k).should == v
         | 
| @@ -60,6 +58,14 @@ describe ChronicDuration, '.output' do | |
| 60 58 | 
             
              end
         | 
| 61 59 |  | 
| 62 60 | 
             
              @exemplars = { 
         | 
| 61 | 
            +
                #(0) => 
         | 
| 62 | 
            +
                  #{
         | 
| 63 | 
            +
                    #:micro    => '0s',
         | 
| 64 | 
            +
                    #:short    => '0s',
         | 
| 65 | 
            +
                    #:default  => '0 secs',
         | 
| 66 | 
            +
                    #:long     => '0 seconds',
         | 
| 67 | 
            +
                    #:chrono   => '0'
         | 
| 68 | 
            +
                  #},
         | 
| 63 69 | 
             
                (60 + 20) => 
         | 
| 64 70 | 
             
                  { 
         | 
| 65 71 | 
             
                    :micro    => '1m20s',
         | 
| @@ -76,6 +82,14 @@ describe ChronicDuration, '.output' do | |
| 76 82 | 
             
                    :long     => '1 minute 20.51 seconds',
         | 
| 77 83 | 
             
                    :chrono   => '1:20.51'
         | 
| 78 84 | 
             
                  },
         | 
| 85 | 
            +
                (60 + 20.51928) => 
         | 
| 86 | 
            +
                  { 
         | 
| 87 | 
            +
                    :micro    => '1m20.51928s',
         | 
| 88 | 
            +
                    :short    => '1m 20.51928s',
         | 
| 89 | 
            +
                    :default  => '1 min 20.51928 secs',
         | 
| 90 | 
            +
                    :long     => '1 minute 20.51928 seconds',
         | 
| 91 | 
            +
                    :chrono   => '1:20.51928'
         | 
| 92 | 
            +
                  },
         | 
| 79 93 | 
             
                (4 * 3600 + 60 + 1) => 
         | 
| 80 94 | 
             
                  { 
         | 
| 81 95 | 
             
                    :micro    => '4h1m1s',
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: chronic_duration
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash: 63
         | 
| 5 4 | 
             
              prerelease: false
         | 
| 6 5 | 
             
              segments: 
         | 
| 7 6 | 
             
              - 0
         | 
| 8 7 | 
             
              - 9
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.9. | 
| 8 | 
            +
              - 3
         | 
| 9 | 
            +
              version: 0.9.3
         | 
| 11 10 | 
             
            platform: ruby
         | 
| 12 11 | 
             
            authors: 
         | 
| 13 12 | 
             
            - hpoydar
         | 
| @@ -15,23 +14,67 @@ autorequire: | |
| 15 14 | 
             
            bindir: bin
         | 
| 16 15 | 
             
            cert_chain: []
         | 
| 17 16 |  | 
| 18 | 
            -
            date:  | 
| 17 | 
            +
            date: 2011-03-29 00:00:00 -04:00
         | 
| 19 18 | 
             
            default_executable: 
         | 
| 20 19 | 
             
            dependencies: 
         | 
| 21 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 22 21 | 
             
              name: rspec
         | 
| 23 | 
            -
              prerelease: false
         | 
| 24 22 | 
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 23 | 
            +
                none: false
         | 
| 24 | 
            +
                requirements: 
         | 
| 25 | 
            +
                - - ~>
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            +
                    segments: 
         | 
| 28 | 
            +
                    - 2
         | 
| 29 | 
            +
                    - 3
         | 
| 30 | 
            +
                    - 0
         | 
| 31 | 
            +
                    version: 2.3.0
         | 
| 32 | 
            +
              type: :development
         | 
| 33 | 
            +
              prerelease: false
         | 
| 34 | 
            +
              version_requirements: *id001
         | 
| 35 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            +
              name: bundler
         | 
| 37 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 38 | 
            +
                none: false
         | 
| 39 | 
            +
                requirements: 
         | 
| 40 | 
            +
                - - ~>
         | 
| 41 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 42 | 
            +
                    segments: 
         | 
| 43 | 
            +
                    - 1
         | 
| 44 | 
            +
                    - 0
         | 
| 45 | 
            +
                    - 0
         | 
| 46 | 
            +
                    version: 1.0.0
         | 
| 47 | 
            +
              type: :development
         | 
| 48 | 
            +
              prerelease: false
         | 
| 49 | 
            +
              version_requirements: *id002
         | 
| 50 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 51 | 
            +
              name: jeweler
         | 
| 52 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 53 | 
            +
                none: false
         | 
| 54 | 
            +
                requirements: 
         | 
| 55 | 
            +
                - - ~>
         | 
| 56 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 57 | 
            +
                    segments: 
         | 
| 58 | 
            +
                    - 1
         | 
| 59 | 
            +
                    - 5
         | 
| 60 | 
            +
                    - 2
         | 
| 61 | 
            +
                    version: 1.5.2
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: *id003
         | 
| 65 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 66 | 
            +
              name: rcov
         | 
| 67 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 25 68 | 
             
                none: false
         | 
| 26 69 | 
             
                requirements: 
         | 
| 27 70 | 
             
                - - ">="
         | 
| 28 71 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            -
                    hash: 3
         | 
| 30 72 | 
             
                    segments: 
         | 
| 31 73 | 
             
                    - 0
         | 
| 32 74 | 
             
                    version: "0"
         | 
| 33 75 | 
             
              type: :development
         | 
| 34 | 
            -
               | 
| 76 | 
            +
              prerelease: false
         | 
| 77 | 
            +
              version_requirements: *id004
         | 
| 35 78 | 
             
            description: A simple Ruby natural language parser for elapsed time. (For example, 4 hours and 30 minutes, 6 minutes 4 seconds, 3 days, etc.) Returns all results in seconds. Will return an integer unless you get tricky and need a float. (4 minutes and 13.47 seconds, for example.) The reverse can also be performed via the output method.
         | 
| 36 79 | 
             
            email: hpoydar@gmail.com
         | 
| 37 80 | 
             
            executables: []
         | 
| @@ -41,7 +84,8 @@ extensions: [] | |
| 41 84 | 
             
            extra_rdoc_files: 
         | 
| 42 85 | 
             
            - README.rdoc
         | 
| 43 86 | 
             
            files: 
         | 
| 44 | 
            -
            -  | 
| 87 | 
            +
            - Gemfile
         | 
| 88 | 
            +
            - Gemfile.lock
         | 
| 45 89 | 
             
            - MIT-LICENSE
         | 
| 46 90 | 
             
            - README.rdoc
         | 
| 47 91 | 
             
            - Rakefile
         | 
| @@ -52,11 +96,11 @@ files: | |
| 52 96 | 
             
            - spec/chronic_duration_spec.rb
         | 
| 53 97 | 
             
            has_rdoc: true
         | 
| 54 98 | 
             
            homepage: http://github.com/hpoydar/chronic_duration
         | 
| 55 | 
            -
            licenses:  | 
| 56 | 
            -
             | 
| 99 | 
            +
            licenses: 
         | 
| 100 | 
            +
            - MIT
         | 
| 57 101 | 
             
            post_install_message: 
         | 
| 58 | 
            -
            rdoc_options: 
         | 
| 59 | 
            -
             | 
| 102 | 
            +
            rdoc_options: []
         | 
| 103 | 
            +
             | 
| 60 104 | 
             
            require_paths: 
         | 
| 61 105 | 
             
            - lib
         | 
| 62 106 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| @@ -64,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 64 108 | 
             
              requirements: 
         | 
| 65 109 | 
             
              - - ">="
         | 
| 66 110 | 
             
                - !ruby/object:Gem::Version 
         | 
| 67 | 
            -
                  hash:  | 
| 111 | 
            +
                  hash: -1256794380230293518
         | 
| 68 112 | 
             
                  segments: 
         | 
| 69 113 | 
             
                  - 0
         | 
| 70 114 | 
             
                  version: "0"
         | 
| @@ -73,7 +117,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 73 117 | 
             
              requirements: 
         | 
| 74 118 | 
             
              - - ">="
         | 
| 75 119 | 
             
                - !ruby/object:Gem::Version 
         | 
| 76 | 
            -
                  hash: 3
         | 
| 77 120 | 
             
                  segments: 
         | 
| 78 121 | 
             
                  - 0
         | 
| 79 122 | 
             
                  version: "0"
         | 
    
        data/.gitignore
    DELETED