jekyll-kw-shorten 0.2.1 → 0.2.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 +4 -4
- data/lib/jekyll/KargWare/Shorten/parser.rb +13 -20
- data/lib/jekyll/KargWare/Shorten/version.rb +1 -1
- 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: df3ee2ecf207c1b6b96184ae10437b14703d66e9a4c6535d3692c6319f560a2f
|
4
|
+
data.tar.gz: ef033ff7ca3cc1160fcea93dfca027435fc54c7b2c3f4f187523b1e380024429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a39154c789ece32ab0dee19fc3054b4b8f74d5d8379fe059e68286a90c6a1650a0623907d8f5bb623095688ab128dcd0fb8f140b7169a8a50ec759de02ffcdc
|
7
|
+
data.tar.gz: 70b3f150871a1e5decccd6615e40ecfdae3c7fa15bac9f204c7f7320d9c5472c18cbdfb3ed0a7562a695e6130944a64a37c9c84899abfb5bdd7e6954866d5192
|
@@ -10,10 +10,10 @@ module Jekyll
|
|
10
10
|
# https://stackoverflow.com/questions/33952093/how-to-allow-only-one-dot-in-regex
|
11
11
|
DIGITS_AND_SINGLE_DOT_ESCAPE_REGEXP = /(-?\s?[0-9]+(\.[0-9]+)?)/.freeze
|
12
12
|
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :config
|
14
14
|
|
15
15
|
def initialize(options = {})
|
16
|
-
@
|
16
|
+
@config = Jekyll::KargWare::Shorten::Configuration.new(options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def parse(text)
|
@@ -21,27 +21,20 @@ module Jekyll
|
|
21
21
|
|
22
22
|
return text unless Parser.number?(num)
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
num.round(0).truncate(0).to_s.rjust(5)
|
35
|
-
end
|
36
|
-
rescue StandardError => e
|
37
|
-
puts e.message
|
38
|
-
text
|
24
|
+
return '∞ 🚀' if num >= 1000000000000
|
25
|
+
|
26
|
+
if num >= 1000000000
|
27
|
+
format(num / 1000000000.0) + @config.shorten_gt9_digit
|
28
|
+
elsif num >= 1000000
|
29
|
+
format(num / 1000000.0) + @config.shorten_gt6_digit
|
30
|
+
elsif num >= 1000
|
31
|
+
format(num / 1000.0) + @config.shorten_gt3_digit
|
32
|
+
else
|
33
|
+
num.round(0).truncate(0).to_s.rjust(5)
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
def format(num)
|
37
|
+
private def format(num)
|
45
38
|
num.round(1).truncate(1).to_s
|
46
39
|
end
|
47
40
|
|