jekyll_plugin_support 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fa04aaa91759fb0cea5d52005f80d854c0e88bdc6c7300d167fd85737cdc584
4
- data.tar.gz: '0183049f3234a4d97e071dc00055fd79d844da86ef8c6d836c1c8be3b1430d1b'
3
+ metadata.gz: 4d4b97854b427b9113f6db8e175608ac5e2b3fc5866c0062449c9b7e5c530798
4
+ data.tar.gz: 39c0b2b1ee1b457df3e339edb166d295fdf14b83faeb44a6261be39993fc82f4
5
5
  SHA512:
6
- metadata.gz: 48bcfac7c6a918b7ad182bdcb5890c5707a5955d119df6ad03304c0a4712e07b7b5d523668fa6fc391a41e403706810d8939ac8c5c6ff1d7616db35ee804f017
7
- data.tar.gz: 6adc3d6a4b5cebbf081b8b53abe3cc6abdac822046abbfe1d350f85f18d4c45f4861c0bed91cad29117d88605e49f22afb79d4b65adc6b35413924df6556d579
6
+ metadata.gz: db5aa2fe02695556bb5bc7c95e53c5eb98990688fd1920bcab97503262979ef4266ac95210da7fc5d60a67f635b2fe11e7b18ebd3d35ab6e4bdbeedc1d116442
7
+ data.tar.gz: accae0af9a79e92f812980db24e23e33b7555362f24e28f9dd099f6faa57e7484a7043ddeccb16aa10f1d6a7d187cf6ee9f023bbd030d8cb49bf9984dc8049eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.7.0 / 2023-05-22
2
+ * Added `error_short_trace` and `warn_short_trace` methods for displaying non-fatal errors on the console.
3
+
4
+ ## 0.6.2 / 2023-05-15
5
+ * Removed annoying blank line output when attribute was invoked.
6
+
1
7
  ## 0.6.1 / 2023-04-12
2
8
  * Added `CallChain.excerpt_caller` to detect if an excerpt is being generated.
3
9
 
@@ -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/jekyll/10200-jekyll-plugin-support.html'
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',
@@ -142,7 +142,6 @@ class JekyllPluginHelper # rubocop:disable Metrics/ClassLength
142
142
  else
143
143
  @attribution
144
144
  end
145
- puts { "Interpolationg #{string}" }
146
145
  String.interpolate { string }
147
146
  end
148
147
 
@@ -1,3 +1,3 @@
1
1
  module JekyllPluginSupportVersion
2
- VERSION = '0.6.1'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
@@ -12,6 +12,26 @@ module NoArgParsing
12
12
  end
13
13
 
14
14
  module JekyllSupport
15
+ DISPLAYED_CALLS = 8
16
+
17
+ def self.error_short_trace(logger, error)
18
+ remaining = e.backtrace.length - DISPLAYED_CALLS
19
+ logger.error do
20
+ error.message + "\n" + # rubocop:disable Style/StringConcatenation
21
+ error.backtrace.take(DISPLAYED_CALLS).join("\n") +
22
+ "\n...Remaining #{remaining} call sites elided.\n"
23
+ end
24
+ end
25
+
26
+ def self.warn_short_trace(logger, error)
27
+ remaining = e.backtrace.length - DISPLAYED_CALLS
28
+ logger.warn do
29
+ error.message + "\n" + # rubocop:disable Style/StringConcatenation
30
+ error.backtrace.take(DISPLAYED_CALLS).join("\n") +
31
+ "\n...Remaining #{remaining} call sites elided.\n"
32
+ end
33
+ end
34
+
15
35
  # Base class for Jekyll block tags
16
36
  class JekyllBlock < Liquid::Block
17
37
  attr_reader :argument_string, :helper, :line_number, :logger, :page, :site, :text
@@ -34,16 +54,27 @@ module JekyllSupport
34
54
  @helper = JekyllPluginHelper.new tag_name, argument_string, @logger, respond_to?(:no_arg_parsing)
35
55
  end
36
56
 
57
+ # @return line number where tag or block was found, relative to the start of the page
58
+ def jekyll_line_number
59
+ @page['front_matter'].count("\n") + @line_number
60
+ end
61
+
37
62
  # Method prescribed by the Jekyll plugin lifecycle.
63
+ # Defines @config, @envs, @mode, @page and @site
38
64
  # @return [String]
39
65
  def render(liquid_context)
40
66
  text = super
41
67
  @helper.liquid_context = liquid_context
42
68
 
43
- @page = liquid_context.registers[:page] # Type Jekyll::Drops::DocumentDrop
69
+ @page = liquid_context.registers[:page] # hash
44
70
  @site = liquid_context.registers[:site]
