jekyll_plugin_support 3.1.5 → 3.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d4f6b9106ad6c0ac015ac96af510e4f284d01de3296b29f815cfe74a14dd249
4
- data.tar.gz: aa2ff95dfa6366d6c1b06e6fe7689d34131bf699e17a8ce05090fe1df836ceb8
3
+ metadata.gz: 0e9e668968a611289735fbb49845ac930d027015d4c385295e78722f85cf40cf
4
+ data.tar.gz: b2cc67846dd969875cf3fa62cba74adfbe10ed86b9607077054e63c07ac890e8
5
5
  SHA512:
6
- metadata.gz: 629abbd99fb59ca3c741d623bc34248377c65744209a2f2b06b27b030aaaa8fba616e92db61494474ac2810674deb49aafd5ef006761e2fcc05380ecf733de80
7
- data.tar.gz: bc8b36722bf0a033231a7b60f1cc70de4c354b898c4ab45ea99aaabe6a8cb70886550fb4bde13524ac741a789824178c76bfdfcd3dcd33cb79d854cfe87a6025
6
+ metadata.gz: 831f38b469c65ef2e2332f18b1624ce06626322643939e3bc497f513c24092070b7ac96664f0a6a63f323f8058141f7c6159966ed23fb76741f807d53d5ffef5
7
+ data.tar.gz: fe06519f62fb7a42cdbba80752cd12a85ad2f1458fa18a2318bb758d75d6c02a65739f62096f6bda3077947588da88398aa6b7cb644346438b35c905b963ee43
data/.rubocop.yml CHANGED
@@ -107,6 +107,9 @@ Style/GlobalVars:
107
107
  Exclude:
108
108
  - spec/mslinn_binary_search_spec.rb
109
109
 
110
+ Style/OneClassPerFile:
111
+ Enabled: false
112
+
110
113
  Style/RedundantParentheses:
111
114
  Exclude:
112
115
  - README.md
data/CHANGELOG.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.6
4
+
5
+ Several little fixes and tweaks.
6
+
7
+
3
8
  ## 3.1.5
4
9
 
5
10
  * Added install subcommand to bundle invocations
6
- * Replaced wslvar which is no longer maintained
11
+ * Replaced `wslvar` which is no longer maintained
12
+
7
13
 
8
14
  ## 3.1.4
9
15
 
