jekyll-kw-shorten 0.0.9 → 0.0.10
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-kw-shorten.rb +2 -1
- data/lib/jekyll/KargWare/Shorten/parser.rb +18 -8
- data/lib/jekyll/KargWare/Shorten/version.rb +1 -1
- 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: 68f63c1abffd9e7cadb9ce48e2b926f612b4e6ec7a40d964a9a7660631cff5fb
|
4
|
+
data.tar.gz: 319d0ba44d6f0ae50589ad2df7db45ca9798bab80db52a225bc29ba32318d967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5bd7d988b75d828a50c5733e2e843e662c58c18a3dd009c61955926c53f62fe5216fbdded3642b12d2f9648dea238392665b773e5b32e6e1002b0e86d6ee91e
|
7
|
+
data.tar.gz: 38b05260c97dda5f6e1c531cf87e815c8890d880b1a83f3edfc36d9842121a981add98eb36ac7f57863b427a1b0f975dfba4bdca9db49cbccc0fbbc7334af69f
|
data/lib/jekyll-kw-shorten.rb
CHANGED
@@ -20,7 +20,7 @@ module Jekyll
|
|
20
20
|
|
21
21
|
def initialize(tag_name, input, tokens)
|
22
22
|
super
|
23
|
-
@input = input
|
23
|
+
@input = input.to_s.strip
|
24
24
|
|
25
25
|
# raise ArgumentError, <<~MSG
|
26
26
|
# Could not use '#{input}' in tag '#{self.class.tag_name}'.
|
@@ -30,6 +30,7 @@ module Jekyll
|
|
30
30
|
|
31
31
|
def render(context)
|
32
32
|
parser = Jekyll::KargWare::Shorten::Parser.new(get_plugin_config(context))
|
33
|
+
# parser = Jekyll::KargWare::Shorten::Parser.new({})
|
33
34
|
parser.parse(@input)
|
34
35
|
end
|
35
36
|
|
@@ -14,24 +14,34 @@ module Jekyll
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def parse(text)
|
17
|
-
if
|
18
|
-
|
19
|
-
else
|
20
|
-
num = text.to_i
|
17
|
+
if Parser.is_number?(text) then
|
18
|
+
num = text.to_f
|
21
19
|
if num >= 1000000000000 then
|
22
20
|
return "∞ 🚀"
|
23
21
|
elsif num >= 1000000000 then
|
24
|
-
return (num / 1000000000.0)
|
22
|
+
return format(num / 1000000000.0) + @configuration.shorten_gt9_digit
|
25
23
|
elsif num >= 1000000 then
|
26
|
-
return (num / 1000000.0)
|
24
|
+
return format(num / 1000000.0) + @configuration.shorten_gt6_digit
|
27
25
|
elsif num >= 1000 then
|
28
|
-
return (num / 1000.0)
|
26
|
+
return format(num / 1000.0) + @configuration.shorten_gt3_digit
|
29
27
|
else
|
30
|
-
return (
|
28
|
+
return num.round(0).truncate(0).to_s.rjust(5)
|
31
29
|
end
|
30
|
+
else
|
31
|
+
return text
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
# private
|
36
|
+
|
37
|
+
def format(num)
|
38
|
+
num.round(1).truncate(1).to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.is_number? string
|
42
|
+
true if Float(string) rescue false
|
43
|
+
end
|
44
|
+
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-kw-shorten
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Karg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-12-
|
12
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|