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 +4 -4
- data/.travis.yml +1 -8
- data/{Gemfile.activesupport32 → Gemfile.activesupport51} +1 -1
- data/README.md +2 -0
- data/lib/time_difference.rb +8 -6
- data/spec/spec_helper.rb +0 -1
- data/spec/time_difference_spec.rb +2 -2
- data/time_difference.gemspec +3 -3
- metadata +11 -12
- data/Gemfile.activesupport42 +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddbbd2776fa610f2b462a3bd34cfa053764de7c7
|
4
|
+
data.tar.gz: 60ba68aecef657121b45132068e2a196fba8ba35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f5a247d2c2deb2221872ec3c1406ebb78e0c82f264fc19fc079ef64a3ae7a1bbc3793790828139b3c067dfda8571c6b5d5dacc6b078eb22215413027855a90
|
7
|
+
data.tar.gz: 530f80604b653f162b6a6a170006d6bbb49e392205ca712e27a78b7761e5b54eb4368e0c0246db987490de69e9aa444a06d52dfd0862ed184c1150f2e0e48b1f
|
data/.travis.yml
CHANGED
@@ -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.
|
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
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
[](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.
|
data/lib/time_difference.rb
CHANGED
@@ -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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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)
|
data/spec/spec_helper.rb
CHANGED
@@ -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:
|
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
|
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
|
data/time_difference.gemspec
CHANGED
@@ -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.
|
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', '~>
|
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.
|
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: '
|
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: '
|
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:
|
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:
|
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.
|
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:
|
93
|
+
version: '0'
|
95
94
|
requirements: []
|
96
95
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
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
|
data/Gemfile.activesupport42
DELETED