jekyll_context_inspector 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/.rubocop.yml +17 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +99 -0
- data/Rakefile +7 -0
- data/jekyll_context_inspector.gemspec +46 -0
- data/lib/jekyll_context_inspector/version.rb +5 -0
- data/lib/jekyll_context_inspector.rb +46 -0
- data/spec/jekyll_context_inspector.rb +19 -0
- data/spec/spec_helper.rb +10 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b009a78b48c3243bca2418e851bd75cce51cc081708568c8e3b073cf68c9ee6b
|
4
|
+
data.tar.gz: 8b036f1151375fcb5337230984caae7783bf07d250e7f0650977027b4d9c189f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f61f8d7d1ad741eb782d6dcc19a23e4c47a03df94e84a7429df03fd152aea837626d4ab6d4b0a3a9ade04333428f48ae9d149f5e6b6e5e2ebdebef8a3145526d
|
7
|
+
data.tar.gz: 81b88213a3a61cbd83dcf26c60d15574af323bd9d3d69b4eb956c5e3246efe5f2aa098a8aa101fd6009c26c579e47be588868b17d86d97f75d6f32f002f1c1fb
|
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,99 @@
|
|
1
|
+
`jekyll_context_inspector`
|
2
|
+
[](https://badge.fury.io/rb/jekyll_context_inspector)
|
3
|
+
===========
|
4
|
+
|
5
|
+
`jekyll_context_inspector` is a Jekyll tag plugin that displays lots of information from context for websites in development mode if `context_inspector: true` in `_config.yml`.
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
```html
|
11
|
+
<p>{% context_inspector %}</p>
|
12
|
+
```
|
13
|
+
Output is also displayed on the console.
|
14
|
+
|
15
|
+
|
16
|
+
## Additional Information
|
17
|
+
More information is available on
|
18
|
+
[Mike Slinn’s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile, within the `jekyll_plugins` group:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
group :jekyll_plugins do
|
27
|
+
gem 'jekyll_context_inspector'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle install
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install jekyll_context_inspector
|
38
|
+
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
43
|
+
|
44
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
|
47
|
+
### Build and Install Locally
|
48
|
+
To build and install this gem onto your local machine, run:
|
49
|
+
```shell
|
50
|
+
$ rake install:local
|
51
|
+
```
|
52
|
+
|
53
|
+
The following also does the same thing:
|
54
|
+
```shell
|
55
|
+
$ bundle exec rake install
|
56
|
+
jekyll_context_inspector 1.0.0 built to pkg/jekyll_context_inspector-0.1.0.gem.
|
57
|
+
jekyll_context_inspector (1.0.0) installed.
|
58
|
+
```
|
59
|
+
|
60
|
+
Examine the newly built gem:
|
61
|
+
```shell
|
62
|
+
$ gem info jekyll_context_inspector
|
63
|
+
|
64
|
+
*** LOCAL GEMS ***
|
65
|
+
|
66
|
+
jekyll_context_inspector (1.0.0)
|
67
|
+
Author: Mike Slinn
|
68
|
+
Homepage:
|
69
|
+
https://github.com/mslinn/jekyll_context_inspector
|
70
|
+
License: MIT
|
71
|
+
Installed at: /home/mslinn/.gems
|
72
|
+
|
73
|
+
Generates Jekyll logger with colored output.
|
74
|
+
```
|
75
|
+
|
76
|
+
|
77
|
+
### Build and Push to RubyGems
|
78
|
+
To release a new version,
|
79
|
+
1. Update the version number in `version.rb`.
|
80
|
+
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
81
|
+
3. Run the following:
|
82
|
+
```shell
|
83
|
+
$ bundle exec rake release
|
84
|
+
```
|
85
|
+
The above creates a git tag for the version, commits the created tag,
|
86
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
87
|
+
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
1. Fork the project
|
92
|
+
2. Create a descriptively named feature branch
|
93
|
+
3. Add your feature
|
94
|
+
4. Submit a pull request
|
95
|
+
|
96
|
+
|
97
|
+
## License
|
98
|
+
|
99
|
+
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_context_inspector/version"
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
github = "https://github.com/mslinn/jekyll_context_inspector"
|
8
|
+
|
9
|
+
spec.authors = ["Mike Slinn"]
|
10
|
+
spec.bindir = "exe"
|
11
|
+
spec.description = <<~END_OF_DESC
|
12
|
+
Provides a Jekyll tag plugin that displays lots of information from context for websites in development mode.
|
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#context_inspector"
|
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_context_inspector"
|
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 displays lots of information from context for websites in development mode."
|
34
|
+
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
35
|
+
spec.version = JekyllContextInspector::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,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "liquid"
|
4
|
+
require "jekyll_plugin_logger"
|
5
|
+
require_relative "jekyll_context_inspector/version"
|
6
|
+
|
7
|
+
module JekyllPlubinContextInspectorName
|
8
|
+
PLUGIN_NAME = "context_inspector"
|
9
|
+
end
|
10
|
+
|
11
|
+
class ContextInspector < Liquid::Tag
|
12
|
+
def render(context)
|
13
|
+
@logger = PluginMetaLogger.instance.new_logger(self)
|
14
|
+
site = context.registers[:site]
|
15
|
+
inspector_enabled = site.config["context_inspector"]
|
16
|
+
return if inspector_enabled.nil? || !inspector_enabled
|
17
|
+
|
18
|
+
mode = site.config["env"]["JEKYLL_ENV"]
|
19
|
+
return unless inspector_enabled == "force" || mode == "development"
|
20
|
+
|
21
|
+
dump_info(context)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def dump_info(context)
|
27
|
+
page = context.registers[:page]
|
28
|
+
info do
|
29
|
+
key_value_pairs = context.registers.map do |key, value|
|
30
|
+
" <code>#{key}</code> has a value with type <code>#{value.class}</code>"
|
31
|
+
end
|
32
|
+
vars = page.keys.sort.join("</code>, <code>")
|
33
|
+
<<~END_MESSAGE
|
34
|
+
context for #{page.path} is of type #{context.class}.
|
35
|
+
context.registers for #{page.path} contains the following key/value pairs:
|
36
|
+
#{key_value_pairs.join("\n")}
|
37
|
+
#{JekyllPlubinContextInspectorName::PLUGIN_NAME}: #{page.path} contains the following key/value pairs:
|
38
|
+
<p class='info'>Jekyll variables for this page are:
|
39
|
+
<code>#{vars}</code></p>
|
40
|
+
END_MESSAGE
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Liquid::Template.register_tag(JekyllPlubinContextInspectorName::PLUGIN_NAME, ContextInspector)
|
46
|
+
PluginMetaLogger.instance.info { "Loaded #{JekyllPlubinContextInspectorName::PLUGIN_NAME} v#{JekyllContextInspector::VERSION} plugin." }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require_relative "../lib/jekyll_context_inspector"
|
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
|
+
# expect(output).to eq("asdf")
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_context_inspector
|
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 displays lots of information from
|
70
|
+
context for websites in development mode.
|
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_context_inspector.gemspec
|
85
|
+
- lib/jekyll_context_inspector.rb
|
86
|
+
- lib/jekyll_context_inspector/version.rb
|
87
|
+
- spec/jekyll_context_inspector.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#context_inspector
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
allowed_push_host: https://rubygems.org
|
94
|
+
bug_tracker_uri: https://github.com/mslinn/jekyll_context_inspector/issues
|
95
|
+
changelog_uri: https://github.com/mslinn/jekyll_context_inspector/CHANGELOG.md
|
96
|
+
homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#context_inspector
|
97
|
+
source_code_uri: https://github.com/mslinn/jekyll_context_inspector
|
98
|
+
post_install_message: |2+
|
99
|
+
|
100
|
+
Thanks for installing jekyll_context_inspector!
|
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 displays lots of information from context
|
120
|
+
for websites in development mode.
|
121
|
+
test_files:
|
122
|
+
- spec/jekyll_context_inspector.rb
|
123
|
+
- spec/spec_helper.rb
|