jekyll_run 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 +79 -0
- data/Rakefile +7 -0
- data/jekyll_run.gemspec +46 -0
- data/lib/jekyll_run/version.rb +5 -0
- data/lib/jekyll_run.rb +35 -0
- data/spec/jekyll_run.rb +21 -0
- data/spec/spec_helper.rb +10 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fcf2b4160579d3201e5b404e9af50a7bd06d542ebf6ede5bfcd86db0c91f0f92
|
4
|
+
data.tar.gz: 36f813049d6c657458edf0b4442b09e27a2cb1f93972451153fbbf33ac7e9b6d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 350c8eaebe6c995d5eb0b4931d81ddea464d2a4f39ffcb88c122c2d09f05d6710cddc5391fbdb54af61bf7cb543f3b352d02166cced1f941b33e18771c097d07
|
7
|
+
data.tar.gz: 0a58a6e748b477c98e662288c3336e42693f1f669a6e762381e799af6e32ed3618d1f281b38b48733cf02669fd35fbcaa3b6e717311fc1ed4644327d89722d1c
|
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,79 @@
|
|
1
|
+
`jekyll_run`
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll_run.svg)](https://badge.fury.io/rb/jekyll_run)
|
3
|
+
===========
|
4
|
+
|
5
|
+
`jekyll_run` Jekyll tag plugin that executes a program and returns the output from STDOUT. Because the output includes the command that was executed,
|
6
|
+
and contains unselectable span tags,
|
7
|
+
this plugin is intended to be embedded within a pre tag.
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'jekyll_run'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle install
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install jekyll_run
|
25
|
+
|
26
|
+
|
27
|
+
## Additional Information
|
28
|
+
More information is available on
|
29
|
+
[Mike Slinn’s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
30
|
+
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
Install development dependencies like this:
|
37
|
+
```
|
38
|
+
$ BUNDLE_WITH="development" bundle install
|
39
|
+
```
|
40
|
+
|
41
|
+
To build and install this gem onto your local machine, run:
|
42
|
+
```shell
|
43
|
+
$ bundle exec rake install
|
44
|
+
jekyll_run 1.0.0 built to pkg/jekyll_run-0.1.0.gem.
|
45
|
+
jekyll_run (1.0.0) installed.
|
46
|
+
|
47
|
+
$ gem info jekyll_run
|
48
|
+
|
49
|
+
*** LOCAL GEMS ***
|
50
|
+
|
51
|
+
jekyll_run (1.0.0)
|
52
|
+
Author: Mike Slinn
|
53
|
+
Homepage:
|
54
|
+
https://github.com/mslinn/jekyll_run
|
55
|
+
License: MIT
|
56
|
+
Installed at: /home/mslinn/.gems
|
57
|
+
|
58
|
+
Generates Jekyll logger with colored output.
|
59
|
+
```
|
60
|
+
|
61
|
+
To release a new version,
|
62
|
+
1. Update the version number in `version.rb`.
|
63
|
+
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
64
|
+
3. Run the following:
|
65
|
+
```shell
|
66
|
+
$ bundle exec rake release
|
67
|
+
```
|
68
|
+
The above creates a git tag for the version, commits the created tag,
|
69
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
70
|
+
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll_run.
|
75
|
+
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/jekyll_run.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll_run/version"
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
github = "https://github.com/mslinn/jekyll_run"
|
8
|
+
|
9
|
+
spec.authors = ["Mike Slinn"]
|
10
|
+
spec.bindir = "exe"
|
11
|
+
spec.description = <<~END_OF_DESC
|
12
|
+
Jekyll tag plugin that executes a program and returns the output from STDOUT.
|
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#run"
|
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_run"
|
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 = "Jekyll tag plugin that executes a program and returns the output from STDOUT."
|
34
|
+
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
35
|
+
spec.version = JekyllRun::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
|
data/lib/jekyll_run.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll_plugin_logger"
|
4
|
+
require "liquid"
|
5
|
+
require_relative "jekyll_run/version"
|
6
|
+
|
7
|
+
# Jekyll tag plugin that executes a program and returns the output from STDOUT.
|
8
|
+
# Because the output includes the command that was executed,
|
9
|
+
# and is contains unselectable span tags,
|
10
|
+
# this plugin is intended to be embedded within a pre tag.
|
11
|
+
# Executes a program and returns the output from STDOUT.
|
12
|
+
class RunTag < Liquid::Tag
|
13
|
+
# Constructor.
|
14
|
+
# @param tag_name [String] is the name of the tag, which we already know.
|
15
|
+
# @param command_line [Hash, String, Liquid::Tag::Parser] the arguments from the web page.
|
16
|
+
# @param tokens [Liquid::ParseContext] tokenized command line
|
17
|
+
# @return [void]
|
18
|
+
def initialize(tag_name, command_line, tokens)
|
19
|
+
super
|
20
|
+
@command = command_line
|
21
|
+
@command = "" if @command.nil? || @command.empty?
|
22
|
+
@logger = PluginMetaLogger.instance.new_logger(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Method prescribed by the Jekyll plugin lifecycle.
|
26
|
+
# @return [String]
|
27
|
+
def render(_context)
|
28
|
+
@logger.info "Running #{@command}"
|
29
|
+
output = `#{@command}`.rstrip
|
30
|
+
"<span class='unselectable'>$ </span>#{@command}\n<span class='unselectable'>#{output}</span>"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
PluginMetaLogger.instance.info { "Loaded jekyll_run v#{JekyllRun::VERSION} plugin." }
|
35
|
+
Liquid::Template.register_tag("run", RunTag)
|
data/spec/jekyll_run.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require_relative "../lib/jekyll_run"
|
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,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_run
|
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: 'Jekyll tag plugin that executes a program and returns the output from
|
70
|
+
STDOUT.
|
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_run.gemspec
|
85
|
+
- lib/jekyll_run.rb
|
86
|
+
- lib/jekyll_run/version.rb
|
87
|
+
- spec/jekyll_run.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#run
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
allowed_push_host: https://rubygems.org
|
94
|
+
bug_tracker_uri: https://github.com/mslinn/jekyll_run/issues
|
95
|
+
changelog_uri: https://github.com/mslinn/jekyll_run/CHANGELOG.md
|
96
|
+
homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#run
|
97
|
+
source_code_uri: https://github.com/mslinn/jekyll_run
|
98
|
+
post_install_message: |2+
|
99
|
+
|
100
|
+
Thanks for installing jekyll_run!
|
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: Jekyll tag plugin that executes a program and returns the output from STDOUT.
|
120
|
+
test_files:
|
121
|
+
- spec/jekyll_run.rb
|
122
|
+
- spec/spec_helper.rb
|