jekyll-kw-shorten 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 012dee8b1fc72f257b2e457836d2b8f56cc3faac819e57fb0f29336cf3ff2436
4
- data.tar.gz: b3203689baedeeef368523c60a6bc272c74642f4348bf7dfc332665836085188
3
+ metadata.gz: 02e501c4b564c70c2b80b73ade6532272ddfc0a8b0bcf271f0e959172fd9f551
4
+ data.tar.gz: 193d395096556484947539aab6658bf287e199247001620c6ea932e36d4b4f96
5
5
  SHA512:
6
- metadata.gz: 443768121201fcbb3a56405c1d25ca797278b4178070445b5ff745113a6efc1f694aff1156f9ea6e073b553c690348eb423db86ae0154e7d4e8847792d015a04
7
- data.tar.gz: ed61ccbf42f6b92577d68f8efbc4258f884185b69866a93c93b1484dc2e10c7937177b3bc9303e6b2cdaf6993e89637270fc1e5cc89be8120fd735a5ca6442af
6
+ metadata.gz: ab37e59c44e0fde55cafce3be02ddc6d9369131e5f76e3284fb46325d9f0f7752fcd44efb87ae8ca342825a9bbb45b8ed2f7fbae706e3e28f9f8d510fa335b1d
7
+ data.tar.gz: 8f955d0924134e3d446779a6183fc4b3cade744c240971212b555eeae8cc378bb9aa63d31199a4ef7c640b7045662284aa931de0f435bfbe14143859e8cc1c83
data/README.md CHANGED
@@ -1,27 +1,113 @@
1
1
 
