jekyll_random_hex 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +101 -0
- data/Rakefile +7 -0
- data/jekyll_random_hex.gemspec +46 -0
- data/lib/jekyll_random_hex/version.rb +5 -0
- data/lib/jekyll_random_hex.rb +39 -0
- data/spec/jekyll_download_link.rb +21 -0
- data/spec/spec_helper.rb +10 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 926154800aea874a256a870936e5e9a4a00a81c112235fd62861532ef543ca4d
|
4
|
+
data.tar.gz: 959f39980bfb294d9246d5c7ed36fe3a83561d60ba115a2b59f10d3126a40a92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46e06064d1cd0abfbbd4e4dcc1669a6b5689a5b28562df4724752a329d3f203e45332095337e67a0ba925d59c579a5e253a2bd1c07cf5ab8356711fbfb51c197
|
7
|
+
data.tar.gz: 0e573c54ba9cf4b89c1cd06c40f6084473a9786b0d9e832e04898dbb7bb976939a877f66b721ab229d542b22991037027b86b476b44c520d0b48efb0ffe3c31d
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require: rubocop-jekyll
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-jekyll: .rubocop.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Exclude:
|
7
|
+
- vendor/**/*
|
8
|
+
- Gemfile*
|
9
|
+
- '*.gemspec' # This does nothing. Why?
|
10
|
+
NewCops: enable
|
11
|
+
TargetRubyVersion: 2.6
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 150
|
15
|
+
|
16
|
+
# Gemspec/RequireMFA:
|
17
|
+
# enable: false
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Mike Slinn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
`jekyll_random_hex`
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll_random_hex.svg)](https://badge.fury.io/rb/jekyll_random_hex)
|
3
|
+
===========
|
4
|
+
|
5
|
+
`jekyll_random_hex` is a Jekyll tag plugin that outputs a string of random hexadecimal characters of any length.
|
6
|
+
Defaults to a six-character string.
|
7
|
+
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
Example: Generate 6 random characters:
|
11
|
+
```
|
12
|
+
{{ random_hex_string }}
|
13
|
+
```
|
14
|
+
|
15
|
+
Example: generate 20 random characters. Each hex digit expands to 2 characters, so 10 hex digits yields 20 characters.
|
16
|
+
```
|
17
|
+
{{ random_hex_string 10 }}
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'jekyll_random_hex'
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle install
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install jekyll_random_hex
|
36
|
+
|
37
|
+
|
38
|
+
## Additional Information
|
39
|
+
More information is available on
|
40
|
+
[Mike Slinn’s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
41
|
+
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
46
|
+
|
47
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
### Build and Install Locally
|
52
|
+
To build and install this gem onto your local machine, run:
|
53
|
+
```shell
|
54
|
+
$ rake install:local
|
55
|
+
```
|
56
|
+
|
57
|
+
The following also does the same thing:
|
58
|
+
```shell
|
59
|
+
$ bundle exec rake install
|
60
|
+
```
|
61
|
+
|
62
|
+
Examine the newly built gem:
|
63
|
+
```shell
|
64
|
+
$ gem info jekyll_random_hex
|
65
|
+
|
66
|
+
*** LOCAL GEMS ***
|
67
|
+
|
68
|
+
jekyll_random_hex (1.0.0)
|
69
|
+
Author: Mike Slinn
|
70
|
+
Homepage:
|
71
|
+
https://github.com/mslinn/jekyll_random_hex
|
72
|
+
License: MIT
|
73
|
+
Installed at: /home/mslinn/.gems
|
74
|
+
|
75
|
+
Generates Jekyll logger with colored output.
|
76
|
+
```
|
77
|
+
|
78
|
+
|
79
|
+
### Build and Push to RubyGems
|
80
|
+
To release a new version,
|
81
|
+
1. Update the version number in `version.rb`.
|
82
|
+
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
83
|
+
3. Run the following:
|
84
|
+
```shell
|
85
|
+
$ bundle exec rake release
|
86
|
+
```
|
87
|
+
The above creates a git tag for the version, commits the created tag,
|
88
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
89
|
+
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
1. Fork the project
|
94
|
+
2. Create a descriptively named feature branch
|
95
|
+
3. Add your feature
|
96
|
+
4. Submit a pull request
|
97
|
+
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll_random_hex/version"
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
github = "https://github.com/mslinn/jekyll_random_hex"
|
8
|
+
|
9
|
+
spec.authors = ["Mike Slinn"]
|
10
|
+
spec.bindir = "exe"
|
11
|
+
spec.description = <<~END_OF_DESC
|
12
|
+
Provides a Jekyll tag plugin that outputs a string of random hexadecimal characters of any length.
|
13
|
+
END_OF_DESC
|
14
|
+
spec.email = ["mslinn@mslinn.com"]
|
15
|
+
spec.files = Dir[".rubocop.yml", "LICENSE.*", "Rakefile", "{lib,spec}/**/*", "*.gemspec", "*.md"]
|
16
|
+
spec.homepage = "https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#random_hex_string"
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.metadata = {
|
19
|
+
"allowed_push_host" => "https://rubygems.org",
|
20
|
+
"bug_tracker_uri" => "#{github}/issues",
|
21
|
+
"changelog_uri" => "#{github}/CHANGELOG.md",
|
22
|
+
"homepage_uri" => spec.homepage,
|
23
|
+
"source_code_uri" => github,
|
24
|
+
}
|
25
|
+
spec.name = "jekyll_random_hex"
|
26
|
+
spec.post_install_message = <<~END_MESSAGE
|
27
|
+
|
28
|
+
Thanks for installing #{spec.name}!
|
29
|
+
|
30
|
+
END_MESSAGE
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
spec.required_ruby_version = ">= 2.6.0"
|
33
|
+
spec.summary = "Provides a Jekyll tag plugin that outputs a string of random hexadecimal characters of any length."
|
34
|
+
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
35
|
+
spec.version = JekyllRandomHex::VERSION
|
36
|
+
|
37
|
+
spec.add_dependency "jekyll", ">= 3.5.0"
|
38
|
+
spec.add_dependency "jekyll_plugin_logger"
|
39
|
+
|
40
|
+
spec.add_development_dependency "debase"
|
41
|
+
# spec.add_development_dependency "rubocop-jekyll"
|
42
|
+
# spec.add_development_dependency "rubocop-rake"
|
43
|
+
# spec.add_development_dependency "rubocop-rspec"
|
44
|
+
spec.add_development_dependency "ruby-debug-ide"
|
45
|
+
end
|
46
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll_plugin_logger"
|
4
|
+
require "liquid"
|
5
|
+
require "securerandom"
|
6
|
+
require_relative "jekyll_random_hex/version"
|
7
|
+
|
8
|
+
module JekyllPluginRandomNumberTagName
|
9
|
+
PLUGIN_NAME = "random_hex_string"
|
10
|
+
end
|
11
|
+
|
12
|
+
class RandomNumberTag < Liquid::Tag
|
13
|
+
# Called by Jekyll only once to register the module.
|
14
|
+
# @param tag_name [String] Describe this parameter's purpose
|
15
|
+
# @param text [String] Describe this parameter's purpose
|
16
|
+
# @param context [String] Describe this parameter's purpose
|
17
|
+
# @return [String, nil] Describe the return value
|
18
|
+
def initialize(tag_name, text, context)
|
19
|
+
super
|
20
|
+
text.to_s.strip!
|
21
|
+
if text.empty?
|
22
|
+
@n = 6
|
23
|
+
else
|
24
|
+
tokens = text.split
|
25
|
+
abort "random_hex_string error - more than one token was provided: '#{text}'" if tokens.length > 1
|
26
|
+
not_integer = !Integer(text, :exception => false)
|
27
|
+
abort "random_hex_string error: '#{text}' is not a valid integer" if not_integer
|
28
|
+
@n = text.to_i
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def render(_)
|
33
|
+
SecureRandom.hex(@n)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
PluginMetaLogger.instance.info { "Loaded #{JekyllPluginRandomNumberTagName::PLUGIN_NAME} v#{JekyllRandomHex::VERSION} plugin." }
|
38
|
+
|
39
|
+
Liquid::Template.register_tag(JekyllPluginRandomNumberTagName::PLUGIN_NAME, RandomNumberTag)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require_relative "../lib/jekyll_random_hex"
|
5
|
+
|
6
|
+
RSpec.describe(Jekyll) do
|
7
|
+
include Jekyll
|
8
|
+
|
9
|
+
let(:config) { instance_double("Configuration") }
|
10
|
+
let(:context) {
|
11
|
+
context_ = instance_double("Liquid::Context")
|
12
|
+
context_.config = config
|
13
|
+
context_
|
14
|
+
}
|
15
|
+
|
16
|
+
it "is created properly" do
|
17
|
+
run_tag = RunTag.new("run", "echo asdf")
|
18
|
+
output = run_tag.render(context)
|
19
|
+
expect(output).to eq("asdf")
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_random_hex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Slinn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-25 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.5.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.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jekyll_plugin_logger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debase
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-debug-ide
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: 'Provides a Jekyll tag plugin that outputs a string of random hexadecimal
|
70
|
+
characters of any length.
|
71
|
+
|
72
|
+
'
|
73
|
+
email:
|
74
|
+
- mslinn@mslinn.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".rubocop.yml"
|
80
|
+
- CHANGELOG.md
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- jekyll_random_hex.gemspec
|
85
|
+
- lib/jekyll_random_hex.rb
|
86
|
+
- lib/jekyll_random_hex/version.rb
|
87
|
+
- spec/jekyll_download_link.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#random_hex_string
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
allowed_push_host: https://rubygems.org
|
94
|
+
bug_tracker_uri: https://github.com/mslinn/jekyll_random_hex/issues
|
95
|
+
changelog_uri: https://github.com/mslinn/jekyll_random_hex/CHANGELOG.md
|
96
|
+
homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#random_hex_string
|
97
|
+
source_code_uri: https://github.com/mslinn/jekyll_random_hex
|
98
|
+
post_install_message: |2+
|
99
|
+
|
100
|
+
Thanks for installing jekyll_random_hex!
|
101
|
+
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.6.0
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.1.4
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Provides a Jekyll tag plugin that outputs a string of random hexadecimal
|
120
|
+
characters of any length.
|
121
|
+
test_files:
|
122
|
+
- spec/jekyll_download_link.rb
|
123
|
+
- spec/spec_helper.rb
|