45
71
  @config = @site.config
46
72
  @envs = liquid_context.environments.first
73
+
74
+ @layout = @envs[:layout]
75
+ @paginator = @envs[:paginator]
76
+ @theme = @envs[:theme]
77
+
47
78
  @mode = @config['env']['JEKYLL_ENV'] || 'development'
48
79
 
49
80
  render_impl text
@@ -54,12 +85,18 @@ module JekyllSupport
54
85
  raise e
55
86
  end
56
87
 
57
- # Jekyll plugins should override this method, not render, so their plugin can be tested more easily
58
- # @page and @site are available
59
- # @return [String]
88
+ # Jekyll plugins should override this method, not render,
89
+ # so they can be tested more easily.
90
+ # The following variables are predefined:
91
+ # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
92
+ # @return [String] The result to be rendered to the invoking page
60
93
  def render_impl(text)
61
94
  text
62
95
  end
96
+
97
+ def warn_short_trace(error)
98
+ JekyllSupport.warn_short_trace(@logger, error)
99
+ end
63
100
  end
64
101
 
65
102
  class JekyllBlockNoArgParsing < JekyllBlock
@@ -74,6 +111,10 @@ module JekyllSupport
74
111
  @logger.error { "#{self.class} died with a #{e.full_message}" }
75
112
  exit 2
76
113
  end
114
+
115
+ def warn_short_trace(error)
116
+ JekyllSupport.warn_short_trace(@logger, error)
117
+ end
77
118
  end
78
119
 
79
120
  # Base class for Jekyll tags
@@ -98,6 +139,11 @@ module JekyllSupport
98
139
  @helper = JekyllPluginHelper.new(tag_name, argument_string, @logger, respond_to?(:no_arg_parsing))
99
140
  end
100
141
 
142
+ # @return line number where tag or block was found, relative to the start of the page
143
+ def jekyll_line_number
144
+ @page['front_matter'].count("\n") + @line_number
145
+ end
146
+
101
147
  # Method prescribed by the Jekyll plugin lifecycle.
102
148
  def render(liquid_context)
103
149
  return if @helper.excerpt_caller
@@ -123,10 +169,15 @@ module JekyllSupport
123
169
  end
124
170
 
125
171
  # Jekyll plugins must override this method, not render, so their plugin can be tested more easily
126
- # @page and @site are available
172
+ # The following variables are predefined:
173
+ # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
127
174
  def render_impl
128
175
  abort "#{self.class}.render_impl for tag #{@tag_name} must be overridden, but it was not."
129
176
  end
177
+
178
+ def warn_short_trace(error)
179
+ JekyllSupport.warn_short_trace(@logger, error)
180
+ end
130
181
  end
131
182
 
132
183
  class JekyllTagNoArgParsing < JekyllTag
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.6.1
4
+ version: 0.7.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-04-13 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -86,18 +86,16 @@ 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
- - spec/status_persistence.txt
93
- homepage: https://www.mslinn.com/jekyll/10200-jekyll-plugin-support.html
91
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
94
92
  licenses:
95
93
  - MIT
96
94
  metadata:
97
95
  allowed_push_host: https://rubygems.org
98
96
  bug_tracker_uri: https://github.com/mslinn/jekyll_plugin_support/issues
99
97
  changelog_uri: https://github.com/mslinn/jekyll_plugin_support/CHANGELOG.md
100
- homepage_uri: https://www.mslinn.com/jekyll/10200-jekyll-plugin-support.html
98
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
101
99
  source_code_uri: https://github.com/mslinn/jekyll_plugin_support
102
100
  post_install_message: |2+
103
101
 
@@ -122,8 +120,6 @@ signing_key:
122
120
  specification_version: 4
123
121
  summary: Provides support for writing Jekyll plugins.
124
122
  test_files:
125
- - spec/jekyll_plugin_helper_call_spec.rb
126
123
  - spec/jekyll_plugin_helper_options_spec.rb
127
124
  - spec/spec_helper.rb
128
- - spec/status_persistence.txt
129
125
  ...
@@ -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
@@ -1,4 +0,0 @@
1
- example_id | status | run_time |
2
- ----------------------------------------------------------------------------------------------- | ------ | --------------- |
3
- /mnt/_/work/jekyll/my_plugins/jekyll_plugin_support/spec/jekyll_plugin_helper_call_spec.rb[1:1] | passed | 0.00436 seconds |
4
- /mnt/_/work/jekyll/my_plugins/jekyll_plugin_support/spec/jekyll_plugin_helper_call_spec.rb[1:2] | passed | 0.00476 seconds |