2
- The project `jekyll-kw-shorten` is a **[filter](https://jekyllrb.com/docs/plugins/filters/)** plug-in for a [jekyll](https://jekyllrb.com/) static page blog.
2
+ The project `jekyll-kw-shorten` is a plug-in for a [jekyll](https://jekyllrb.com/) static page blog.
3
+
4
+ It can be used as **[filter](https://jekyllrb.com/docs/plugins/filters/)** and as **[tag](https://jekyllrb.com/docs/plugins/tag/)**.
3
5
 
4
6
  It is published on [rubygems.org](https://rubygems.org/gems/jekyll-kw-shorten), the source code is hosted on [GitHub](https://github.com/n13org/jekyll-kw-shorten).
5
7
 
6
8
  ## Usage
7
9
 
8
- * {{ "txt" | shorten }}
9
- * {{ "text with spaces" | shorten }}
10
- * {{ 500 | shorten }}
11
- * {{ 777 | shorten }}
12
- * {{ 1000 | shorten }}
13
- * {{ 1200 | shorten }}
14
- * {{ 1450 | shorten }}
15
- * {{ 1777 | shorten }}
16
- * {{ 12345 | shorten }}
17
- * {{ 1000000 | shorten }}
18
- * {{ 1110000 | shorten }}
19
- * {{ 1000000000 | shorten }}
10
+ Use the filter `{{ 1234 | shorten }}` or the tag `{% shorten 1234 %}` inside your markdown blog post file to get `1.2 K`.
11
+
12
+ The plug-in supports
13
+
14
+ * positiv numbers
15
+ * negativ numbers with leading `-` or `- `.
16
+ * float numbers (when multiple dots are in the text only the part to the first will be taken)
17
+ * Text with no numbers inside will simply echoed
18
+ * Text with numbers, will be reduced to just the digits
19
+ * Show a rocket `∞ 🚀` for very huge values (>= 1000000000000)
20
+ * Float numbers will be rounded
21
+
22
+ ### Examples as Jekyll Tag
23
+
24
+ | Syntax | OK | Result |
25
+ |-------------------------------|:--:|----------|
26
+ | {% shorten "MyText" %} | ✔️ | "MyText" |
27
+ | {% shorten MyText %} | ✔️ | MyText |
28
+ | {% shorten "My43Text" %} | ✔️ | 43 |
29
+ | {% shorten "My43.56Text" %} | ✔️ | 44 |
30
+ | {% shorten "My43.56.7Text" %} | ✔️ | 44 |
31
+ | {% shorten "1234" %} | ✔️ | 1.2 K |
32
+ | {% shorten 1 %} | ✔️ | 1 |
33
+ | {% shorten -22 %} | ✔️ | -22 |
34
+ | {% shorten - 44 %} | ✔️ | -44 |
35
+ | {% shorten 1000 %} | ✔️ | 1.0 K |
36
+ | {% shorten 1000000 %} | ✔️ | 1.0 M |
37
+ | {% shorten 1000000000 %} | ✔️ | 1.0 B |
38
+ | {% shorten 1000000000000 %} | ✔️ | ∞ 🚀 |
39
+
40
+ ### Examples as Jekyll Filter
41
+
42
+ | Syntax | OK | Result |
43
+ |----------------------------------|:--:|----------|
44
+ | {{ "MyText" \| shorten }} | ✔️ | "MyText" |
45
+ | {{ MyText \| shorten }} | ❌ | |
46
+ | {{ "My43Text" \| shorten }} | ✔️ | 43 |
47
+ | {{ "My43.56Text" \| shorten }} | ✔️ | 44 |
48
+ | {{ "My43.56.7Text" \| shorten }} | ✔️ | 44 |
49
+ | {{ "1234" \| shorten }} | ✔️ | 1.2 K |
50
+ | {{ 1 \| shorten }} | ✔️ | 1 |
51
+ | {{ -22 \| shorten }} | ✔️ | -22 |
52
+ | {{ - 44 \| shorten }} | ❌ | |
53
+ | {{ 1000 \| shorten }} | ✔️ | 1.0 K |
54
+ | {{ 1000000 \| shorten }} | ✔️ | 1.0 M |
55
+ | {{ 1000000000 \| shorten }} | ✔️ | 1.0 B |
56
+ | {{ 1000000000000 \| shorten }} | ✔️ | ∞ 🚀 |
57
+
58
+ **HINT**:
59
+ The filter `{{ MyText | shorten }}` will show nothing (empty string). The filter "thinks" the MyText is a variable (with the value nil). Numbers can be used with and without quotes. Text must be wrapped in quotes.
20
60
 
21
61
  ## Installation
22
62
 
63
+ Add `jekyll-kw-shorten` plugin in your Gemfile inside the `jekyll_plugins` group.
64
+
65
+ ```ruby
66
+ group :jekyll_plugins do
67
+ ...
68
+ gem "jekyll-kw-shorten"
69
+ ...
70
+ end
71
+ ```
72
+
73
+ Run `bundle install` to install the gem and update the Gemfile.lock.
74
+
75
+ Add `jekyll-kw-shorten` to the plugins section in your site's `_config.yml`. Then [configure](#configuration) your plug-in.
76
+
77
+ ```yaml
78
+ plugins:
79
+ - jekyll-kw-shorten
80
+ ```
81
+
23
82
  ## Configuration
24
83
 
25
- ## Contribution
84
+ Add the setting to your `_config.yml` file. Details you can find in the [documentation](https://jekyllrb.com/docs/configuration/). The name of the group is `jekyll-kw-shorten`.
85
+
86
+ * **shorten_gt3_digit** will be used for numbers between 1000 and 999999. Default is `' K'`.
87
+ * **shorten_gt6_digit** will be used for numbers between 1000000 and 999999999. Default is `' M'`.
88
+ * **shorten_gt9_digit** will be used for numbers between 1000000000 and 999999999999. Default is `' B'`.
89
+
90
+ ```yaml
91
+ ...
92
+ jekyll-kw-shorten:
93
+ shorten_gt3_digit: ' K'
94
+ shorten_gt6_digit: ' M'
95
+ shorten_gt9_digit: ' B'
96
+ ...
97
+ ```
98
+
99
+ When the config values are omit then the default values are used.
26
100
 
27
101
  ## Test locally
102
+
103
+ Run linting
104
+
105
+ ```shell
106
+ bundle exec rubocop
107
+ ```
108
+
109
+ Run tests
110
+
111
+ ```shell
112
+ bundle exec rake test
113
+ ```
@@ -4,7 +4,7 @@ module Jekyll
4
4
  module KargWare
5
5
  module Shorten
6
6
  RUBYGEM_NAME = 'jekyll-kw-shorten'
7
- VERSION = '0.0.12'
7
+ VERSION = '0.1.0'
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.0.12
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Karg
@@ -25,7 +25,10 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.8'
28
- description: " A template project for jekyll plugins with some additional content\n"
28
+ description: |2
29
+ A jekyll plugin which can shorten long numbers, e.g. 1000 == 1K or 1000000 == 1M.
30
+
31
+ It can be used as [filter](https://jekyllrb.com/docs/plugins/filters/) `{{ 1234 | shorten }}` and as [tag](https://jekyllrb.com/docs/plugins/tags/) `{% shorten 1234 %}`, the result will be **1.2 K**
29
32
  email:
30
33
  - rubygems.org@n13.org
31
34
  executables: []
@@ -37,12 +40,12 @@ files:
37
40
  - lib/jekyll/KargWare/Shorten/configuration.rb
38
41
  - lib/jekyll/KargWare/Shorten/parser.rb
39
42
  - lib/jekyll/KargWare/Shorten/version.rb
40
- homepage: https://notes.n13.org/rubygems
43
+ homepage: https://n13.org/rubygems
41
44
  licenses: []
42
45
  metadata:
43
- homepage_uri: https://notes.n13.org/rubygems
44
- bug_tracker_uri: https://github.com/n13org/jekyll-plugin-template/issues
45
- source_code_uri: https://github.com/n13org/jekyll-plugin-template
46
+ homepage_uri: https://n13.org/rubygems
47
+ bug_tracker_uri: https://github.com/n13org/jekyll-kw-shorten/issues
48
+ source_code_uri: https://github.com/n13org/jekyll-kw-shorten
46
49
  post_install_message:
47
50
  rdoc_options: []
48
51
  require_paths:
@@ -61,5 +64,5 @@ requirements: []
61
64
  rubygems_version: 3.1.2
62
65
  signing_key:
63
66
  specification_version: 4
64
- summary: A template project for jekyll plugins.
67
+ summary: A jekyll plugin to shorten long numbers
65
68
  test_files: []