jekyll_plugin_support 0.4.0 → 0.5.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/.rubocop.yml +25 -3
- data/CHANGELOG.md +9 -0
- data/README.md +45 -8
- data/Rakefile +1 -1
- data/jekyll_plugin_support.gemspec +1 -13
- data/lib/jekyll_plugin_support/version.rb +2 -2
- data/lib/jekyll_plugin_support.rb +13 -5
- data/lib/jekyll_plugin_support_helper.rb +20 -7
- metadata +2 -72
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ad3dd2c6f00993d77f9db69e844a1f70e52c21ac1ef66c47294cc7683dee5743
         | 
| 4 | 
            +
              data.tar.gz: 121436f415bbcb0cddffa4f9b9c26f735e899aa733df38749e5be2856d56d238
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b6d186e5d5347b7857cef3318a152a4a9db75e57ebe7dc244dd0574542b47b2c97c4ba55af03065099cca94c3ca3fb3e666268fb4e2427683b94a0c058388a7b
         | 
| 7 | 
            +
              data.tar.gz: 1529488c906cc7c687356f22b65223f347d75eb35f1747742466166921b266c4f172233eaf638bb06af7fdf6fcd93e67d0f6ca25cbde0f98139edb05fb07d64a
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -1,11 +1,17 @@ | |
| 1 1 | 
             
            AllCops:
         | 
| 2 2 | 
             
              Exclude:
         | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
                - exe/**/*
         | 
| 4 | 
            +
                - vendor/**/*
         | 
| 5 | 
            +
                - Gemfile*
         | 
| 6 6 | 
             
              NewCops: enable
         | 
| 7 7 | 
             
              TargetRubyVersion: 2.6
         | 
| 8 8 |  | 
| 9 | 
            +
            Gemspec/DeprecatedAttributeAssignment:
         | 
| 10 | 
            +
              Enabled: false
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Gemspec/RequireMFA:
         | 
| 13 | 
            +
              Enabled: false
         | 
| 14 | 
            +
             | 
| 9 15 | 
             
            Layout/HashAlignment:
         | 
| 10 16 | 
             
              Enabled: false
         | 
| 11 17 |  | 
| @@ -15,5 +21,21 @@ Layout/LineLength: | |
| 15 21 | 
             
            Layout/MultilineMethodCallIndentation:
         | 
| 16 22 | 
             
              Enabled: false
         | 
| 17 23 |  | 
| 24 | 
            +
            Metrics/AbcSize:
         | 
| 25 | 
            +
              Max: 20
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Metrics/BlockLength:
         | 
| 28 | 
            +
              Exclude:
         | 
| 29 | 
            +
                - jekyll_plugin_support.gemspec
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            Metrics/MethodLength:
         | 
| 32 | 
            +
              Max: 25
         | 
| 33 | 
            +
             | 
| 18 34 | 
             
            Style/FrozenStringLiteralComment:
         | 
| 19 35 | 
             
              Enabled: false
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            Style/Documentation:
         | 
| 38 | 
            +
              Enabled: false
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            Style/TrailingCommaInHashLiteral:
         | 
| 41 | 
            +
              EnforcedStyleForMultiline: comma
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,12 @@ | |
| 1 | 
            +
            ## 0.5.0 / 2023-02-15
         | 
| 2 | 
            +
              * Plugins now register themselves
         | 
| 3 | 
            +
              * Plugins now report their name and version
         | 
