tago 0.6.0 → 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/Gemfile +2 -2
- data/Gemfile.lock +8 -7
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +1 -1
- data/Rakefile +1 -1
- data/lib/tago.rb +30 -7
- data/tago.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4e8598879603e55acc0cda3df629ded3ff88855eb9233895beddcefec279c87
|
|
4
|
+
data.tar.gz: 4a14e46f54c5c1dae2233bcb71876610946a10b480c1ca454b65c4a127edaba0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ebee72e43d01da91d5ac3010c990eabd53c3f904ff6a57c541176fb2bf5f314e8327bc96a7fb5e001a4357391f85a48ee5f7d6135fff03bd06179573063c9a05
|
|
7
|
+
data.tar.gz: ad26ded7b5ebd39f523bb8a447659df74f4f16588376daae0b418ac4c79ec2402d5fafa0da24df849709217870a2961f9f0c0c1ad8e4ca3aba5b7ceb43303eb6
|
data/Gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
source 'https://rubygems.org'
|
|
7
7
|
gemspec
|
|
8
8
|
|
|
9
|
-
gem 'minitest', '~>
|
|
9
|
+
gem 'minitest', '~>6.0', require: false
|
|
10
10
|
gem 'rake', '~>13.2', require: false
|
|
11
11
|
gem 'rubocop', '~>1.75', require: false
|
|
12
12
|
gem 'rubocop-minitest', '~>0.38', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -8,21 +8,22 @@ GEM
|
|
|
8
8
|
specs:
|
|
9
9
|
ast (2.4.3)
|
|
10
10
|
docile (1.4.1)
|
|
11
|
-
json (2.
|
|
11
|
+
json (2.18.0)
|
|
12
12
|
language_server-protocol (3.17.0.5)
|
|
13
13
|
lint_roller (1.1.0)
|
|
14
|
-
minitest (
|
|
14
|
+
minitest (6.0.1)
|
|
15
|
+
prism (~> 1.5)
|
|
15
16
|
parallel (1.27.0)
|
|
16
17
|
parser (3.3.10.0)
|
|
17
18
|
ast (~> 2.4.1)
|
|
18
19
|
racc
|
|
19
|
-
prism (1.
|
|
20
|
+
prism (1.6.0)
|
|
20
21
|
racc (1.8.1)
|
|
21
22
|
rainbow (3.1.1)
|
|
22
23
|
rake (13.3.1)
|
|
23
24
|
regexp_parser (2.11.3)
|
|
24
25
|
rexml (3.4.2)
|
|
25
|
-
rubocop (1.
|
|
26
|
+
rubocop (1.82.1)
|
|
26
27
|
json (~> 2.3)
|
|
27
28
|
language_server-protocol (~> 3.17.0.2)
|
|
28
29
|
lint_roller (~> 1.1.0)
|
|
@@ -30,10 +31,10 @@ GEM
|
|
|
30
31
|
parser (>= 3.3.0.2)
|
|
31
32
|
rainbow (>= 2.2.2, < 4.0)
|
|
32
33
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
33
|
-
rubocop-ast (>= 1.
|
|
34
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
34
35
|
ruby-progressbar (~> 1.7)
|
|
35
36
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
36
|
-
rubocop-ast (1.
|
|
37
|
+
rubocop-ast (1.48.0)
|
|
37
38
|
parser (>= 3.3.7.2)
|
|
38
39
|
prism (~> 1.4)
|
|
39
40
|
rubocop-minitest (0.38.2)
|
|
@@ -71,7 +72,7 @@ PLATFORMS
|
|
|
71
72
|
x86_64-linux
|
|
72
73
|
|
|
73
74
|
DEPENDENCIES
|
|
74
|
-
minitest (~>
|
|
75
|
+
minitest (~> 6.0)
|
|
75
76
|
rake (~> 13.2)
|
|
76
77
|
rubocop (~> 1.75)
|
|
77
78
|
rubocop-minitest (~> 0.38)
|
data/LICENSE.txt
CHANGED
data/LICENSES/MIT.txt
CHANGED
data/Rakefile
CHANGED
data/lib/tago.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require 'time'
|
|
@@ -8,7 +8,7 @@ require 'time'
|
|
|
8
8
|
# A new method to print time as text.
|
|
9
9
|
#
|
|
10
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
11
|
-
# Copyright:: Copyright (c) 2024-
|
|
11
|
+
# Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
12
12
|
# License:: MIT
|
|
13
13
|
class Float
|
|
14
14
|
def seconds(*args)
|
|
@@ -21,9 +21,10 @@ class Float
|
|
|
21
21
|
7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten' },
|
|
22
22
|
units: { microsecond: %w[microsecond microseconds], millisecond: %w[millisecond milliseconds],
|
|
23
23
|
second: %w[second seconds], minute: %w[minute minutes], hour: %w[hour hours], day: %w[day days],
|
|
24
|
-
week: %w[week weeks] },
|
|
24
|
+
week: %w[week weeks], month: %w[month months], year: %w[year years] },
|
|
25
25
|
short_units: {
|
|
26
|
-
microsecond: 'μs', millisecond: 'ms', second: 'sec', minute: 'min', hour: 'hr', day: 'd', week: 'wk'
|
|
26
|
+
microsecond: 'μs', millisecond: 'ms', second: 'sec', minute: 'min', hour: 'hr', day: 'd', week: 'wk',
|
|
27
|
+
month: 'mo', year: 'y'
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
}.freeze
|
|
@@ -46,9 +47,15 @@ class Float
|
|
|
46
47
|
elsif s < 7 * 24 * 60 * 60
|
|
47
48
|
val = (s / (24 * 60 * 60)).to_i
|
|
48
49
|
unit = :day
|
|
49
|
-
|
|
50
|
+
elsif s < 30 * 24 * 60 * 60
|
|
50
51
|
val = (s / (7 * 24 * 60 * 60)).to_i
|
|
51
52
|
unit = :week
|
|
53
|
+
elsif s < 365 * 24 * 60 * 60
|
|
54
|
+
val = (s / (30 * 24 * 60 * 60)).to_i
|
|
55
|
+
unit = :month
|
|
56
|
+
else
|
|
57
|
+
val = (s / (365 * 24 * 60 * 60)).to_i
|
|
58
|
+
unit = :year
|
|
52
59
|
end
|
|
53
60
|
short = args.include?(:short)
|
|
54
61
|
number_to_words = val <= 10 ? locales[:en][:numbers][val] : val.to_s
|
|
@@ -97,7 +104,7 @@ class Float
|
|
|
97
104
|
else
|
|
98
105
|
format('%<days>dd%<hours>dh', days:, hours:)
|
|
99
106
|
end
|
|
100
|
-
|
|
107
|
+
elsif s < 30 * 24 * 60 * 60
|
|
101
108
|
weeks = (s / (7 * 24 * 60 * 60)).to_i
|
|
102
109
|
days = (s / (24 * 60 * 60) % 7).to_i
|
|
103
110
|
if args.include?(:round) || args.include?(:short) || days.zero?
|
|
@@ -105,6 +112,22 @@ class Float
|
|
|
105
112
|
else
|
|
106
113
|
format('%<weeks>dw%<days>dd', weeks:, days:)
|
|
107
114
|
end
|
|
115
|
+
elsif s < 365 * 24 * 60 * 60
|
|
116
|
+
months = (s / (30 * 24 * 60 * 60)).to_i
|
|
117
|
+
weeks = ((s % (30 * 24 * 60 * 60)) / (7 * 24 * 60 * 60)).to_i
|
|
118
|
+
if args.include?(:round) || args.include?(:short) || weeks.zero?
|
|
119
|
+
format('%dmo', months)
|
|
120
|
+
else
|
|
121
|
+
format('%<months>dmo%<weeks>dw', months:, weeks:)
|
|
122
|
+
end
|
|
123
|
+
else
|
|
124
|
+
years = (s / (365 * 24 * 60 * 60)).to_i
|
|
125
|
+
months = ((s % (365 * 24 * 60 * 60)) / (30 * 24 * 60 * 60)).to_i
|
|
126
|
+
if args.include?(:round) || args.include?(:short) || months.zero?
|
|
127
|
+
format('%dy', years)
|
|
128
|
+
else
|
|
129
|
+
format('%<years>dy%<months>dmo', years:, months:)
|
|
130
|
+
end
|
|
108
131
|
end
|
|
109
132
|
end
|
|
110
133
|
end
|
|
@@ -112,7 +135,7 @@ end
|
|
|
112
135
|
# A new method to print time as text.
|
|
113
136
|
#
|
|
114
137
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
115
|
-
# Copyright:: Copyright (c) 2024-
|
|
138
|
+
# Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
116
139
|
# License:: MIT
|
|
117
140
|
class Time
|
|
118
141
|
def ago(arg = Time.now, *options)
|
data/tago.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require 'English'
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
10
10
|
s.required_ruby_version = '>=3.0'
|
|
11
11
|
s.name = 'tago'
|
|
12
|
-
s.version = '0.
|
|
12
|
+
s.version = '0.7.0'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'A new .ago() method for the Time class'
|
|
15
15
|
s.description =
|