tago 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -12
- data/lib/tago.rb +13 -6
- data/tago.gemspec +1 -1
- data/test/test_tago.rb +13 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0127fd10025c451f556575af7705a2956defe95bca254d3c6e15fd340b23c0b1
|
4
|
+
data.tar.gz: 00e85043722bb7b4a1303954ecd6df39f8b3bd001090cfe61d14235b3b0bfdd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec9090a17889ec2cb4ebbf66323ccf678bcd668c82320731bf1c00f23a1fb5d348f76c50f16d03ff0967ae8ffae99340b1ed6f9ce08e7488914a0b6ef5647552
|
7
|
+
data.tar.gz: c84b2694de35f985e1150d5464c186ac61c3b6155ff2ba0a7e97a72cbab5945dffdb2d8363ca992d423c96308756fba7964454516afa7125e052d1b81e4b709e
|
data/Gemfile
CHANGED
@@ -26,7 +26,7 @@ gemspec
|
|
26
26
|
gem 'minitest', '5.23.1', require: false
|
27
27
|
gem 'rake', '13.2.1', require: false
|
28
28
|
gem 'rubocop', '1.64.1', require: false
|
29
|
-
gem 'rubocop-rspec', '
|
29
|
+
gem 'rubocop-rspec', '3.0.1', require: false
|
30
30
|
gem 'simplecov', '0.22.0', require: false
|
31
31
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
32
32
|
gem 'yard', '0.9.36', require: false
|
data/Gemfile.lock
CHANGED
@@ -34,17 +34,8 @@ GEM
|
|
34
34
|
unicode-display_width (>= 2.4.0, < 3.0)
|
35
35
|
rubocop-ast (1.31.3)
|
36
36
|
parser (>= 3.3.1.0)
|
37
|
-
rubocop-
|
38
|
-
rubocop (~> 1.
|
39
|
-
rubocop-factory_bot (2.26.0)
|
40
|
-
rubocop (~> 1.41)
|
41
|
-
rubocop-rspec (2.31.0)
|
42
|
-
rubocop (~> 1.40)
|
43
|
-
rubocop-capybara (~> 2.17)
|
44
|
-
rubocop-factory_bot (~> 2.22)
|
45
|
-
rubocop-rspec_rails (~> 2.28)
|
46
|
-
rubocop-rspec_rails (2.29.0)
|
47
|
-
rubocop (~> 1.40)
|
37
|
+
rubocop-rspec (3.0.1)
|
38
|
+
rubocop (~> 1.61)
|
48
39
|
ruby-progressbar (1.13.0)
|
49
40
|
simplecov (0.22.0)
|
50
41
|
docile (~> 1.1)
|
@@ -69,7 +60,7 @@ DEPENDENCIES
|
|
69
60
|
minitest (= 5.23.1)
|
70
61
|
rake (= 13.2.1)
|
71
62
|
rubocop (= 1.64.1)
|
72
|
-
rubocop-rspec (=
|
63
|
+
rubocop-rspec (= 3.0.1)
|
73
64
|
simplecov (= 0.22.0)
|
74
65
|
simplecov-cobertura (= 2.1.0)
|
75
66
|
tago!
|
data/lib/tago.rb
CHANGED
@@ -35,16 +35,23 @@ class Time
|
|
35
35
|
format('%dμs', s * 1000 * 1000)
|
36
36
|
elsif s < 1
|
37
37
|
format('%dms', s * 1000)
|
38
|
-
elsif s <
|
39
|
-
format('
|
38
|
+
elsif s < 10
|
39
|
+
ms = format('%03d', s * 1000 % 1000)
|
40
|
+
if ms == '000'
|
41
|
+
format('%ds', s)
|
42
|
+
else
|
43
|
+
format('%<sec>ds%<msec>sms', sec: s, msec: ms)
|
44
|
+
end
|
45
|
+
elsif s < 100
|
46
|
+
format('%ds', s)
|
40
47
|
elsif s < 60 * 60
|
41
|
-
format('
|
48
|
+
format('%<mins>dm%<secs>ds', mins: s / 60, secs: s % 60)
|
42
49
|
elsif s < 24 * 60 * 60
|
43
|
-
format('
|
50
|
+
format('%<hours>dh%<mins>dm', hours: s / (60 * 60), mins: (s % (60 * 60)) / 60)
|
44
51
|
elsif s < 7 * 24 * 60 * 60
|
45
|
-
format('
|
52
|
+
format('%<days>dd%<hours>dh', days: s / (24 * 60 * 60), hours: (s % (24 * 60 * 60)) / (60 * 60))
|
46
53
|
else
|
47
|
-
format('
|
54
|
+
format('%<weeks>dw%<days>dd', weeks: s / (7 * 24 * 60 * 60), days: s % (7 * 24 * 60 * 60) / (24 * 60 * 60))
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
data/tago.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
28
28
|
s.required_ruby_version = '>=3.0'
|
29
29
|
s.name = 'tago'
|
30
|
-
s.version = '0.0.
|
30
|
+
s.version = '0.0.2'
|
31
31
|
s.license = 'MIT'
|
32
32
|
s.summary = 'A new .ago() method for the Time class'
|
33
33
|
s.description =
|
data/test/test_tago.rb
CHANGED
@@ -31,20 +31,23 @@ class TestTago < Minitest::Test
|
|
31
31
|
def test_simple_printing
|
32
32
|
t = Time.now
|
33
33
|
assert_equal('14ms', (t - 0.014).ago(t))
|
34
|
-
assert_equal('
|
35
|
-
assert_equal('
|
36
|
-
assert_equal('
|
37
|
-
assert_equal('
|
38
|
-
assert_equal('
|
34
|
+
assert_equal('1s', (t - 1).ago(t))
|
35
|
+
assert_equal('1s350ms', (t - 1.35).ago(t))
|
36
|
+
assert_equal('67s', (t - 67).ago(t))
|
37
|
+
assert_equal('4m5s', (t - 245).ago(t))
|
38
|
+
assert_equal('13h18m', (t - (13.3 * 60 * 60)).ago(t))
|
39
|
+
assert_equal('5d0h', (t - (5 * 24 * 60 * 60)).ago(t))
|
40
|
+
assert_equal('5d7h', (t - (5.3 * 24 * 60 * 60)).ago(t))
|
41
|
+
assert_equal('22w1d', (t - (155 * 24 * 60 * 60)).ago(t))
|
39
42
|
end
|
40
43
|
|
41
44
|
def test_inverse
|
42
45
|
t = Time.now
|
43
46
|
assert_equal('14ms', (t + 0.014).ago(t))
|
44
|
-
assert_equal('
|
45
|
-
assert_equal('
|
46
|
-
assert_equal('
|
47
|
-
assert_equal('
|
48
|
-
assert_equal('
|
47
|
+
assert_equal('1s', (t + 1).ago(t))
|
48
|
+
assert_equal('67s', (t + 67).ago(t))
|
49
|
+
assert_equal('13h0m', (t + (13 * 60 * 60)).ago(t))
|
50
|
+
assert_equal('5d0h', (t + (5 * 24 * 60 * 60)).ago(t))
|
51
|
+
assert_equal('22w1d', (t + (155 * 24 * 60 * 60)).ago(t))
|
49
52
|
end
|
50
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This simple gem adds a new supplementary method .ago() to the existing
|
14
14
|
class Time, thus making logging more convenient
|