jekyll_plugin_support 0.6.2 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -23
- data/README.md +58 -27
- data/jekyll_plugin_support.gemspec +1 -1
- data/lib/jekyll_plugin_support/version.rb +1 -1
- data/lib/jekyll_plugin_support.rb +68 -8
- data/spec/status_persistence.txt +6 -4
- metadata +4 -6
- data/spec/jekyll_plugin_helper_call_spec.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4093bb78659c8a6b9e75df1ed8e288e7ba8a0216b7d870f04856933c992e631
|
4
|
+
data.tar.gz: 69c2191230866feb2552a9a170140008b5d16290703f525d1a6487b28df78706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e63ab6ea4dc5a241d4fdafd00fd088943dee27591a36297a2a5a4984e0096775365c902bd43ece243cea45ac26e64e5a374c1afcc72f51653825e680e33f40ae
|
7
|
+
data.tar.gz: 25db74e77f3f24dd4d40fb2aba3b3717ff630c6afb6e3e9743ac91dc1331a29139fe79c9c7e596e8e9a7c7149c83c2cedd6503401ff9f83cf1b3eb7ada94197c
|
data/CHANGELOG.md
CHANGED
@@ -1,53 +1,96 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.7.1 / 2023-08-11
|
4
|
+
|
5
|
+
* Suppressed stack trace from issue [#4](../../issues/4).
|
6
|
+
* Now using Shopify `ruby-lsp` instead of `rebornix.Ruby` by Peng Lv
|
7
|
+
* Debug configurations changed to `rdbg` instead of `ruby`, so the `debase` development dependency was changed to
|
8
|
+
[`debug`](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg),
|
9
|
+
which provides the `rdgb` command.
|
10
|
+
The `ruby-debug-ide` development dependency is also no longer required.
|
11
|
+
|
12
|
+
|
13
|
+
## 0.7.0 / 2023-05-22
|
14
|
+
|
15
|
+
* Added `error_short_trace` and `warn_short_trace` methods for displaying non-fatal errors on the console.
|
16
|
+
|
1
17
|
## 0.6.2 / 2023-05-15
|
2
|
-
|
18
|
+
|
19
|
+
* Removed annoying blank line output when attribute was invoked.
|
3
20
|
|
4
21
|
## 0.6.1 / 2023-04-12
|
5
|
-
|
22
|
+
|
23
|
+
* Added `CallChain.excerpt_caller` to detect if an excerpt is being generated.
|
24
|
+
|
6
25
|
|
7
26
|
## 0.6.0 / 2023-04-05
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
27
|
+
|
28
|
+
* Added attribution support
|
29
|
+
* Renamed `jekyll_plugin_support_helper.rb` to `jekyll_plugin_helper.rb`.
|
30
|
+
* Now returns `undefined` instead of `false'` when `@keys_values.empty?`
|
31
|
+
and parameter is not specified.
|
32
|
+
|
12
33
|
|
13
34
|
## 0.5.3 / 2023-03-19
|
14
|
-
|
35
|
+
|
36
|
+
* Added properties `argv_original`, `keys_values_original`, `remaining_markup_original`,
|
15
37
|
and `params_original`, which are the original values of `argv`, `keys_values`,
|
16
38
|
`remaining_markup`, and `params`, before environment variable expansion.
|
17
39
|
|
40
|
+
|
18
41
|
## 0.5.2 / 2023-03-17
|
19
|
-
|
42
|
+
|
43
|
+
* Added `@helper.remaining_markup` public method, which returns remaining markup passed to your tag,
|
44
|
+
after keyword and name/value parsing is complete.
|
20
45
|
* Finally wrote proper `rspec` tests.
|
21
46
|
* Finally documented argument parsing.
|
22
47
|
* Fixed bug introduced in v0.5.1 which did not remove elements from `@params`.
|
23
48
|
|
49
|
+
|
24
50
|
## 0.5.1 / 2023-02-17
|
25
|
-
|
51
|
+
|
52
|
+
* `no_arg_parsing` optimization added.
|
53
|
+
|
26
54
|
|
27
55
|
## 0.5.0 / 2023-02-15
|
28
|
-
|
29
|
-
|
30
|
-
|
56
|
+
|
57
|
+
* Plugins now register themselves
|
58
|
+
* Plugins now report their name and version
|
59
|
+
* `@layout`, `@paginator`, and `@theme` have values if supported by the version of Jekyll, and they are active.
|
60
|
+
(See [Jekyll docs](https://jekyllrb.com/docs/variables/).)
|
61
|
+
|
31
62
|
|
32
63
|
## 0.4.1 / 2023-02-14
|
33
|
-
|
34
|
-
|
64
|
+
|
65
|
+
* Fixed several problems
|
66
|
+
* Added demo site
|
67
|
+
|
35
68
|
|
36
69
|
## 0.4.0 / 2023-02-12
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
70
|
+
|
71
|
+
* `render_impl` for tags and blocks now predefines more instance variables:
|
72
|
+
|
73
|
+
* `@liquid_context` – passed to `render`
|
74
|
+
* `@config` Jekyll configuration
|
75
|
+
* `@envs` Environment variables
|
76
|
+
* `@mode` ('development', 'test' or 'production')
|
77
|
+
|
42
78
|
|
43
79
|
## 0.3.1 / 2023-02-07
|
44
|
-
|
80
|
+
|
81
|
+
* `JekyllBlock.render_impl` and `JekyllTag.render_impl` now define `@page` and `@site`.
|
82
|
+
|
45
83
|
|
46
84
|
## 0.3.0 / 2023-01-14
|
47
|
-
|
85
|
+
|
86
|
+
* Added support for tags, which should subclass JekyllSupport::JekyllTag
|
87
|
+
|
48
88
|
|
49
89
|
## 0.2.0 / 2023-01-12
|
50
|
-
|
90
|
+
|
91
|
+
* Refactored
|
92
|
+
|
51
93
|
|
52
94
|
## 0.1.0 / 2023-01-10
|
53
|
-
|
95
|
+
|
96
|
+
* Initial version; only supports Jekyll block tags
|
data/README.md
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
`jekyll_plugin_support`
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/jekyll_plugin_support.svg)](https://badge.fury.io/rb/jekyll_plugin_support)
|
3
|
-
===========
|
1
|
+
# `jekyll_plugin_support` [![Gem Version](https://badge.fury.io/rb/jekyll_plugin_support.svg)](https://badge.fury.io/rb/jekyll_plugin_support)
|
4
2
|
|
5
3
|
`Jekyll_plugin_support` is a Ruby gem that facilitates writing and testing Jekyll plugins.
|
6
4
|
At present, only Jekyll tags and blocks are supported.
|
7
5
|
|
8
6
|
|
9
7
|
## Installation
|
8
|
+
|
10
9
|
`Jekyll_plugin_support` can be used to create simple Jekyll plugins in the `_plugins/` directory, or gem-based Jekyll plugins.
|
11
10
|
|
12
|
-
### Simple
|
13
|
-
|
11
|
+
### Simple Plugins
|
12
|
+
|
13
|
+
For jekyll plugins defined in the `_plugins/` directory,
|
14
|
+
add this line to your Jekyll plugin's `Gemfile`:
|
14
15
|
|
15
16
|
```ruby
|
16
17
|
group :jekyll_plugins do
|
@@ -20,10 +21,13 @@ end
|
|
20
21
|
|
21
22
|
And then execute:
|
22
23
|
|
23
|
-
|
24
|
+
```shell
|
25
|
+
$ bundle
|
26
|
+
```
|
24
27
|
|
25
28
|
|
26
29
|
### Gem-Based Plugins
|
30
|
+
|
27
31
|
Add this line to your Jekyll plugin's `.gemspec`:
|
28
32
|
|
29
33
|
```ruby
|
@@ -32,16 +36,20 @@ spec.add_dependency 'jekyll_plugin_support'
|
|
32
36
|
|
33
37
|
And then execute:
|
34
38
|
|
35
|
-
|
39
|
+
```shell
|
40
|
+
$ bundle
|
41
|
+
```
|
36
42
|
|
37
43
|
|
38
44
|
## General Usage
|
45
|
+
|
39
46
|
`JekyllSupport::JekyllBlock` and `JekyllSupport::JekyllTag`
|
40
47
|
provide support for Jekyll tag blocks and Jekyll tags, respectively.
|
41
48
|
They are very similar in construction and usage.
|
42
49
|
|
43
50
|
Instead of subclassing your Jekyll block tag class from `Liquid::Block`,
|
44
51
|
subclass from `JekyllSupport::JekyllBlock` instead.
|
52
|
+
|
45
53
|
Similarly, instead of subclassing your Jekyll tag class from `Liquid::Tag`,
|
46
54
|
subclass from `JekyllSupport::JekyllTag` instead.
|
47
55
|
|
@@ -64,6 +72,7 @@ Your implementation of `render_impl` can access `@page` and `@site`,
|
|
64
72
|
and can parse parameters passed to the tag / block tag, [as described here](https://mslinn.com/jekyll/10100-jekyll-plugin-background.html#params):
|
65
73
|
|
66
74
|
### For a tag:
|
75
|
+
|
67
76
|
```ruby
|
68
77
|
require 'jekyll_plugin_support'
|
69
78
|
|
@@ -84,6 +93,7 @@ end
|
|
84
93
|
```
|
85
94
|
|
86
95
|
### For a tag block:
|
96
|
+
|
87
97
|
```ruby
|
88
98
|
require 'jekyll_plugin_support'
|
89
99
|
|
@@ -116,6 +126,7 @@ end
|
|
116
126
|
```
|
117
127
|
|
118
128
|
Then your plugin can incorporate the `VERSION` constant into your plugin like this:
|
129
|
+
|
119
130
|
```ruby
|
120
131
|
require 'jekyll_plugin_support'
|
121
132
|
require_relative 'my_block/version'
|
@@ -139,6 +150,7 @@ end
|
|
139
150
|
```
|
140
151
|
|
141
152
|
### Argument Parsing
|
153
|
+
|
142
154
|
Tag arguments can be obtained within `render_impl`.
|
143
155
|
Both keyword options and name/value parameters are supported.
|
144
156
|
|
@@ -167,42 +179,45 @@ The `demo/_plugins/demo_tag.rb` plugin uses `@helper.parameter_specified?` provi
|
|
167
179
|
`jekyll_support_plugin` to parse the string passed to the tag, which is
|
168
180
|
`keyword1 name1='value1' unreferenced_key unreferenced_name="unreferenced_value"`.
|
169
181
|
|
170
|
-
|
182
|
+
* Because `keyword1` was referenced by `@helper.parameter_specified?` above,
|
171
183
|
that keyword option is removed from the argument string.
|
172
|
-
|
184
|
+
* Because the `name1` key/value parameter was referenced by `@helper.parameter_specified?` above,
|
173
185
|
that name/value pair is removed from the argument string.
|
174
|
-
|
186
|
+
* The remainder of the argument string is now `unreferenced_key unreferenced_name="unreferenced_value"`.
|
175
187
|
|
176
188
|
Name/value parameters can be quoted; if the value consists of only one token then it does not need to be quoted.
|
177
189
|
The following name/value parameters all have the same result:
|
178
190
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
191
|
+
* `pay_tuesday="true"`
|
192
|
+
* `pay_tuesday='true'`
|
193
|
+
* `pay_tuesday=true`
|
194
|
+
* `pay_tuesday`
|
183
195
|
|
184
196
|
The following also have the same result, however note that because the value has more than one token, quotes must be used:
|
185
197
|
|
186
|
-
|
187
|
-
|
198
|
+
* `pay_tuesday="maybe not"`
|
199
|
+
* `pay_tuesday='maybe not'`
|
188
200
|
|
189
201
|
#### Remaining Markup
|
202
|
+
|
190
203
|
After your plugin has parsed all the keyword options and name/value parameters,
|
191
204
|
call `@helper.remaining_markup` to obtain the remaining markup that was passed to your plugin.
|
192
205
|
|
193
206
|
|
194
207
|
### `no_arg_parsing` Optimization
|
208
|
+
|
195
209
|
If your tag or block plugin only needs access to the raw arguments passed from the web page,
|
196
210
|
without tokenization, and you expect that the plugin might be invoked with large amounts of text,
|
197
211
|
derive your plugin from `JekyllBlockNoArgParsing` or `JekyllTagNoArgParsing`.
|
198
212
|
|
199
213
|
|
200
214
|
## Subclass Attribution
|
215
|
+
|
201
216
|
`JekyllTag` and `JekyllBlock` subclasses of `jekyll_plugin_support` can utilize the `attribution` option IFF they are published as a gem.
|
202
217
|
`JekyllTagNoArgParsing` and `JekyllBlockNoArgParsing` subclasses cannot.
|
203
218
|
|
204
|
-
|
205
|
-
|
219
|
+
* When used as a keyword option, a default value is used for the attribution string.
|
220
|
+
* When used as a name/value option, the attribution string can be specified.
|
206
221
|
|
207
222
|
Using the `attribution` option cause subclasses to replace their usual output with HTML that looks like:
|
208
223
|
|
@@ -218,9 +233,10 @@ The `id` attribute is in the sample HTML above is randomized so more than one at
|
|
218
233
|
|
219
234
|
|
220
235
|
### Usage
|
236
|
+
|
221
237
|
Typical usage for the `attribution` tag is:
|
222
238
|
|
223
|
-
```
|
239
|
+
```html
|
224
240
|
{% my_tag attribution %}
|
225
241
|
```
|
226
242
|
|
@@ -239,14 +255,17 @@ The `date` property is obtained from the plugin/gem publishing date.
|
|
239
255
|
|
240
256
|
An alternative attribution string can be specified properties can be output using any of the above properties:
|
241
257
|
|
242
|
-
```
|
258
|
+
```html
|
243
259
|
{% my_tag attribution="Generated by the #{name} #{version} Jekyll plugin, written by #{author} #{date}" %}
|
244
260
|
```
|
245
261
|
|
246
262
|
### Attribution Generation
|
247
|
-
You can decide where you want the attribution string for your Jekyll tag to appear by invoking `@helper.attribute`. For example, this is how the [`jekyll_outline` tag](https://github.com/mslinn/jekyll_outline/blob/v1.1.1/lib/outline_tag.rb#L32-L46) generates output:
|
248
263
|
|
249
|
-
|
264
|
+
You can decide where you want the attribution string for your Jekyll tag to appear by invoking `@helper.attribute`.
|
265
|
+
For example, this is how the
|
266
|
+
[`jekyll_outline` tag](https://github.com/mslinn/jekyll_outline/blob/v1.1.1/lib/outline_tag.rb#L32-L46) generates output:
|
267
|
+
|
268
|
+
```html
|
250
269
|
<<~HEREDOC
|
251
270
|
<div class="outer_posts">
|
252
271
|
#{make_entries(collection)&.join("\n")}
|
@@ -257,8 +276,9 @@ HEREDOC
|
|
257
276
|
|
258
277
|
|
259
278
|
## Additional Information
|
279
|
+
|
260
280
|
More information is available on
|
261
|
-
[Mike Slinn’s website](https://www.mslinn.com/
|
281
|
+
[Mike Slinn’s website](https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html).
|
262
282
|
|
263
283
|
|
264
284
|
## Development
|
@@ -269,6 +289,7 @@ You can also run `bin/console` for an interactive prompt that will allow you to
|
|
269
289
|
|
270
290
|
|
271
291
|
To build and install this gem onto your local machine, run:
|
292
|
+
|
272
293
|
```shell
|
273
294
|
$ bundle exec rake install
|
274
295
|
jekyll_plugin_support 0.1.0 built to pkg/jekyll_plugin_support-0.1.0.gem.
|
@@ -276,6 +297,7 @@ jekyll_plugin_support (0.1.0) installed.
|
|
276
297
|
```
|
277
298
|
|
278
299
|
Examine the newly built gem:
|
300
|
+
|
279
301
|
```shell
|
280
302
|
$ gem info jekyll_plugin_support
|
281
303
|
|
@@ -293,39 +315,48 @@ jekyll_plugin_support (0.1.0)
|
|
293
315
|
|
294
316
|
|
295
317
|
## Demo
|
318
|
+
|
296
319
|
A demo / test website is provided in the `demo` directory.
|
297
320
|
It can be used to debug the plugin or to run freely.
|
298
321
|
|
299
322
|
### Run Freely
|
323
|
+
|
300
324
|
1. Run from the command line:
|
325
|
+
|
301
326
|
```shell
|
302
327
|
$ demo/_bin/debug -r
|
303
328
|
```
|
304
329
|
|
305
|
-
|
330
|
+
2. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
306
331
|
|
307
332
|
### Plugin Debugging
|
333
|
+
|
308
334
|
1. Set breakpoints in Visual Studio Code.
|
309
335
|
|
310
336
|
2. Initiate a debug session from the command line:
|
337
|
+
|
311
338
|
```shell
|
312
339
|
$ demo/_bin/debug
|
313
340
|
```
|
314
341
|
|
315
|
-
|
316
|
-
configuration called `Attach
|
342
|
+
3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch
|
343
|
+
configuration called `Attach with rdbg`.
|
317
344
|
|
318
|
-
|
345
|
+
4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
319
346
|
|
320
347
|
|
321
348
|
### Build and Push to RubyGems
|
349
|
+
|
322
350
|
To release a new version,
|
351
|
+
|
323
352
|
1. Update the version number in `version.rb`.
|
324
353
|
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
325
354
|
3. Run the following:
|
355
|
+
|
326
356
|
```shell
|
327
357
|
$ bundle exec rake release
|
328
358
|
```
|
359
|
+
|
329
360
|
The above creates a git tag for the version, commits the created tag,
|
330
361
|
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
331
362
|
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
7
7
|
spec.authors = ['Mike Slinn']
|
8
8
|
spec.email = ['mslinn@mslinn.com']
|
9
9
|
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
10
|
-
spec.homepage = 'https://www.mslinn.com/
|
10
|
+
spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html'
|
11
11
|
spec.license = 'MIT'
|
12
12
|
spec.metadata = {
|
13
13
|
'allowed_push_host' => 'https://rubygems.org',
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'colorator'
|
1
2
|
require 'jekyll'
|
2
3
|
require 'jekyll_plugin_logger'
|
3
4
|
require_relative 'jekyll_plugin_helper'
|
@@ -12,6 +13,26 @@ module NoArgParsing
|
|
12
13
|
end
|
13
14
|
|
14
15
|
module JekyllSupport
|
16
|
+
DISPLAYED_CALLS = 8
|
17
|
+
|
18
|
+
def self.error_short_trace(logger, error)
|
19
|
+
remaining = e.backtrace.length - DISPLAYED_CALLS
|
20
|
+
logger.error do
|
21
|
+
error.message + "\n" + # rubocop:disable Style/StringConcatenation
|
22
|
+
error.backtrace.take(DISPLAYED_CALLS).join("\n") +
|
23
|
+
"\n...Remaining #{remaining} call sites elided.\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.warn_short_trace(logger, error)
|
28
|
+
remaining = e.backtrace.length - DISPLAYED_CALLS
|
29
|
+
logger.warn do
|
30
|
+
error.message + "\n" + # rubocop:disable Style/StringConcatenation
|
31
|
+
error.backtrace.take(DISPLAYED_CALLS).join("\n") +
|
32
|
+
"\n...Remaining #{remaining} call sites elided.\n"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
15
36
|
# Base class for Jekyll block tags
|
16
37
|
class JekyllBlock < Liquid::Block
|
17
38
|
attr_reader :argument_string, :helper, :line_number, :logger, :page, :site, :text
|
@@ -34,16 +55,27 @@ module JekyllSupport
|
|
34
55
|
@helper = JekyllPluginHelper.new tag_name, argument_string, @logger, respond_to?(:no_arg_parsing)
|
35
56
|
end
|
36
57
|
|
58
|
+
# @return line number where tag or block was found, relative to the start of the page
|
59
|
+
def jekyll_line_number
|
60
|
+
@page['front_matter'].count("\n") + @line_number
|
61
|
+
end
|
62
|
+
|
37
63
|
# Method prescribed by the Jekyll plugin lifecycle.
|
64
|
+
# Defines @config, @envs, @mode, @page and @site
|
38
65
|
# @return [String]
|
39
66
|
def render(liquid_context)
|
40
67
|
text = super
|
41
68
|
@helper.liquid_context = liquid_context
|
42
69
|
|
43
|
-
@page = liquid_context.registers[:page] #
|
70
|
+
@page = liquid_context.registers[:page] # hash
|
44
71
|
@site = liquid_context.registers[:site]
|
45
72
|
@config = @site.config
|
46
73
|
@envs = liquid_context.environments.first
|
74
|
+
|
75
|
+
@layout = @envs[:layout]
|
76
|
+
@paginator = @envs[:paginator]
|
77
|
+
@theme = @envs[:theme]
|
78
|
+
|
47
79
|
@mode = @config['env']['JEKYLL_ENV'] || 'development'
|
48
80
|
|
49
81
|
render_impl text
|
@@ -54,12 +86,18 @@ module JekyllSupport
|
|
54
86
|
raise e
|
55
87
|
end
|
56
88
|
|
57
|
-
# Jekyll plugins should override this method, not render,
|
58
|
-
#
|
59
|
-
#
|
89
|
+
# Jekyll plugins should override this method, not render,
|
90
|
+
# so they can be tested more easily.
|
91
|
+
# The following variables are predefined:
|
92
|
+
# @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
|
93
|
+
# @return [String] The result to be rendered to the invoking page
|
60
94
|
def render_impl(text)
|
61
95
|
text
|
62
96
|
end
|
97
|
+
|
98
|
+
def warn_short_trace(error)
|
99
|
+
JekyllSupport.warn_short_trace(@logger, error)
|
100
|
+
end
|
63
101
|
end
|
64
102
|
|
65
103
|
class JekyllBlockNoArgParsing < JekyllBlock
|
@@ -74,6 +112,10 @@ module JekyllSupport
|
|
74
112
|
@logger.error { "#{self.class} died with a #{e.full_message}" }
|
75
113
|
exit 2
|
76
114
|
end
|
115
|
+
|
116
|
+
def warn_short_trace(error)
|
117
|
+
JekyllSupport.warn_short_trace(@logger, error)
|
118
|
+
end
|
77
119
|
end
|
78
120
|
|
79
121
|
# Base class for Jekyll tags
|
@@ -98,6 +140,20 @@ module JekyllSupport
|
|
98
140
|
@helper = JekyllPluginHelper.new(tag_name, argument_string, @logger, respond_to?(:no_arg_parsing))
|
99
141
|
end
|
100
142
|
|
143
|
+
def exit_without_stack_trace(error)
|
144
|
+
raise error
|
145
|
+
rescue StandardError => e
|
146
|
+
file, line_number, caller = e.backtrace[1].split(':')
|
147
|
+
caller = caller.tr('`', "'")
|
148
|
+
warn "#{self.class} died with a '#{error.message}' #{caller} on line #{line_number} of #{file}".red
|
149
|
+
exec "echo ''"
|
150
|
+
end
|
151
|
+
|
152
|
+
# @return line number where tag or block was found, relative to the start of the page
|
153
|
+
def jekyll_line_number
|
154
|
+
@page['front_matter'].count("\n") + @line_number
|
155
|
+
end
|
156
|
+
|
101
157
|
# Method prescribed by the Jekyll plugin lifecycle.
|
102
158
|
def render(liquid_context)
|
103
159
|
return if @helper.excerpt_caller
|
@@ -114,19 +170,23 @@ module JekyllSupport
|
|
114
170
|
@site = liquid_context.registers[:site]
|
115
171
|
|
116
172
|
@config = @site.config
|
117
|
-
@mode = @config['env']['JEKYLL_ENV']
|
173
|
+
@mode = @config['env'].key?('JEKYLL_ENV') ? @config['env']['JEKYLL_ENV'] : 'development'
|
118
174
|
|
119
175
|
render_impl
|
120
176
|
rescue StandardError => e
|
121
|
-
|
122
|
-
exit 3
|
177
|
+
exit_without_stack_trace(e)
|
123
178
|
end
|
124
179
|
|
125
180
|
# Jekyll plugins must override this method, not render, so their plugin can be tested more easily
|
126
|
-
#
|
181
|
+
# The following variables are predefined:
|
182
|
+
# @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
|
127
183
|
def render_impl
|
128
184
|
abort "#{self.class}.render_impl for tag #{@tag_name} must be overridden, but it was not."
|
129
185
|
end
|
186
|
+
|
187
|
+
def warn_short_trace(error)
|
188
|
+
JekyllSupport.warn_short_trace(@logger, error)
|
189
|
+
end
|
130
190
|
end
|
131
191
|
|
132
192
|
class JekyllTagNoArgParsing < JekyllTag
|
data/spec/status_persistence.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------ | ------ | --------------- |
|
3
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:1] | passed | 0.00559 seconds |
|
4
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:2] | passed | 0.00583 seconds |
|
5
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:3] | passed | 0.00543 seconds |
|
6
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:4] | passed | 0.00157 seconds |
|
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.7.1
|
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-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facets
|
@@ -86,18 +86,17 @@ files:
|
|
86
86
|
- lib/jekyll_plugin_support.rb
|
87
87
|
- lib/jekyll_plugin_support/version.rb
|
88
88
|
- lib/jekyll_plugin_support_spec_support.rb
|
89
|
-
- spec/jekyll_plugin_helper_call_spec.rb
|
90
89
|
- spec/jekyll_plugin_helper_options_spec.rb
|
91
90
|
- spec/spec_helper.rb
|
92
91
|
- spec/status_persistence.txt
|
93
|
-
homepage: https://www.mslinn.com/
|
92
|
+
homepage: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
|
94
93
|
licenses:
|
95
94
|
- MIT
|
96
95
|
metadata:
|
97
96
|
allowed_push_host: https://rubygems.org
|
98
97
|
bug_tracker_uri: https://github.com/mslinn/jekyll_plugin_support/issues
|
99
98
|
changelog_uri: https://github.com/mslinn/jekyll_plugin_support/CHANGELOG.md
|
100
|
-
homepage_uri: https://www.mslinn.com/
|
99
|
+
homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
|
101
100
|
source_code_uri: https://github.com/mslinn/jekyll_plugin_support
|
102
101
|
post_install_message: |2+
|
103
102
|
|
@@ -122,7 +121,6 @@ signing_key:
|
|
122
121
|
specification_version: 4
|
123
122
|
summary: Provides support for writing Jekyll plugins.
|
124
123
|
test_files:
|
125
|
-
- spec/jekyll_plugin_helper_call_spec.rb
|
126
124
|
- spec/jekyll_plugin_helper_options_spec.rb
|
127
125
|
- spec/spec_helper.rb
|
128
126
|
- spec/status_persistence.txt
|
@@ -1,21 +0,0 @@
|
|
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
|
-
class JekyllPluginHelperCallTest
|
7
|
-
RSpec.describe JekyllPluginHelper do
|
8
|
-
it 'might not return jpsh_subclass_caller value' do
|
9
|
-
jpsh_subclass_caller = CallChain.jpsh_subclass_caller
|
10
|
-
expect(jpsh_subclass_caller).to be_nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'asf' do
|
14
|
-
logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
15
|
-
jph = described_class.new('my_tag', 'attribution', logger, false)
|
16
|
-
actual = jph.jpsh_subclass_caller
|
17
|
-
expected = [__FILE__, 15, 'new'] # The 2nd element value depends on the line # of two lines up
|
18
|
-
expect(actual).to match_array(expected)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|