data/FIXME.md ADDED
@@ -0,0 +1,49 @@
1
+ # Code Smells in `jekyll_plugin_support`
2
+
3
+ A review of the codebase turned up the issues below. They are ordered by
4
+ severity. Line numbers refer to the state of the repo at the time of review and
5
+ may drift.
6
+
7
+ ## Medium severity
8
+
9
+ ### 6. Duplication between `JekyllTag` and `JekyllBlock`
10
+
11
+ `render`, `initialize`, and `set_error_context` are ~90% identical across
12
+ `lib/tag/jekyll_plugin_support_tag.rb` and
13
+ `lib/block/jekyll_plugin_support_block.rb`. The block version even logs
14
+ `e.full_message` **twice** (lines 89 and 93). Extract a shared
15
+ `JekyllPluginBase` module.
16
+
17
+
18
+ ### 12. `parse` has a leftover TODO and dead branch
19
+
20
+ ```ruby
21
+ @params_original = @keys_values_original unless respond_to?(:no_arg_parsing) && no_arg_parsing
22
+ ...
23
+ @params = @keys_values # TODO: @keys_values should be deleted
24
+ ```
25
+
26
+ The conditional on `@params_original` is moot because `reinitialize` only calls
27
+ `parse` when `!@no_arg_parsing`. And the TODO has lingered.
28
+ (`lib/helper/jekyll_plugin_helper.rb:91-106`)
29
+
30
+ ## Lower severity
31
+
32
+ ### 17. Comment typos / placeholder text in docs
33
+
34
+ `@ptions` appears in the parse_context doc block of *both* tag and block files
35
+ (should be `@options`). Comments like `# Are error and logger.error defined?`
36
+ (`lib/jekyll_plugin_support/jekyll_plugin_support_class.rb:18`) read like
37
+ unanswered questions left in production.
38
+
39
+ ### 20. `_` prefixed unused param but still required
40
+
41
+ `dump_vars(_logger, liquid_context)` — the `_` prefix says "unused," but callers
42
+ must still pass it. Either drop the parameter or use it.
43
+ (`lib/jekyll_plugin_support/jekyll_plugin_support_class.rb:30`)
44
+
45
+
46
+ ## Suggested order to tackle
47
+
48
+ 1. **Extract shared base for `JekyllTag`/`JekyllBlock` (#6)** — biggest maintainability win.
49
+ 3. Remove dead/commented code (#4).
@@ -34,6 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'jekyll', '>= 4.4.1'
35
35
  spec.add_dependency 'jekyll_plugin_logger'
36
36
  spec.add_dependency 'key-value-parser'
37
- spec.add_dependency 'pry'
38
37
  spec.add_dependency 'sorted_set'
39
38
  end
@@ -1,7 +1,8 @@
1
1
  module JekyllSupport
2
2
  # Base class for Jekyll block tags
3
3
  class JekyllBlock < Liquid::Block
4
- attr_reader :argument_string, :helper, :highlighter_prefix, :highlighter_suffix, :jekyll_version, :line_number, :logger, :page, :raw_content, :site, :text
4
+ attr_reader :argument_string, :helper, :highlighter_prefix, :highlighter_suffix, :jekyll_version, :line_number, :logger, :page, :raw_content,
5
+ :site, :text
5
6
 
6
7
  # See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
7
8
  # @param tag_name [String] the name of the tag, which we usually know.
@@ -79,10 +80,6 @@ module JekyllSupport
79
80
  @attribution = @helper.parameter_specified?('attribution') || false unless @no_arg_parsing
80
81
  @logger.debug { "@keys_values='#{@keys_values}'" }
81
82
 
82
- # @argument_string = JekyllSupport.lookup_liquid_variables @logger, liquid_context, @argument_string # Is this redundant?
83
- # @argument_string.strip! # Is this redundant?
84
- # @helper.reinitialize @argument_string # Is this redundant?
85
-
86
83
  render_impl(text)
87
84
  rescue StandardError => e
88
85
  e.shorten_backtrace
@@ -91,7 +88,7 @@ module JekyllSupport
91
88
  in_file_name = "in '#{file_name}' " if file_name
92
89
  of_page = "of '#{@page['path']}'" if @page
93
90
  @logger.error { "While processing line #{@line_number} #{of_page} for #{tag_name} #{in_file_name}- #{e.message}" }
94
- binding.pry if @pry_on_standard_error # rubocop:disable Lint/Debugger
91
+ binding.pry if @pry_on_standard_error && defined?(Pry) # rubocop:disable Lint/Debugger
95
92
  raise e if @die_on_standard_error
96
93
 
97
94
  <<~END_MSG
@@ -1,7 +1,5 @@
1
1
  module JekyllSupport
2
2
  class JekyllBlockNoArgParsing < JekyllBlock
3
- attr_reader :argument_string, :helper, :line_number, :logger, :page, :site
4
-
5
3
  def initialize(tag_name, argument_string, parse_context)
6
4
  class << self
7
5
  include NoArgParsing
@@ -42,12 +42,8 @@ module JekyllSupport
42
42
  END_MSG
43
43
  end
44
44
 
45
- def shorten_backtrace(backtrace_element_count = 6)
46
- set_backtrace backtrace[0..backtrace_element_count]
47
- # b = backtrace[0..backtrace_element_count - 1].map do |x|
48
- # x.gsub(Dir.pwd + '/', './')
49
- # end
50
- # set_backtrace b
45
+ def shorten_backtrace(backtrace_element_count = 5)
46
+ set_backtrace backtrace.first(backtrace_element_count)
51
47
  end
52
48
  end
53
49
  end
@@ -27,7 +27,7 @@ module JekyllSupport
27
27
 
28
28
  # @return undefined if parameter was specified, removes it from the available tokens and returns value
29
29
  def parameter_specified?(name, delete_param: true)
30
- return false if @keys_values.to_s.empty?
30
+ return false if @keys_values.empty?
31
31
 
32
32
  key = name
33
33
  key = name.to_sym if @keys_values&.first&.first.instance_of?(Symbol)
@@ -1,12 +1,7 @@
1
- # Monkey patch StandardError so a new method called shorten_backtrace is added.
2
1
  class StandardError
3
2
  def shorten_backtrace(backtrace_element_count = 5)
4
- set_backtrace backtrace[0..backtrace_element_count]
5
- # self.backtrace = backtrace[0..backtrace_element_count].map do |x|
6
- # raise JekyllPluginSupportError, "backtrace contains a #{x.class} with value '#{x}'." unless x.instance_of? String
7
-
8
- # x.gsub(Dir.pwd + '/', './')
9
- # end
3
+ limit = [backtrace.size - 1, backtrace_element_count].min
4
+ set_backtrace(backtrace[0..limit])
10
5
  end
11
6
  end
12
7
 
@@ -131,7 +126,7 @@ module JekyllSupport
131
126
  layout&.each do |name, value|
132
127
  if value.nil?
133
128
  value = ''
134
- logger.warn { "layout.#{value} is undefined." }
129
+ logger.warn { 'layout.value is undefined.' }
135
130
  end
136
131
  markup.gsub!("{{layout.#{name}}}", value.to_s)
137
132
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllPluginSupportVersion
2
- VERSION = '3.1.5'.freeze unless defined?(VERSION)
2
+ VERSION = '3.1.6'.freeze unless defined?(VERSION)
3
3
  end
@@ -1,5 +1,5 @@
1
1
  def require_directory(dir)
2
- Dir[File.join(dir, '*.rb')]&.sort&.each do |file|
2
+ Dir[File.join(dir, '*.rb')].each do |file|
3
3
  require file unless file == __FILE__
4
4
  end
5
5
  end
@@ -7,7 +7,6 @@ end
7
7
  require 'colorator'
8
8
  require 'jekyll'
9
9
  require 'jekyll_plugin_logger'
10
- require 'pry'
11
10
  require 'sorted_set'
12
11
 
13
12
  # require_directory __dir__
@@ -21,16 +20,9 @@ require_directory "#{__dir__}/tag"
21
20
  require_directory "#{__dir__}/jekyll_all_collections"
22
21
  require_directory "#{__dir__}/hooks"
23
22
 
24
- module JekyllSupport
25
- def self.redef_without_warning(const, value)
26
- send(:remove_const, const) if const_defined?(const)
27
- const_set const, value
28
- end
29
- end
30
-
31
23
  module ToString
32
24
  def to_s
33
- "#{self}.class.name"
25
+ self.class.name
34
26
  end
35
27
  end
36
28
 
@@ -41,6 +33,11 @@ module NoArgParsing
41
33
  end
42
34
 
43
35
  module JekyllSupport
36
+ def self.redef_without_warning(const, value)
37
+ send(:remove_const, const) if const_defined?(const)
38
+ const_set const, value
39
+ end
40
+
44
41
  class JekyllTag
45
42
  include JekyllSupportError
46
43
  include ToString
@@ -1,7 +1,8 @@
1
1
  module JekyllSupport
2
2
  # Base class for Jekyll tags
3
3
  class JekyllTag < Liquid::Tag
4
- attr_reader :argument_string, :helper, :highlighter_prefix, :highlighter_suffix, :jekyll_version, :line_number, :logger, :page, :raw_content, :site
4
+ attr_reader :argument_string, :helper, :highlighter_prefix, :highlighter_suffix, :jekyll_version, :line_number,
5
+ :logger, :page, :raw_content, :site
5
6
 
6
7
  # See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
7
8
  # @param tag_name [String] the name of the tag, which we usually know.
@@ -69,10 +70,6 @@ module JekyllSupport
69
70
  @argument_string = JekyllSupport.lookup_liquid_variables @logger, @helper.liquid_context, @argument_string.to_s.strip
70
71
  @helper.reinitialize @argument_string.to_s.strip
71
72
 
72
- # @argument_string = JekyllSupport.lookup_liquid_variables @logger, liquid_context, @argument_string # Is this redundant?
73
- # @argument_string.strip! # Is this redundant?
74
- # @helper.reinitialize @argument_string # Is this redundant?
75
-
76
73
  render_impl
77
74
  rescue StandardError => e
78
75
  e.shorten_backtrace
@@ -80,7 +77,7 @@ module JekyllSupport
80
77
  in_file_name = "in '#{file_name}' " if file_name
81
78
  of_page = "of '#{@page['path']}'" if @page
82
79
  @logger.error { "#{e.class} on line #{@line_number} #{of_page} while processing #{tag_name} #{in_file_name}- #{e.message}" }
83
- binding.pry if @pry_on_standard_error # rubocop:disable Lint/Debugger
80
+ binding.pry if @pry_on_standard_error && defined?(Pry) # rubocop:disable Lint/Debugger
84
81
  raise e if @die_on_standard_error
85
82
 
86
83
  <<~END_MSG
@@ -1,7 +1,5 @@
1
1
  module JekyllSupport
2
2
  class JekyllTagNoArgParsing < JekyllTag
3
- attr_reader :argument_string, :helper, :line_number, :logger, :page, :site
4
-
5
3
  def initialize(tag_name, argument_string, parse_context)
6
4
  class << self
7
5
  include NoArgParsing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_plugin_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
@@ -79,20 +79,6 @@ dependencies:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
- - !ruby/object:Gem::Dependency
83
- name: pry
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- type: :runtime
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
82
  - !ruby/object:Gem::Dependency
97
83
  name: sorted_set
98
84
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +102,7 @@ files:
116
102
  - ".rubocop.yml"
117
103
  - ATTIBUTION_NOTES.md
118
104
  - CHANGELOG.md
105
+ - FIXME.md
119
106
  - LICENSE.txt
120
107
  - README.md
121
108
  - Rakefile
@@ -182,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
169
  - !ruby/object:Gem::Version
183
170
  version: '0'
184
171
  requirements: []
185
- rubygems_version: 4.0.11
172
+ rubygems_version: 4.0.19
186
173
  specification_version: 4
187
174
  summary: Provides a framework for writing and testing Jekyll plugins
188
175
  test_files: