jekyll-uj-powertools 1.7.6 → 1.7.7
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/jekyll-uj-powertools.gemspec +1 -1
- data/lib/filters/main.rb +7 -0
- 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: b2bbc8c153db266e8ef63d1eb3a5223c4c84fe099623eb2ed8c525965a4583fc
|
|
4
|
+
data.tar.gz: 404d483a3d63551ecf9cbb272b0c63afc6535050ec0b1688c4d2e176b2c8805d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6caa4c4a8e3e30d8cb8f3c92d12e1b0480a4acd724c96f8e7ee833bd58e87057612f3f00525fbd2de40b9d26343c1d4117c80cbfd69a709a3e3fa5f7287d533e
|
|
7
|
+
data.tar.gz: ed168cb35dad450d2adcad236f1810d2ffe76f0bc17d8589219758b13661b278199417cd8d3e6f1e0e18b1171664764eb4360741ffd1677f9855c8f60182910d
|
data/lib/filters/main.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Libraries
|
|
2
2
|
require "jekyll"
|
|
3
3
|
require "json"
|
|
4
|
+
require "digest"
|
|
4
5
|
|
|
5
6
|
# Filters
|
|
6
7
|
module Jekyll
|
|
@@ -49,6 +50,12 @@ module Jekyll
|
|
|
49
50
|
rand(input)
|
|
50
51
|
end
|
|
51
52
|
|
|
53
|
+
# Return a deterministic number between 0 and max (exclusive) based on input string hash
|
|
54
|
+
# Usage: {{ "some-string" | uj_hash: 1000 }} => 0-999 (always same for same input)
|
|
55
|
+
def uj_hash(input, max)
|
|
56
|
+
Digest::MD5.hexdigest(input.to_s).hex % max.to_i
|
|
57
|
+
end
|
|
58
|
+
|
|
52
59
|
# Title case
|
|
53
60
|
def uj_title_case(input)
|
|
54
61
|
input.split(' ').map(&:capitalize).join(' ')
|