| 4 | 
            +
              * `@layout`, `@paginator`, and `@theme` have values if supported by the version of Jekyll, and they are active. (See [Jekyll docs](https://jekyllrb.com/docs/variables/).)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            ## 0.4.1 / 2023-02-14
         | 
| 7 | 
            +
              * Fixed several problems
         | 
| 8 | 
            +
              * Added demo site
         | 
| 9 | 
            +
             | 
| 1 10 | 
             
            ## 0.4.0 / 2023-02-12
         | 
| 2 11 | 
             
             * `render_impl` for tags and blocks now predefines more instance variables:
         | 
| 3 12 | 
             
               - `@liquid_context` – passed to `render`
         | 
    
        data/README.md
    CHANGED
    
    | @@ -50,11 +50,11 @@ and can parse parameters passed to the tag / block tag, [as described here](http | |
| 50 50 | 
             
            ```ruby
         | 
| 51 51 | 
             
            # For a tag:
         | 
| 52 52 | 
             
            module Jekyll
         | 
| 53 | 
            -
              class  | 
| 53 | 
            +
              class MyTag < JekyllSupport::JekyllTag
         | 
| 54 | 
            +
                VERSION = '0.1.0'.freeze
         | 
| 55 | 
            +
             | 
| 54 56 | 
             
                def render_impl
         | 
| 55 | 
            -
                   | 
| 56 | 
            -
                  @break  = @helper.parameter_specified? 'break'
         | 
| 57 | 
            -
                  # ...
         | 
| 57 | 
            +
                  # Your code here
         | 
| 58 58 | 
             
                end
         | 
| 59 59 | 
             
              end
         | 
| 60 60 | 
             
            end
         | 
| @@ -63,11 +63,34 @@ end | |
| 63 63 | 
             
            ```ruby
         | 
| 64 64 | 
             
            # For a tag block:
         | 
| 65 65 | 
             
            module Jekyll
         | 
| 66 | 
            -
              class  | 
| 66 | 
            +
              class MyBlock < JekyllSupport::JekyllBlock
         | 
| 67 | 
            +
                VERSION = '0.1.0'.freeze
         | 
| 68 | 
            +
             | 
| 67 69 | 
             
                def render_impl(text)
         | 
| 68 | 
            -
                   | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 70 | 
            +
                  # Your code here
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
            end
         | 
| 74 | 
            +
            ```
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            Note that each tag or tag block must define a constant called `VERSION`.
         | 
| 77 | 
            +
            If your plugin is packaged as a gem, then you might need to include `version.rb` into the plugin class.
         | 
| 78 | 
            +
            For example, if `lib/my_plugin/version.rb` looks like this:
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            ```ruby
         | 
| 81 | 
            +
            module MyPluginVersion
         | 
| 82 | 
            +
              VERSION = '0.5.0'.freeze
         | 
| 83 | 
            +
            end
         | 
| 84 | 
            +
            ```
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            Then your plugin can incorporate the `VERSION` constant into your plugin like this:
         | 
| 87 | 
            +
            ```ruby
         | 
| 88 | 
            +
            module Jekyll
         | 
| 89 | 
            +
              class MyBlock < JekyllSupport::JekyllBlock
         | 
| 90 | 
            +
                include MyPluginVersion
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                def render_impl(text)
         | 
| 93 | 
            +
                  # Your code here
         | 
| 71 94 | 
             
                end
         | 
| 72 95 | 
             
              end
         | 
| 73 96 | 
             
            end
         | 
| @@ -109,6 +132,20 @@ jekyll_plugin_support (0.1.0) | |
| 109 132 | 
             
            ```
         | 
| 110 133 |  | 
| 111 134 |  | 
| 135 | 
            +
            ## Test
         | 
| 136 | 
            +
            A test website is provided in the `demo` directory.
         | 
| 137 | 
            +
             1. Set breakpoints.
         | 
| 138 | 
            +
             | 
| 139 | 
            +
             2. Initiate a debug session from the command line:
         | 
| 140 | 
            +
                ```shell
         | 
| 141 | 
            +
                $ bin/attach demo
         | 
| 142 | 
            +
                ```
         | 
| 143 | 
            +
             | 
| 144 | 
            +
              3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch configuration called `Attach rdebug-ide`.
         | 
| 145 | 
            +
             | 
| 146 | 
            +
              4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
         | 
| 147 | 
            +
             | 
| 148 | 
            +
             | 
| 112 149 | 
             
            ### Build and Push to RubyGems
         | 
| 113 150 | 
             
            To release a new version,
         | 
| 114 151 | 
             
              1. Update the version number in `version.rb`.
         | 
    
        data/Rakefile
    CHANGED
    
    
| @@ -21,26 +21,14 @@ Gem::Specification.new do |spec| | |
| 21 21 |  | 
| 22 22 | 
             
                Thanks for installing #{spec.name}!
         | 
| 23 23 |  | 
| 24 | 
            -
              END_MESSAGE
         | 
| 25 | 
            -
              spec.post_install_message = <<~END_MESSAGE
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                Thanks for installing #{spec.name}!
         | 
| 28 | 
            -
             | 
| 29 24 | 
             
              END_MESSAGE
         | 
| 30 25 | 
             
              spec.require_paths = ['lib']
         | 
| 31 26 | 
             
              spec.required_ruby_version = '>= 2.6.0'
         | 
| 32 27 | 
             
              spec.summary = 'Provides support for writing Jekyll plugins.'
         | 
| 33 28 | 
             
              spec.test_files = spec.files.grep %r{^(test|spec|features)/}
         | 
| 34 | 
            -
              spec.version =  | 
| 29 | 
            +
              spec.version = JekyllPluginSupportVersion::VERSION
         | 
| 35 30 |  | 
| 36 31 | 
             
              spec.add_dependency 'jekyll', '>= 3.5.0'
         | 
| 37 32 | 
             
              spec.add_dependency 'jekyll_plugin_logger'
         | 
| 38 33 | 
             
              spec.add_dependency 'key-value-parser'
         | 
| 39 | 
            -
             | 
| 40 | 
            -
              spec.add_development_dependency 'debase'
         | 
| 41 | 
            -
              spec.add_development_dependency 'rspec-match_ignoring_whitespace'
         | 
| 42 | 
            -
              # spec.add_development_dependency 'rubocop-jekyll'
         | 
| 43 | 
            -
              spec.add_development_dependency 'rubocop-rake'
         | 
| 44 | 
            -
              spec.add_development_dependency 'rubocop-rspec'
         | 
| 45 | 
            -
              spec.add_development_dependency 'ruby-debug-ide'
         | 
| 46 34 | 
             
            end
         | 
| @@ -1,3 +1,3 @@ | |
| 1 | 
            -
            module  | 
| 2 | 
            -
              VERSION = '0. | 
| 1 | 
            +
            module JekyllPluginSupportVersion
         | 
| 2 | 
            +
              VERSION = '0.5.0'.freeze
         | 
| 3 3 | 
             
            end
         | 
| @@ -31,7 +31,7 @@ module JekyllSupport | |
| 31 31 | 
             
                # @return [String]
         | 
| 32 32 | 
             
                def render(liquid_context)
         | 
| 33 33 | 
             
                  text = super
         | 
| 34 | 
            -
                  @liquid_context = liquid_context
         | 
| 34 | 
            +
                  @helper.liquid_context = liquid_context
         | 
| 35 35 |  | 
| 36 36 | 
             
                  # The names of front matter variables are hash keys for @page
         | 
| 37 37 | 
             
                  @page = liquid_context.registers[:page] # Jekyll::Drops::DocumentDrop
         | 
| @@ -74,12 +74,20 @@ module JekyllSupport | |
| 74 74 |  | 
| 75 75 | 
             
                # Method prescribed by the Jekyll plugin lifecycle.
         | 
| 76 76 | 
             
                def render(liquid_context)
         | 
| 77 | 
            -
                  @liquid_context = liquid_context
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                  @ | 
| 77 | 
            +
                  @helper.liquid_context = liquid_context
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  @envs      = liquid_context.environments.first
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  @layout    = @envs[:layout]
         | 
| 82 | 
            +
                  @paginator = @envs[:paginator]
         | 
| 83 | 
            +
                  @theme     = @envs[:theme]
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  @page      = liquid_context.registers[:page]
         | 
| 86 | 
            +
                  @site      = liquid_context.registers[:site]
         | 
| 87 | 
            +
             | 
| 80 88 | 
             
                  @config = @site.config
         | 
| 81 | 
            -
                  @envs = liquid_context.environments.first
         | 
| 82 89 | 
             
                  @mode = @config['env']['JEKYLL_ENV'] || 'development'
         | 
| 90 | 
            +
             | 
| 83 91 | 
             
                  render_impl
         | 
| 84 92 | 
             
                end
         | 
| 85 93 |  | 
| @@ -1,5 +1,3 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 1 | 
             
            require 'shellwords'
         | 
| 4 2 | 
             
            require 'key_value_parser'
         | 
| 5 3 |  | 
| @@ -7,17 +5,32 @@ require 'key_value_parser' | |
| 7 5 | 
             
            class JekyllPluginHelper
         | 
| 8 6 | 
             
              attr_reader :argv, :keys_values, :liquid_context, :logger, :markup, :params, :tag_name
         | 
| 9 7 |  | 
| 10 | 
            -
              # Expand  | 
| 8 | 
            +
              # Expand an environment variable reference
         | 
| 11 9 | 
             
              def self.expand_env(str, die_if_undefined: false)
         | 
| 12 10 | 
             
                str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
         | 
| 13 11 | 
             
                  envar = Regexp.last_match(1)
         | 
| 14 12 | 
             
                  raise HrefError, "jekyll_href error: #{envar} is undefined".red, [] \
         | 
| 15 13 | 
             
                    if !ENV.key?(envar) && die_if_undefined # Suppress stack trace
         | 
| 16 14 |  | 
| 17 | 
            -
                  ENV | 
| 15 | 
            +
                  ENV.fetch(envar, nil)
         | 
| 18 16 | 
             
                end
         | 
| 19 17 | 
             
              end
         | 
| 20 18 |  | 
| 19 | 
            +
              def self.register(klass, name)
         | 
| 20 | 
            +
                abort("Error: The #{name} plugin does not define VERSION") \
         | 
| 21 | 
            +
                  unless klass.const_defined?(:VERSION)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                version = klass.const_get(:VERSION)
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                abort("Error: The #{name} plugin is not an instance of JekyllSupport::JekyllBlock or JekyllSupport::JekyllTag") \
         | 
| 26 | 
            +
                  unless klass.instance_of?(Class) &&
         | 
| 27 | 
            +
                         (klass.ancestors.include?(JekyllSupport::JekyllBlock) || \
         | 
| 28 | 
            +
                          klass.ancestors.include?(JekyllSupport::JekyllTag))
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                Liquid::Template.register_tag(name, klass)
         | 
| 31 | 
            +
                PluginMetaLogger.instance.info { "Loaded #{name} v#{version} plugin." }
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 21 34 | 
             
              # strip leading and trailing quotes if present
         | 
| 22 35 | 
             
              def self.remove_quotes(string)
         | 
| 23 36 | 
             
                string.strip.gsub(/\A'|\A"|'\Z|"\Z/, '').strip if string
         | 
| @@ -35,14 +48,14 @@ class JekyllPluginHelper | |
| 35 48 | 
             
              def initialize(tag_name, markup, logger)
         | 
| 36 49 | 
             
                @tag_name = tag_name
         | 
| 37 50 | 
             
                @logger = logger
         | 
| 38 | 
            -
                @logger.debug { "@keys_values='#{@keys_values}'" }
         | 
| 39 51 | 
             
                reinitialize(markup.strip)
         | 
| 52 | 
            +
                @logger.debug { "@keys_values='#{@keys_values}'" }
         | 
| 40 53 | 
             
              end
         | 
| 41 54 |  | 
| 42 55 | 
             
              def reinitialize(markup)
         | 
| 43 56 | 
             
                # @keys_values was a Hash[Symbol, String|Boolean] but now it is Hash[String, String|Boolean]
         | 
| 44 | 
            -
                @markup = markup | 
| 45 | 
            -
                @argv = Shellwords.split( | 
| 57 | 
            +
                @markup = markup
         | 
| 58 | 
            +
                @argv = Shellwords.split(self.class.expand_env(markup))
         | 
| 46 59 | 
             
                @keys_values = KeyValueParser \
         | 
| 47 60 | 
             
                  .new({}, { array_values: false, normalize_keys: false, separator: /=/ }) \
         | 
| 48 61 | 
             
                  .parse(@argv)
         | 
    
        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.5.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-02- | 
| 11 | 
            +
            date: 2023-02-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: jekyll
         | 
| @@ -52,76 +52,6 @@ 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'
         | 
| 97 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            -
              name: rubocop-rspec
         | 
| 99 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            -
                requirements:
         | 
| 101 | 
            -
                - - ">="
         | 
| 102 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            -
                    version: '0'
         | 
| 104 | 
            -
              type: :development
         | 
| 105 | 
            -
              prerelease: false
         | 
| 106 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            -
                requirements:
         | 
| 108 | 
            -
                - - ">="
         | 
| 109 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 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'
         | 
| 125 55 | 
             
            description:
         | 
| 126 56 | 
             
            email:
         | 
| 127 57 | 
             
            - mslinn@mslinn.com
         |