jenna_time 0.1 → 0.1.2

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: e3c2f2346a27a8505e941c6b7e0b228dde7b8144
4
- data.tar.gz: 8282c541b306470e29d1d3800502d49dc75f190c
3
+ metadata.gz: 1ce6c79bb1913ebe6ef6638ebdd4fe86443f3e30
4
+ data.tar.gz: 5fc2545e368a7d5ec5e00a94ce0b841a975a0c6e
5
5
  SHA512:
6
- metadata.gz: 7181552ea07f88be1399103741e03fc3e8001b457460969f18f0fd61bdbb6694357cca05f23cab04f23b7d97c58608815a6784a7f3b26f32260cf47e5e5c9113
7
- data.tar.gz: 2c26f042c7ff11e14d8401281dc1524c1d394fea623e6de1811db6fde2484d0a9aa6c1f7ecc491552dbd05d686cd6999ab7adf73b397af6943cb6f2447cf9d08
6
+ metadata.gz: 8308a8daa320c0c130f6a7d3e84108b7c43274533debd6b876362ad7da1c3a58b6dc2fbc17bb434d96d7be87d955ba56dacf406d536a6bc9dc044cb700e9ca1d
7
+ data.tar.gz: 40ffa0599fddfabf9fd1565761191e4e0c05957ba671a82a57ac6938df9f1a413fc00a7d5f2d31f5e1e8739e6a85817c4f3fea114c0a24567227c498ed6fd213
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 BBC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require 'date'
3
+ include ActionView::Helpers::DateHelper
4
+
5
+ describe "Time duration testing" do
6
+ it "Accurately describes time at 0 seconds" do
7
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
8
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 0)
9
+ expect(JennaTime::duration(starttime,endtime)).to eq('')
10
+ end
11
+ it "Accurately describes time at -1 seconds" do
12
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 1)
13
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 0)
14
+ expect(JennaTime::duration(starttime,endtime)).to eq('-1s')
15
+ end
16
+ it "Accurately describes time at -1m" do
17
+ starttime = DateTime.new(2016, 6, 10, 0, 1, 0)
18
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 0)
19
+ expect(JennaTime::duration(starttime,endtime)).to eq('-1m')
20
+ end
21
+ it "Accurately describes time at -20m" do
22
+ starttime = DateTime.new(2016, 6, 10, 0, 20, 0)
23
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 0)
24
+ expect(JennaTime::duration(starttime,endtime)).to eq('-20m')
25
+ end
26
+ it "Accurately describes time at 4 seconds" do
27
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
28
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 4)
29
+ expect(JennaTime::duration(starttime,endtime)).to eq('4s')
30
+ end
31
+ it "Accurately describes time 6 seconds" do
32
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
33
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 6)
34
+ expect(JennaTime::duration(starttime,endtime)).to eq('6s')
35
+ end
36
+ it "Accurately describes time at 20 seconds" do
37
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
38
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 20)
39
+ expect(JennaTime::duration(starttime,endtime)).to eq('20s')
40
+ end
41
+ it "Accurately describes time at 50 seconds" do
42
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
43
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 50)
44
+ expect(JennaTime::duration(starttime,endtime)).to eq('50s')
45
+ end
46
+ it "Accurately describes time at 4 minutes" do
47
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
48
+ endtime = DateTime.new(2016, 6, 10, 0, 4, 0)
49
+ expect(JennaTime::duration(starttime,endtime)).to eq('4m')
50
+ end
51
+ it "Accurately describes time at 1 hour" do
52
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
53
+ endtime = DateTime.new(2016, 6, 10, 1, 0, 0)
54
+ expect(JennaTime::duration(starttime,endtime)).to eq('~1h')
55
+ end
56
+ it "Accurately describes time at -1 hour" do
57
+ starttime = DateTime.new(2016, 6, 10, 1, 0, 0)
58
+ endtime = DateTime.new(2016, 6, 10, 0, 0, 0)
59
+ expect(JennaTime::duration(starttime,endtime)).to eq('~-1h')
60
+ end
61
+ it "Accurately describes time at 1 day 1 hour" do
62
+ starttime = DateTime.new(2016, 6, 10, 0, 0, 0)
63
+ endtime = DateTime.new(2016, 6, 11, 1, 1, 0)
64
+ expect(JennaTime::duration(starttime,endtime)).to eq('1d')
65
+ end
66
+ it "Accurately describes time at 29 days" do
67
+ starttime = DateTime.new(2016, 6, 1, 0, 0, 0)
68
+ endtime = DateTime.new(2016, 6, 30, 0, 0, 0)
69
+ expect(JennaTime::duration(starttime,endtime)).to eq('29d')
70
+ end
71
+ it "Accurately describes time at 2 months" do
72
+ starttime = DateTime.new(2015, 6, 1, 0, 0, 0)
73
+ endtime = DateTime.new(2015, 8, 1, 0, 0, 0)
74
+ expect(JennaTime::duration(starttime,endtime)).to eq('2mo')
75
+ end
76
+ it "Accurately describes time at about 2 months" do
77
+ starttime = DateTime.new(2015, 6, 1, 0, 0, 0)
78
+ endtime = DateTime.new(2015, 8, 2, 0, 0, 0)
79
+ expect(JennaTime::duration(starttime,endtime)).to eq('2mo')
80
+ end
81
+ it "Accurately describes time at -2 months" do
82
+ starttime = DateTime.new(2015, 8, 1, 0, 0, 0)
83
+ endtime = DateTime.new(2015, 6, 1, 0, 0, 0)
84
+ expect(JennaTime::duration(starttime,endtime)).to eq('-2mo')
85
+ end
86
+ it "Accurately describes time at 1 year 2 months" do
87
+ starttime = DateTime.new(2015, 2, 2, 5, 0, 0)
88
+ endtime = DateTime.new(2016, 8, 3, 5, 0, 0)
89
+ expect(JennaTime::duration(starttime,endtime)).to eq('1y')
90
+ end
91
+ it "Accurately describes time at 2 year 1 months" do
92
+ starttime = DateTime.new(2013, 1, 2, 1, 1, 1)
93
+ endtime = DateTime.new(2015, 2, 2, 1, 1, 1)
94
+ expect(JennaTime::duration(starttime,endtime)).to eq('~2y')
95
+ end
96
+ it "Accurately describes time at 5 year 3 months" do
97
+ starttime = DateTime.new(2010, 8, 2, 6, 6, 6)
98
+ endtime = DateTime.new(2015, 6, 2, 0, 0, 0)
99
+ expect(JennaTime::duration(starttime,endtime)).to eq('~5y')
100
+ end
101
+ it "Accurately describes time at zero duration using default argument" do
102
+ starttime = Time.now
103
+ expect(JennaTime::duration(starttime)).to eq('')
104
+ end
105
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift('./lib/')
2
+
3
+ require 'jenna_time'
4
+ include JennaTime
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenna_time
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BBC
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 4.2.6
21
+ version: 4.2.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 4.2.6
28
+ version: 4.2.4
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -48,8 +48,12 @@ executables: []
48
48
  extensions: []
49
49
  extra_rdoc_files: []
50
50
  files:
51
+ - Gemfile
52
+ - LICENSE
51
53
  - README.md
52
54
  - lib/jenna_time.rb
55
+ - spec/jenna_time.rb
56
+ - spec/spec_helper.rb
53
57
  homepage: https://github.com/bbc/jenna_time
54
58
  licenses:
55
59
  - MIT