jekyll_plugin_support 0.1.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/Rakefile +0 -2
- data/jekyll_plugin_support.gemspec +4 -8
- data/lib/jekyll_plugin_support/version.rb +1 -3
- data/lib/jekyll_plugin_support.rb +35 -3
- data/lib/jekyll_plugin_support_helper.rb +16 -3
- data/lib/jekyll_plugin_support_spec_support.rb +0 -2
- data/spec/{jekyll_plugin_support_spec.rb → jekyll_block_plugin_support_spec.rb} +1 -3
- data/spec/jekyll_tag_plugin_support_spec.rb +41 -0
- data/spec/spec_helper.rb +0 -2
- metadata +62 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a564d99fd3a1f1ec146bc48a9ad2afbb77c9d35b3af011930e36618c29e15b4
|
4
|
+
data.tar.gz: 4888e9972bfad0307f2391079f5a815ea4ffc2588d570738362b310220be2a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 485072f986cb15a89b0b70070b992b73e16e35bdea8003e82a770fed2918ab21f70470314beb65ca4b08343db5b41fd9237a99e686d06d1619d13502ed1e9f49
|
7
|
+
data.tar.gz: '0780bed92c05b1351cb67a9859e7d25c0f96c57d9cd7a3ee1b5f9e6678dde11ef72f7e4b0623f1d5143d9905a357e252fa641e38fbea1d147e0399cf38051bae'
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
[](https://badge.fury.io/rb/jekyll_plugin_support)
|
3
3
|
===========
|
4
4
|
|
5
|
-
`
|
6
|
-
At present only Jekyll
|
5
|
+
`Jekyll_plugin_support` is a Ruby gem that facilitates writing and testing Jekyll plugins.
|
6
|
+
At present, only Jekyll tags and blocks are supported.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative 'lib/jekyll_plugin_support/version'
|
4
2
|
|
5
|
-
# rubocop:disable Metrics/BlockLength
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
github = 'https://github.com/mslinn/jekyll_plugin_support'
|
8
5
|
|
@@ -40,11 +37,10 @@ Gem::Specification.new do |spec|
|
|
40
37
|
spec.add_dependency 'jekyll_plugin_logger'
|
41
38
|
spec.add_dependency 'key-value-parser'
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
spec.add_development_dependency 'debase'
|
41
|
+
spec.add_development_dependency 'rspec-match_ignoring_whitespace'
|
45
42
|
# spec.add_development_dependency 'rubocop-jekyll'
|
46
|
-
|
43
|
+
spec.add_development_dependency 'rubocop-rake'
|
47
44
|
spec.add_development_dependency 'rubocop-rspec'
|
48
|
-
|
45
|
+
spec.add_development_dependency 'ruby-debug-ide'
|
49
46
|
end
|
50
|
-
# rubocop:enable Metrics/BlockLength
|
@@ -1,12 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'jekyll'
|
4
2
|
require 'jekyll_plugin_logger'
|
5
3
|
require_relative 'jekyll_plugin_support_helper'
|
6
4
|
require_relative 'jekyll_plugin_support/version'
|
7
5
|
|
8
6
|
# @author Copyright 2022 Michael Slinn
|
9
|
-
# @license SPDX-License-Identifier: Apache-2.0
|
7
|
+
# @license SPDX-License-Identifier: Apache-2.0``
|
10
8
|
module JekyllSupport
|
11
9
|
# Base class for Jekyll block tags
|
12
10
|
class JekyllBlock < Liquid::Block
|
@@ -23,6 +21,7 @@ module JekyllSupport
|
|
23
21
|
# @return [void]
|
24
22
|
def initialize(tag_name, argument_string, parse_context)
|
25
23
|
super
|
24
|
+
@tag_name = tag_name
|
26
25
|
@logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
27
26
|
@helper = JekyllPluginHelper.new(tag_name, argument_string, @logger)
|
28
27
|
@argument_string = argument_string
|
@@ -41,4 +40,37 @@ module JekyllSupport
|
|
41
40
|
text
|
42
41
|
end
|
43
42
|
end
|
43
|
+
|
44
|
+
|
45
|
+
# Base class for Jekyll tags
|
46
|
+
class JekyllTag < Liquid::Tag
|
47
|
+
attr_reader :argument_string, :helper, :line_number, :logger, :page, :site
|
48
|
+
|
49
|
+
# See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
|
50
|
+
# @param tag_name [String] the name of the tag, which we usually know.
|
51
|
+
# @param argument_string [String] the arguments passed to the tag, as a single string.
|
52
|
+
# @param parse_context [Liquid::ParseContext] hash that stores Liquid options.
|
53
|
+
# By default it has two keys: :locale and :line_numbers, the first is a Liquid::I18n object, and the second,
|
54
|
+
# a boolean parameter that determines if error messages should display the line number the error occurred.
|
55
|
+
# This argument is used mostly to display localized error messages on Liquid built-in Tags and Filters.
|
56
|
+
# See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
|
57
|
+
# @return [void]
|
58
|
+
def initialize(tag_name, argument_string, parse_context)
|
59
|
+
super
|
60
|
+
@tag_name = tag_name
|
61
|
+
@logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
62
|
+
@helper = JekyllPluginHelper.new(tag_name, argument_string, @logger)
|
63
|
+
@argument_string = argument_string
|
64
|
+
end
|
65
|
+
|
66
|
+
# Method prescribed by the Jekyll plugin lifecycle.
|
67
|
+
def render(context)
|
68
|
+
render_impl
|
69
|
+
end
|
70
|
+
|
71
|
+
# Jekyll plugins must override this method, not render, so their plugin can be tested more easily
|
72
|
+
def render_impl
|
73
|
+
abort "JekyllTag render_impl for tag #{@tag_name} must be overridden, but it was not."
|
74
|
+
end
|
75
|
+
end
|
44
76
|
end
|
@@ -23,16 +23,29 @@ class JekyllPluginHelper
|
|
23
23
|
string.strip.gsub(/\A'|\A"|'\Z|"\Z/, '').strip if string
|
24
24
|
end
|
25
25
|
|
26
|
+
# See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
|
27
|
+
# @param tag_name [String] the name of the tag, which we already know.
|
28
|
+
# @param argument_string [String] the arguments from the tag, as a single string.
|
29
|
+
# @param parse_context [Liquid::ParseContext] hash that stores Liquid options.
|
30
|
+
# By default it has two keys: :locale and :line_numbers, the first is a Liquid::I18n object, and the second,
|
31
|
+
# a boolean parameter that determines if error messages should display the line number the error occurred.
|
32
|
+
# This argument is used mostly to display localized error messages on Liquid built-in Tags and Filters.
|
33
|
+
# See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
|
34
|
+
# @return [void]
|
26
35
|
def initialize(tag_name, markup, logger)
|
27
|
-
# @keys_values was a Hash[Symbol, String|Boolean] but now it is Hash[String, String|Boolean]
|
28
36
|
@tag_name = tag_name
|
37
|
+
@logger = logger
|
38
|
+
@logger.debug { "@keys_values='#{@keys_values}'" }
|
39
|
+
reinitialize(markup.strip)
|
40
|
+
end
|
41
|
+
|
42
|
+
def reinitialize(markup)
|
43
|
+
# @keys_values was a Hash[Symbol, String|Boolean] but now it is Hash[String, String|Boolean]
|
29
44
|
@markup = markup # Useful for debugging
|
30
45
|
@argv = Shellwords.split(JekyllPluginHelper.expand_env(markup))
|
31
46
|
@keys_values = KeyValueParser \
|
32
47
|
.new({}, { array_values: false, normalize_keys: false, separator: /=/ }) \
|
33
48
|
.parse(@argv)
|
34
|
-
@logger = logger
|
35
|
-
@logger.debug { "@keys_values='#{@keys_values}'" }
|
36
49
|
end
|
37
50
|
|
38
51
|
def delete_parameter(key)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'jekyll_plugin_logger'
|
4
2
|
# require 'rspec/match_ignoring_whitespace'
|
5
3
|
require_relative '../lib/jekyll_plugin_support'
|
@@ -7,7 +5,7 @@ require_relative '../lib/jekyll_plugin_support_spec_support'
|
|
7
5
|
|
8
6
|
# Lets get this party started
|
9
7
|
class MyTest
|
10
|
-
RSpec.describe
|
8
|
+
RSpec.describe JekyllSupport::JekyllBlock do
|
11
9
|
let(:logger) do
|
12
10
|
PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
13
11
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'jekyll_plugin_logger'
|
2
|
+
# require 'rspec/match_ignoring_whitespace'
|
3
|
+
require_relative '../lib/jekyll_plugin_support'
|
4
|
+
require_relative '../lib/jekyll_plugin_support_spec_support'
|
5
|
+
|
6
|
+
# Lets get this party started
|
7
|
+
class MyTest
|
8
|
+
RSpec.describe JekyllSupport::JekyllTag do
|
9
|
+
let(:logger) do
|
10
|
+
PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:parse_context) { TestParseContext.new }
|
14
|
+
|
15
|
+
# Example for plugin authors to refer to:
|
16
|
+
#
|
17
|
+
# let(:helper) do
|
18
|
+
# JekyllTagHelper.new(
|
19
|
+
# 'quote',
|
20
|
+
# "cite='This is a citation' url='https://blah.com' This is the quoted text.",
|
21
|
+
# logger
|
22
|
+
# )
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# fit 'is created properly' do
|
26
|
+
# command_line = "cite='This is a citation' url='https://blah.com' This is the quoted text.".dup
|
27
|
+
# quote = Jekyll::Quote.send(
|
28
|
+
# :new,
|
29
|
+
# 'quote',
|
30
|
+
# command_line,
|
31
|
+
# parse_context
|
32
|
+
# )
|
33
|
+
# result = quote.send(:render_impl, command_line)
|
34
|
+
# expect(result).to match_ignoring_whitespace <<-END_RESULT
|
35
|
+
# <div class='quote'>
|
36
|
+
# This is the quoted text.
|
37
|
+
# </div>
|
38
|
+
# END_RESULT
|
39
|
+
# end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_plugin_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: debase
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-match_ignoring_whitespace
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: rubocop-rspec
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +108,20 @@ dependencies:
|
|
66
108
|
- - ">="
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ruby-debug-ide
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
description:
|
70
126
|
email:
|
71
127
|
- mslinn@mslinn.com
|
@@ -83,7 +139,8 @@ files:
|
|
83
139
|
- lib/jekyll_plugin_support/version.rb
|
84
140
|
- lib/jekyll_plugin_support_helper.rb
|
85
141
|
- lib/jekyll_plugin_support_spec_support.rb
|
86
|
-
- spec/
|
142
|
+
- spec/jekyll_block_plugin_support_spec.rb
|
143
|
+
- spec/jekyll_tag_plugin_support_spec.rb
|
87
144
|
- spec/spec_helper.rb
|
88
145
|
homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#quote
|
89
146
|
licenses:
|
@@ -117,6 +174,7 @@ signing_key:
|
|
117
174
|
specification_version: 4
|
118
175
|
summary: Provides support for writing Jekyll plugins.
|
119
176
|
test_files:
|
120
|
-
- spec/
|
177
|
+
- spec/jekyll_block_plugin_support_spec.rb
|
178
|
+
- spec/jekyll_tag_plugin_support_spec.rb
|
121
179
|
- spec/spec_helper.rb
|
122
180
|
...
|