jekyll-hashsert 1.0.0
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 +7 -0
- data/Gemfile +4 -0
- data/jekyll-hashsert.gemspec +29 -0
- data/lib/jekyll-hashsert/main.rb +68 -0
- data/lib/jekyll-hashsert/version.rb +5 -0
- data/lib/jekyll-hashsert.rb +7 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e20ffbcb5ecc6c9fbd0fc909b05593cc172393ac0aceb3296d71428c465074bf
|
4
|
+
data.tar.gz: 2164ab1c48bc3c1a0f4c0edf2c34b79c38b39f2051fadb0fb7bdf9eb3d300f3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98e071b500a4acb35837e078bc4a5e8534936c0b11c68dd04be53e1a777cc26ee4e6bf54d4f7ac9acd8f08e198bcbdcca35daa462d800f9a7ffdad5d334b36f6
|
7
|
+
data.tar.gz: d26aebeba2c270499236fa69e66f38446d6fa88fa11f8cf4a202fcf77c699ecffd4f5113dde3389d4668df50dd42d8ecb1f5aabd87acf2e4660aaecafdccb972
|
data/Gemfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "jekyll-hashsert/version"
|
5
|
+
require "date"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "jekyll-hashsert"
|
9
|
+
spec.version = Jekyll::Hashsert::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.required_ruby_version = ">= 2.0.0" # Same as Jekyll
|
12
|
+
spec.date = DateTime.now.strftime("%Y-%m-%d")
|
13
|
+
spec.authors = ["Gourav Khunger"]
|
14
|
+
spec.email = ["gouravkhunger18@gmail.com"]
|
15
|
+
spec.homepage = "https://github.com/gouravkhunger/jekyll-hashsert"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.summary = "Insert random hashes of custom length into strings"
|
19
|
+
spec.description = "A jekyll plugin that generates random alphanumeric hashes of custom length and inserts them into specific positions in an input string."
|
20
|
+
|
21
|
+
spec.files = Dir["*.gemspec", "Gemfile", "lib/**/*"]
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
# Dependencies
|
25
|
+
spec.add_runtime_dependency "jekyll", ">= 3.0.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.14"
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Hashsert
|
5
|
+
|
6
|
+
def hashsert(input, symbol = "$", size = 64)
|
7
|
+
return input if !is_valid({ input: input, symbol: symbol, size: size })
|
8
|
+
|
9
|
+
while input.include?(symbol) do
|
10
|
+
input.sub! symbol, rand(36**(size + 5)).to_s(36)[0, size]
|
11
|
+
end
|
12
|
+
|
13
|
+
return input
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_valid(args = {})
|
17
|
+
input = args[:input] ||= ""
|
18
|
+
symbol = args[:symbol] ||= "$"
|
19
|
+
size = args[:size] ||= 64
|
20
|
+
testCase = args[:testCase] ||= false
|
21
|
+
|
22
|
+
if !input.is_a?(String)
|
23
|
+
log("Expected input type 'String'. Got '#{input.class}'.") if !testCase
|
24
|
+
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
if input.nil? || input == ""
|
29
|
+
log("Empty input string.") if !testCase
|
30
|
+
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
|
34
|
+
if !symbol.is_a?(String)
|
35
|
+
log("Expected symbol type 'String'. Got '#{symbol.class}'.") if !testCase
|
36
|
+
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
if symbol.size != 1
|
41
|
+
log("Symbol should only be one special character long. Got '#{symbol}'") if !testCase
|
42
|
+
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
46
|
+
if symbol.index(/[^[:alnum:]]/).nil?
|
47
|
+
log("Expected a special character for parameter symbol. Got '#{symbol}'.") if !testCase
|
48
|
+
|
49
|
+
return false
|
50
|
+
end
|
51
|
+
|
52
|
+
if !size.is_a? Integer
|
53
|
+
log("Expected an 'Integer' parameter for size parameter. Got '#{size.class}'.") if !testCase
|
54
|
+
|
55
|
+
return false
|
56
|
+
end
|
57
|
+
|
58
|
+
return true
|
59
|
+
end
|
60
|
+
|
61
|
+
def log(msg)
|
62
|
+
Jekyll.logger.error "Hashsert:", msg
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Liquid::Template.register_filter(Jekyll::Hashsert)
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-hashsert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gourav Khunger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.14'
|
55
|
+
description: A jekyll plugin that generates random alphanumeric hashes of custom length
|
56
|
+
and inserts them into specific positions in an input string.
|
57
|
+
email:
|
58
|
+
- gouravkhunger18@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- Gemfile
|
64
|
+
- jekyll-hashsert.gemspec
|
65
|
+
- lib/jekyll-hashsert.rb
|
66
|
+
- lib/jekyll-hashsert/main.rb
|
67
|
+
- lib/jekyll-hashsert/version.rb
|
68
|
+
homepage: https://github.com/gouravkhunger/jekyll-hashsert
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.0.0
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubygems_version: 3.3.11
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Insert random hashes of custom length into strings
|
91
|
+
test_files: []
|