time_difference 0.6.0.pre.activesupport42 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d41c2f733312fe79731e39b1b814bba3ba12f8d
4
- data.tar.gz: ee732324a2be9b25e187150683bd5b97975fd4b6
3
+ metadata.gz: ddbbd2776fa610f2b462a3bd34cfa053764de7c7
4
+ data.tar.gz: 60ba68aecef657121b45132068e2a196fba8ba35
5
5
  SHA512:
6
- metadata.gz: 85e019c7f393dc05b523b10cc5ec71ce1f0c8278d9944e6bb7c486a1cf86a1eb018e7e4f633911ec6e2db894ba3c1e9ecd8aced1c29cdff22acb8f6193a4d761
7
- data.tar.gz: 5c0b619fd768f1b7fb1cc22de691500cb2c1b857389efdd6c786b1d30e2b79baad642abdf44e235f9ea586e8c0ca037584efe3503e52655daecb8122442ed690
6
+ metadata.gz: 44f5a247d2c2deb2221872ec3c1406ebb78e0c82f264fc19fc079ef64a3ae7a1bbc3793790828139b3c067dfda8571c6b5d5dacc6b078eb22215413027855a90
7
+ data.tar.gz: 530f80604b653f162b6a6a170006d6bbb49e392205ca712e27a78b7761e5b54eb4368e0c0246db987490de69e9aa444a06d52dfd0862ed184c1150f2e0e48b1f
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
4
3
  - 2.2
5
4
  - 2.3
6
5
  - 2.4
@@ -8,13 +7,7 @@ rvm:
8
7
  # uncomment this line if your project needs to run something other than `rake`:
9
8
  script: bundle exec rspec spec
10
9
  gemfile:
11
- - Gemfile.activesupport32
12
- - Gemfile.activesupport42
13
-
14
- matrix:
15
- exclude:
16
- - rvm: 2.4
17
- gemfile: Gemfile.activesupport32
10
+ - Gemfile.activesupport51
18
11
 
19
12
  before_install:
20
13
  - gem install bundler
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
- gem 'activesupport', '~> 3.2'
4
+ gem 'activesupport', '~> 5.1'
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![Build Status](https://travis-ci.org/tmlee/time_difference.png)](https://travis-ci.org/tmlee/time_difference)
2
2
 
3
+ This latest version of the gem works with ActiveSupport 5.1. For prior version, check out [v0.6.x-activesupport42](https://github.com/tmlee/time_difference/tree/0.6.0-activesupport42)
4
+
3
5
  # TimeDifference
4
6
 
5
7
  TimeDifference is the missing Ruby method to calculate difference between two given time. You can do a Ruby time difference in year, month, week, day, hour, minute, and seconds.
@@ -47,12 +47,14 @@ class TimeDifference
47
47
 
48
48
  def in_general
49
49
  remaining = @time_diff
50
-
51
50
  Hash[TIME_COMPONENTS.map do |time_component|
52
- rounded_time_component = (remaining / 1.send(time_component)).floor
53
- remaining -= rounded_time_component.send(time_component)
54
-
55
- [time_component, rounded_time_component]
51
+ if remaining > 0
52
+ rounded_time_component = (remaining / 1.send(time_component).seconds).round(2).floor
53
+ remaining -= rounded_time_component.send(time_component)
54
+ [time_component, rounded_time_component]
55
+ else
56
+ [time_component, 0]
57
+ end
56
58
  end]
57
59
  end
58
60
 
@@ -78,7 +80,7 @@ class TimeDifference
78
80
  end
79
81
 
80
82
  private
81
-
83
+
82
84
  def initialize(start_time, end_time)
83
85
  start_time = time_in_seconds(start_time)
84
86
  end_time = time_in_seconds(end_time)
@@ -2,7 +2,6 @@ require 'rspec'
2
2
  require 'time_difference'
3
3
 
4
4
  RSpec.configure do |config|
5
- config.color_enabled = true
6
5
  config.formatter = 'documentation'
7
6
 
8
7
  # Configure Timezone for proper tests
@@ -40,7 +40,7 @@ describe TimeDifference do
40
40
  start_time = clazz.new(2009, 11)
41
41
  end_time = clazz.new(2011, 1)
42
42
 
43
- expect(TimeDifference.between(start_time, end_time).in_general).to eql({years: 1, months: 2, weeks: 0, days: 0, hours: 18, minutes: 0, seconds: 0})
43
+ expect(TimeDifference.between(start_time, end_time).in_general).to eql({years: 1, months: 2, weeks: 0, days: 0, hours: 0, minutes: 0, seconds: 0})
44
44
  end
45
45
  end
46
46
  end
@@ -51,7 +51,7 @@ describe TimeDifference do
51
51
  start_time = clazz.new(2009, 11)
52
52
  end_time = clazz.new(2011, 1)
53
53
 
54
- expect(TimeDifference.between(start_time, end_time).humanize).to eql("1 Year, 2 Months and 18 Hours")
54
+ expect(TimeDifference.between(start_time, end_time).humanize).to eql("1 Year and 2 Months")
55
55
  end
56
56
  end
57
57
  end
@@ -11,11 +11,11 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
12
  gem.name = "time_difference"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "0.6.0-activesupport42"
14
+ gem.version = "0.7.0"
15
15
  gem.license = 'MIT'
16
16
 
17
- gem.add_runtime_dependency('activesupport')
18
- gem.add_development_dependency('rspec', '~> 2.13.0')
17
+ gem.add_runtime_dependency('activesupport', '~> 5.1')
18
+ gem.add_development_dependency('rspec', '~> 3.7.0')
19
19
  gem.add_development_dependency('rake')
20
20
 
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_difference
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.pre.activesupport42
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TM Lee
@@ -14,30 +14,30 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.13.0
33
+ version: 3.7.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.13.0
40
+ version: 3.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -65,8 +65,7 @@ files:
65
65
  - ".travis.yml"
66
66
  - CHANGELOG.md
67
67
  - Gemfile
68
- - Gemfile.activesupport32
69
- - Gemfile.activesupport42
68
+ - Gemfile.activesupport51
70
69
  - LICENSE
71
70
  - README.md
72
71
  - Rakefile
@@ -89,12 +88,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
88
  version: '0'
90
89
  required_rubygems_version: !ruby/object:Gem::Requirement
91
90
  requirements:
92
- - - ">"
91
+ - - ">="
93
92
  - !ruby/object:Gem::Version
94
- version: 1.3.1
93
+ version: '0'
95
94
  requirements: []
96
95
  rubyforge_project:
97
- rubygems_version: 2.5.0
96
+ rubygems_version: 2.6.11
98
97
  signing_key:
99
98
  specification_version: 4
100
99
  summary: TimeDifference is the missing Ruby method to calculate difference between
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- gem 'activesupport', '~> 4.2.10'