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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d36305251ad0bc1150e99c902682c9c73b65afe4f816d4a86d15736112f196cc
4
- data.tar.gz: 5164f0b8763c5a53ec0de2856f389d85769ad3ced8c6d65c380056fcf8e6ff74
3
+ metadata.gz: df3ee2ecf207c1b6b96184ae10437b14703d66e9a4c6535d3692c6319f560a2f
4
+ data.tar.gz: ef033ff7ca3cc1160fcea93dfca027435fc54c7b2c3f4f187523b1e380024429
5
5
  SHA512:
6
- metadata.gz: 9ebeae46e07ae73f34acc940cbbdd275abec21543dfee39c9f01365ba2b033ed712700a13519c227b2f082b84cd3fa1334f479282d9ebf5f0e5371fbb8904823
7
- data.tar.gz: bd09589257f177bc1259c3b490b2ed54d8c676285effd4d58c0c5b65f432e92ce83e3415d54e66aad224e54a5b22f17ff368fba6eed3a486522d59588224d692
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 :configuration
13
+ attr_reader :config
14
14
 
15
15
  def initialize(options = {})
16
- @configuration = Jekyll::KargWare::Shorten::Configuration.new(options)
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
- begin
25
- if num >= 1000000000000
26
- '∞ 🚀'
27
- elsif num >= 1000000000
28
- format(num / 1000000000.0) + @configuration.shorten_gt9_digit
29
- elsif num >= 1000000
30
- format(num / 1000000.0) + @configuration.shorten_gt6_digit
31
- elsif num >= 1000
32
- format(num / 1000.0) + @configuration.shorten_gt3_digit
33
- else
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
- # private
43
-
44
- def format(num)
37
+ private def format(num)
45
38
  num.round(1).truncate(1).to_s
46
39
  end
47
40
 
@@ -4,7 +4,7 @@ module Jekyll
4
4
  module KargWare
5
5
  module Shorten
6
6
  RUBYGEM_NAME = 'jekyll-kw-shorten'
7
- VERSION = '0.2.1'
7
+ VERSION = '0.2.2'
8
8
  end
9
9
  end
10
10
  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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Karg