jekyll_plugin_template 0.1.3 → 0.2.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: 589cb215e8458e084b40967bd4b4360c457bb65a3fd01c9830af52a17d5c3bab
4
- data.tar.gz: 323ea35b37a006144ccb10227bff0f49a048a098670f79ee51dda4df4787fb4b
3
+ metadata.gz: 1b8804da5578887e2b1dd581de8ad30d4e7e4f4ed4a9a4d6c517e710f52a94c3
4
+ data.tar.gz: 9237ebfda58f9da784c9c19c13f60ca9f4b7fcaa62a818b9b383c58b66a931ae
5
5
  SHA512:
6
- metadata.gz: 3d0850c46f853f9925e99e92f423e1918303f4ae253b5f45bad8711e614d3cfc76824b7f369d0d6b7a82282440647fd1a9c6d4d5ac66b3605f56ca2d4f62cf41
7
- data.tar.gz: 59fdefd6d4baff1526db8065f2691b01c86a0d889d3aaed5f81ff75adb2ea83da5982b23198fa90a3e167815ff8285d8879841078ebac374ae673cc30f8fba37
6
+ metadata.gz: 8a034a2186a0cd8835a96de90c959da5969b8703d8321c86cd3ed5a34fc8473d8ef6363c67aa6ce51a5214b97e97d19be8d790f8d22667ff9eb460f6279e27be
7
+ data.tar.gz: 2286531c8782695985b19746a019f1215c257ea2c4ffee55bf2fdacf38d3555c85f8a15cd3145f30d466a67c6d31d7ba522b86b4baae1d6779bafeecb9bba86b
data/.rubocop.yml CHANGED
@@ -22,6 +22,9 @@ Layout/HashAlignment:
22
22
  Layout/LineLength:
23
23
  Max: 150
24
24
 
25
+ Metrics/AbcSize:
26
+ Max: 20
27
+
25
28
  Metrics/BlockLength:
26
29
  Max: 50
27
30
 
@@ -31,5 +34,11 @@ Metrics/MethodLength:
31
34
  Metrics/ModuleLength:
32
35
  Enabled: false
33
36
 
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ Style/FrozenStringLiteralComment:
41
+ Enabled: false
42
+
34
43
  Style/StringLiterals:
35
44
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
+ ## 0.2.0 / 2023-02-16
2
+ * Updated to `jekyll_plugin_support` v0.5.0.
3
+
4
+ ## 0.1.3 / 2023-02-12
5
+ * Added `grin`, `horns`, `open`, `poop` and `sad` emojis.
6
+ * Now based on [`JekyllSupport::JekyllTag`](https://mslinn.com/jekyll/10200-jekyll-plugin-support.html) instead of `Liquid::Tag`.
7
+ * Added `list` and `emoji_and_name` options.
8
+ * Updated `demo` to exercise the new features.
9
+ * `Demo` now builds the plugins prior to each run.
10
+
1
11
  ## 0.1.3 / 2022-04-15
2
12
  * Renamed `lib/jekyll_tag_plugins.rb` to `lib/jekyll_block_tag_plugin.rb`
3
13
  * Added `lib/jekyll_tag_plugin.rb`
14
+
4
15
  ## 0.1.2 / 2022-04-05
5
16
  * Initial version published
6
17
  * `bin/run_this_first` is unfinished but plugins work
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "bundler/gem_tasks"
4
2
  require "rspec/core/rake_task"
5
3
 
@@ -1,46 +1,42 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/jekyll_plugin_template/version"
1
+ require_relative 'lib/jekyll_plugin_template/version'
4
2
 
5
3
  Gem::Specification.new do |spec|
6
- github = "https://github.com/mslinn/jekyll_plugin_template"
4
+ github = 'https://github.com/mslinn/jekyll_plugin_template'
7
5
 
8
- spec.authors = ["Firstname Lastname"]
9
- spec.bindir = "bin"
6
+ spec.authors = ['Firstname Lastname']
7
+ spec.bindir = 'bin'
10
8
  spec.description = <<~END_OF_DESC
11
9
  Expand on what spec.summary says.
12
10
  END_OF_DESC
13
- spec.email = ["email@email.com"]
11
+ spec.email = ['email@email.com']
14
12
  spec.executables = []
15
13
 
16
14
  # Specify which files should be added to the gem when it is released.
17
- spec.files = Dir[".rubocop.yml", "LICENSE.*", "Rakefile", "{lib,spec}/**/*", "*.gemspec", "*.md"]
15
+ spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
18
16
 
19
- spec.homepage = "https://www.mslinn.com/blog/2020/12/30/jekyll-plugin-template-collection.html"
20
- spec.license = "CC0-1.0"
17
+ spec.homepage = 'https://www.mslinn.com/blog/2020/12/30/jekyll-plugin-template-collection.html'
18
+ spec.license = 'CC0-1.0'
21
19
  spec.metadata = {
22
- "allowed_push_host" => "https://rubygems.org",
23
- "bug_tracker_uri" => "#{github}/issues",
24
- "changelog_uri" => "#{github}/CHANGELOG.md",
25
- "homepage_uri" => spec.homepage,
26
- "source_code_uri" => github,
20
+ 'allowed_push_host' => 'https://rubygems.org',
21
+ 'bug_tracker_uri' => "#{github}/issues",
22
+ 'changelog_uri' => "#{github}/CHANGELOG.md",
23
+ 'homepage_uri' => spec.homepage,
24
+ 'source_code_uri' => github,
27
25
  }
28
- spec.name = "jekyll_plugin_template"
29
- spec.require_paths = ["lib"]
30
- spec.required_ruby_version = ">= 2.6.0"
31
- spec.summary = "Write a short summary; RubyGems requires one."
26
+ spec.name = 'jekyll_plugin_template'
27
+ spec.require_paths = ['lib']
28
+ spec.required_ruby_version = '>= 2.6.0'
29
+ spec.summary = 'Write a short summary; RubyGems requires one.'
32
30
  spec.version = JekyllPluginTemplateVersion::VERSION
33
31
 
34
- spec.add_dependency "jekyll", ">= 3.5.0"
35
- spec.add_dependency "jekyll_plugin_logger"
36
- spec.add_dependency "key-value-parser"
37
- spec.add_dependency "git"
38
- spec.add_dependency "nokogiri"
39
- spec.add_dependency "os"
40
- spec.add_dependency "shellwords"
41
- spec.add_dependency "talk_like_a_pirate", ">= 0.2.2"
42
- spec.add_dependency "tty-prompt"
32
+ spec.add_dependency 'jekyll', '>= 3.5.0'
33
+ spec.add_dependency 'jekyll_plugin_support', '~> 0.5.0'
34
+ spec.add_dependency 'git'
35
+ spec.add_dependency 'nokogiri'
36
+ spec.add_dependency 'os'
37
+ spec.add_dependency 'talk_like_a_pirate', '~> 0.2.2'
38
+ spec.add_dependency 'tty-prompt'
43
39
 
44
- # spec.add_development_dependency "debase"
45
- # spec.add_development_dependency "ruby-debug-ide"
40
+ # spec.add_development_dependency 'debase'
41
+ # spec.add_development_dependency 'ruby-debug-ide'
46
42
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # Testing...
4
2
  module CategoryCombiner
5
3
  # For each catagory, makes a combined page from the collection pages, saves into _site/combined/#{collection.label}.html.
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # Inspired by the badly broken example on https://jekyllrb.com/docs/plugins/generators/, and completely redone so it works.
4
2
  module CategoryIndexGenerator
5
3
  # Creates an index page for each catagory, plus a main index, all within a directory called _site/categories.
@@ -12,24 +10,24 @@ module CategoryIndexGenerator
12
10
  # This plugin is disabled unless _config.yml contains an entry for category_generator_enable and the value is not false
13
11
  return if site.config['category_generator_enable']
14
12
 
15
- return if site.config['env']['JEKYLL_ENV'] == "production"
13
+ return if site.config['env']['JEKYLL_ENV'] == 'production'
16
14
 
17
- index = Jekyll::PageWithoutAFile.new(site, site.source, 'categories', "index.html")
18
- index.data['layout'] = "default"
19
- index.data['title'] = "Post Categories"
20
- index.content = "<p>"
15
+ index = Jekyll::PageWithoutAFile.new(site, site.source, 'categories', 'index.html')
16
+ index.data['layout'] = 'default'
17
+ index.data['title'] = 'Post Categories'
18
+ index.content = '<p>'
21
19
 
22
20
  site.categories.each do |category, posts|
23
21
  new_page = Jekyll::PageWithoutAFile.new(site, site.source, 'categories', "#{category}.html")
24
- new_page.data['layout'] = "default"
22
+ new_page.data['layout'] = 'default'
25
23
  new_page.data['title'] = "Category #{category} Posts"
26
- new_page.content = "<p>" + posts.map do |post|
24
+ new_page.content = '<p>' + posts.map do |post|
27
25
  "<a href='#{post.url}'>#{post.data['title']}</a><br>"
28
26
  end.join("\n") + "</p>\n"
29
27
  site.pages << new_page
30
28
  index.content += "<a href='#{category}.html'>#{category}</a><br>\n"
31
29
  end
32
- index.content += "</p>"
30
+ index.content += '</p>'
33
31
  site.pages << index
34
32
  end
35
33
  # rubocop:enable Style/StringConcatenation, Metrics/AbcSize
data/lib/dumpers.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # Methods to display Jekyll variable contents
4
2
  module Dumpers
5
3
  # See https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
@@ -8,7 +6,7 @@ module Dumpers
8
6
  # Metadata is a hash with at least these keys: output[Boolean], permalink[String]
9
7
  # selected methods: collection_dir, directory, entries, exists?, files, filtered_entries, relative_directory
10
8
  def collection_as_string(collection, indent_spaces)
11
- indent = " " * indent_spaces
9
+ indent = ' ' * indent_spaces
12
10
  result = <<~END_COLLECTION
13
11
  '#{collection.label}' collection within '#{collection.relative_directory}' subdirectory
14
12
  #{indent}Directory: #{collection.directory}
@@ -1,18 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll_plugin_logger"
4
- require "key_value_parser"
5
- require "shellwords"
1
+ require 'jekyll_plugin_support'
6
2
 
7
3
  module JekyllPluginBlockTagTemplate
8
- PLUGIN_NAME = "block_tag_template"
4
+ PLUGIN_NAME = 'block_tag_template'
9
5
  end
10
6
 
11
7
  # This is the module-level description.
12
8
  #
13
9
  # @example Heading for this example
14
10
  # Describe what this example does
15
- # {% block_tag_template "parameter" %}
11
+ # {% block_tag_template 'parameter' %}
16
12
  # Hello, world!
17
13
  # {% endblock_tag_template %}
18
14
  #
@@ -24,7 +20,9 @@ end
24
20
 
25
21
  module JekyllBlockTagPlugin
26
22
  # This class implements the Jekyll block tag functionality
27
- class MyBlock < Liquid::Block
23
+ class MyBlock < JekyllSupport::JekyllBlock
24
+ include JekyllPluginTemplateVersion
25
+
28
26
  # See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
29
27
  # @param tag_name [String] the name of the tag, which we already know.
30
28
  # @param argument_string [String] the arguments from the tag, as a single string.
@@ -70,12 +68,12 @@ module JekyllBlockTagPlugin
70
68
  # Method prescribed by the Jekyll plugin lifecycle.
71
69
  # @param liquid_context [Liquid::Context]
72
70
  # @return [String]
73
- def render(liquid_context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
71
+ def render(liquid_context) # rubocop:disable Metrics/AbcSize
74
72
  content = super # This underdocumented assignment returns the text within the block.
75
73
 
76
74
  @site = liquid_context.registers[:site]
77
75
  @config = @site.config
78
- @mode = @config.dig("env", "JEKYLL_ENV") || "development"
76
+ @mode = @config.dig('env', 'JEKYLL_ENV') || 'development'
79
77
 
80
78
  # variables defined in pages are stored as hash values in liquid_context
81
79
  _assigned_page_variable = liquid_context['assigned_page_variable']
@@ -101,13 +99,12 @@ module JekyllBlockTagPlugin
101
99
 
102
100
  # Compute the return value of this Jekyll tag
103
101
  <<~HEREDOC
104
- <p style="color: green; background-color: yellow; padding: 1em; border: solid thin grey;">
102
+ <p style='color: green; background-color: yellow; padding: 1em; border: solid thin grey;'>
105
103
  #{content} #{@param1}
106
104
  </p>
107
105
  HEREDOC
108
106
  end
107
+
108
+ JekyllPluginHelper.register(self, JekyllPluginBlockTagTemplate::PLUGIN_NAME)
109
109
  end
110
110
  end
111
-
112
- PluginMetaLogger.instance.info { "Loaded #{JekyllPluginBlockTagTemplate::PLUGIN_NAME} v#{JekyllPluginTemplateVersion::VERSION} plugin." }
113
- Liquid::Template.register_tag(JekyllPluginBlockTagTemplate::PLUGIN_NAME, JekyllBlockTagPlugin::MyBlock)
@@ -1,6 +1,4 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll_plugin_logger"
1
+ require 'jekyll_plugin_logger'
4
2
 
5
3
  # @author Copyright 2020 {https://www.mslinn.com Michael Slinn}
6
4
  # Template for Jekyll filters.
@@ -14,12 +12,12 @@ module JekyllFilterTemplate
14
12
  # @param input_string [String].
15
13
  # @return [String] empty string if input_string has no contents except whitespace.
16
14
  # @example Use.
17
- # {{ "joy" | my_filter_template }} => <a href='https://www.google.com/search?q=joy' target='_blank' rel='nofollow'>joy</a>
15
+ # {{ 'joy' | my_filter_template }} => <a href='https://www.google.com/search?q=joy' target='_blank' rel='nofollow'>joy</a>
18
16
  def my_filter_template(input_string)
19
17
  # @context[Liquid::Context] is available here to look up variables defined in front matter, templates, page, etc.
20
18
 
21
19
  JekyllFilterTemplate.logger.debug do
22
- "Defined filters are: " + self.class # rubocop:disable Style/StringConcatenation
20
+ 'Defined filters are: ' + self.class # rubocop:disable Style/StringConcatenation
23
21
  .class_variable_get('@@global_strainer')
24
22
  .filter_methods.instance_variable_get('@hash')
25
23
  .map { |k, _v| k }
@@ -29,7 +27,7 @@ module JekyllFilterTemplate
29
27
  input_string.strip!
30
28
  JekyllFilterTemplate.logger.debug "input_string=#{input_string}"
31
29
  if input_string.empty?
32
- ""
30
+ ''
33
31
  else
34
32
  "<a href='https://www.google.com/search?q=#{input_string}' target='_blank' rel='nofollow'>#{input_string}</a>"
35
33
  end
@@ -1,10 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support"
4
- require "active_support/inflector"
1
+ require 'active_support'
2
+ require 'active_support/inflector'
5
3
  require 'confidential_info_redactor'
6
- require "nokogiri"
7
- require "talk_like_a_pirate"
4
+ require 'nokogiri'
5
+ require 'talk_like_a_pirate'
8
6
 
9
7
  # Sample Jekyll Hook plugins
10
8
  module JekyllHookExamples
@@ -19,7 +17,7 @@ module JekyllHookExamples
19
17
  next unless webpage.data['pirate_talk']
20
18
 
21
19
  html = Nokogiri.HTML(webpage.output)
22
- html.css("p").each do |node|
20
+ html.css('p').each do |node|
23
21
  node.content = TalkLikeAPirate.translate(node.content)
24
22
  end
25
23
  webpage.output = html
@@ -43,9 +41,9 @@ module JekyllHookExamples
43
41
  def redact_all(content)
44
42
  tokens = ConfidentialInfoRedactor::Extractor.new.extract(content)
45
43
  ConfidentialInfoRedactor::Redactor.new(
46
- number_text: wrap(" number"), # This redactor is over-eager
47
- date_text: wrap(" date"),
48
- token_text: wrap(""),
44
+ number_text: wrap(' number'), # This redactor is over-eager
45
+ date_text: wrap(' date'),
46
+ token_text: wrap(''),
49
47
  tokens: tokens
50
48
  ).redact(content)
51
49
  end
@@ -55,11 +53,11 @@ module JekyllHookExamples
55
53
  # Uncomment the following lines, rebuild the plugin and view http://localhost:4444/
56
54
  # to see these hooks in action:
57
55
  #
58
- # Convert "Jekyll" to "Awesome Jekyll"
56
+ # Convert 'Jekyll' to 'Awesome Jekyll'
59
57
  # Jekyll::Hooks.register(:documents, :post_render, &modify_output)
60
58
  # Jekyll::Hooks.register(:pages, :post_render, &modify_output)
61
59
 
62
- # Convert "English" to "Pirate Talk"
60
+ # Convert 'English' to 'Pirate Talk'
63
61
  Jekyll::Hooks.register(:documents, :post_render, &pirate_translator)
64
62
  Jekyll::Hooks.register(:pages, :post_render, &pirate_translator)
65
63
 
data/lib/jekyll_hooks.rb CHANGED
@@ -1,11 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll_plugin_logger"
4
- require_relative "jekyll_plugin_template/version"
5
- require_relative "dumpers"
1
+ require 'jekyll_plugin_logger'
2
+ require_relative 'jekyll_plugin_template/version'
3
+ require_relative 'dumpers'
6
4
 
7
5
  module JekyllPluginHooksName
8
- PLUGIN_NAME = "jekyll_plugin_hooks"
6
+ PLUGIN_NAME = 'jekyll_plugin_hooks'
9
7
  end
10
8
 
11
9
  # The Jekyll processing steps are described in https://jekyllrb.com/tutorials/orderofinterpretation/
@@ -38,8 +36,8 @@ module JekyllPluginHooks
38
36
  # However, this hook will not be called unless safe mode is OFF, so define loggers in the :site :after_init hook instead
39
37
  Jekyll::Hooks.register(:site, :after_reset, priority: :normal) do |site|
40
38
  @log_site ||= PluginMetaLogger.instance.new_logger(:SiteHooks, PluginMetaLogger.instance.config)
41
- @log_site.info { "Jekyll::Hooks.register(:site, :after_reset) invoked." }
42
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :after_reset)", site)
39
+ @log_site.info { 'Jekyll::Hooks.register(:site, :after_reset) invoked.' }
40
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :after_reset)', site)
43
41
  end
44
42
 
45
43
  # This hook is called just after the site initializes.
@@ -52,17 +50,17 @@ module JekyllPluginHooks
52
50
  @log_posts = PluginMetaLogger.instance.new_logger(:PostHooks, PluginMetaLogger.instance.config)
53
51
  @log_site ||= PluginMetaLogger.instance.new_logger(:SiteHooks, PluginMetaLogger.instance.config)
54
52
 
55
- @log_site.info { "Loaded #{JekyllPluginHooksName::PLUGIN_NAME} v#{JekyllPluginTemplate::VERSION} plugin." }
56
- @log_site.info { "Jekyll::Hooks.register(:site, :after_init) invoked." }
57
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :after_init)", site)
53
+ @log_site.info { "Loaded #{JekyllPluginHooksName::PLUGIN_NAME} v#{JekyllPluginTemplateVersion::VERSION} plugin." }
54
+ @log_site.info { 'Jekyll::Hooks.register(:site, :after_init) invoked.' }
55
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :after_init)', site)
58
56
  end
59
57
 
60
58
  # Called after all source files have been read and loaded from disk.
61
59
  # This is a good hook for enriching posts;
62
60
  # for example, adding links to author pages or adding posts to author pages.
63
61
  Jekyll::Hooks.register(:site, :post_read, priority: :normal) do |site|
64
- @log_site.info { "Jekyll::Hooks.register(:site, :post_read) invoked." }
65
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :post_read)", site)
62
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_read) invoked.' }
63
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_read)', site)
66
64
  end
67
65
 
68
66
  # Called before rendering the whole site
@@ -72,10 +70,10 @@ module JekyllPluginHooks
72
70
  # @param payload [Hash] according to the docs, payload is a hash containing the variables available during rendering; the hash can be modified here.
73
71
  # However, the debugger shows payload has type Jekyll::UnifiedPayloadDrop
74
72
  Jekyll::Hooks.register(:site, :pre_render, priority: :normal) do |site, payload|
75
- @log_site.info { "Jekyll::Hooks.register(:site, :pre_render) invoked." }
76
- @log_site.debug { dump(":site, :pre_render payload", payload) }
77
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :pre_render)", site)
78
- Dumpers.dump_payload(@log_site, "Jekyll::Hooks.register(:site, :pre_render)", payload)
73
+ @log_site.info { 'Jekyll::Hooks.register(:site, :pre_render) invoked.' }
74
+ @log_site.debug { dump(':site, :pre_render payload', payload) }
75
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :pre_render)', site)
76
+ Dumpers.dump_payload(@log_site, 'Jekyll::Hooks.register(:site, :pre_render)', payload)
79
77
  end
80
78
 
81
79
  # Called after rendering the whole site, but before writing any files.
@@ -87,16 +85,16 @@ module JekyllPluginHooks
87
85
  # :documents and :pages, whereas the :pages and :documents hooks are called once for each page and document.
88
86
  # @param payload [Hash] contains final values of variables after rendering the entire site (useful for sitemaps, feeds, etc).
89
87
  Jekyll::Hooks.register(:site, :post_render, priority: :normal) do |site, payload|
90
- @log_site.info { "Jekyll::Hooks.register(:site, :post_render) invoked." }
91
- @log_site.debug { dump(":site, :post_render payload", payload) }
92
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :post_render)", site)
93
- Dumpers.dump_payload(@log_site, "Jekyll::Hooks.register(:site, :post_render)", payload)
88
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_render) invoked.' }
89
+ @log_site.debug { dump(':site, :post_render payload', payload) }
90
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_render)', site)
91
+ Dumpers.dump_payload(@log_site, 'Jekyll::Hooks.register(:site, :post_render)', payload)
94
92
  end
95
93
 
96
94
  # Called after writing all of the rendered files to disk
97
95
  Jekyll::Hooks.register(:site, :post_write, priority: :normal) do |site|
98
- @log_site.info { "Jekyll::Hooks.register(:site, :post_write) invoked." }
99
- Dumpers.dump_site(@log_site, "Jekyll::Hooks.register(:site, :post_write)", site)
96
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_write) invoked.' }
97
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_write)', site)
100
98
  end
101
99
 
102
100
  ########## :pages hooks
@@ -105,34 +103,34 @@ module JekyllPluginHooks
105
103
 
106
104
  # Called whenever a page is initialized
107
105
  Jekyll::Hooks.register(:pages, :post_init, priority: :normal) do |page|
108
- @log_pages.info { "Jekyll::Hooks.register(:pages, :post_init) invoked." }
109
- Dumpers.dump_page(@log_pages, "Jekyll::Hooks.register(:pages, :post_init)", page)
106
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_init) invoked.' }
107
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_init)', page)
110
108
  end
111
109
 
112
110
  # Called just before rendering a page
113
111
  Jekyll::Hooks.register(:pages, :pre_render, priority: :normal) do |page, payload|
114
- @log_pages.info { "Jekyll::Hooks.register(:pages, :pre_render) invoked." }
115
- Dumpers.dump_page(@log_pages, "Jekyll::Hooks.register(:pages, :pre_render)", page)
116
- Dumpers.dump_payload(@log_pages, ":pages, :pre_render payload", payload)
112
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :pre_render) invoked.' }
113
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :pre_render)', page)
114
+ Dumpers.dump_payload(@log_pages, ':pages, :pre_render payload', payload)
117
115
  end
118
116
 
119
117
  # Called after converting the page content, but before rendering the page layout
120
118
  Jekyll::Hooks.register(:pages, :post_convert, priority: :normal) do |page|
121
- @log_pages.info { "Jekyll::Hooks.register(:pages, :post_convert) invoked." }
122
- Dumpers.dump_page(@log_pages, "Jekyll::Hooks.register(:pages, :post_convert)", page)
119
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_convert) invoked.' }
120
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_convert)', page)
123
121
  end
124
122
 
125
123
  # Called after rendering a page, but before writing it to disk
126
124
  Jekyll::Hooks.register(:pages, :post_render, priority: :normal) do |page|
127
125
  page.site.safe = true
128
- @log_pages.info { "Jekyll::Hooks.register(:pages, :post_render) invoked." }
129
- Dumpers.dump_page(@log_pages, "Jekyll::Hooks.register(:pages, :post_render)", page)
126
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_render) invoked.' }
127
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_render)', page)
130
128
  end
131
129
 
132
130
  # Called after writing a page to disk
133
131
  Jekyll::Hooks.register(:pages, :post_write, priority: :normal) do |page|
134
- @log_pages.info { "Jekyll::Hooks.register(:pages, :post_write) invoked." }
135
- Dumpers.dump_page(@log_pages, "Jekyll::Hooks.register(:pages, :post_write)", page)
132
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_write) invoked.' }
133
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_write)', page)
136
134
  end
137
135
 
138
136
  ########## :documents hooks
@@ -149,9 +147,9 @@ module JekyllPluginHooks
149
147
  # excerpt and ext (file extension).
150
148
  # The collection attribute will be set properly for this hook.
151
149
  Jekyll::Hooks.register(:documents, :post_init, priority: :normal) do |document|
152
- @log_docs.info { "Jekyll::Hooks.register(:documents, :post_init) invoked." }
153
- Dumpers.dump_document(@log_docs, "Jekyll::Hooks.register(:documents, :post_init)", document)
154
- "stop"
150
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_init) invoked.' }
151
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_init)', document)
152
+ 'stop'
155
153
  end
156
154
 
157
155
  # Called just before rendering a document.
@@ -160,30 +158,30 @@ module JekyllPluginHooks
160
158
  # If the document contains markdown (or some other markup),
161
159
  # it will not have been converted to HTML (or whatever the target format is) yet.
162
160
  Jekyll::Hooks.register(:documents, :pre_render, priority: :normal) do |document, payload|
163
- @log_docs.info { "Jekyll::Hooks.register(:documents, :pre_render) invoked." }
164
- Dumpers.dump_document(@log_docs, "Jekyll::Hooks.register(:documents, :pre_render)", document)
165
- Dumpers.dump_payload(@log_docs, ":documents, :pre_render payload", payload)
161
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :pre_render) invoked.' }
162
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :pre_render)', document)
163
+ Dumpers.dump_payload(@log_docs, ':documents, :pre_render payload', payload)
166
164
  end
167
165
 
168
166
  # Called after converting the document content to HTML (or whatever),
169
167
  # but before rendering the document using the layout.
170
168
  Jekyll::Hooks.register(:documents, :post_convert, priority: :normal) do |document|
171
- @log_docs.info { "Jekyll::Hooks.register(:documents, :post_convert) invoked." }
172
- Dumpers.dump_document(@log_docs, "Jekyll::Hooks.register(:documents, :post_convert)", document)
169
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_convert) invoked.' }
170
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_convert)', document)
173
171
  end
174
172
 
175
173
  # Called after rendering a document using the layout, but before writing it to disk.
176
174
  # This is your last chance to modify the content.
177
175
  Jekyll::Hooks.register(:documents, :post_render, priority: :normal) do |document|
178
- @log_docs.info { "Jekyll::Hooks.register(:documents, :post_render) invoked." }
179
- Dumpers.dump_document(@log_docs, "Jekyll::Hooks.register(:documents, :post_render)", document)
176
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_render) invoked.' }
177
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_render)', document)
180
178
  end
181
179
 
182
180
  # Called after writing a document to disk.
183
181
  # Useful for statistics regarding completed renderings.
184
182
  Jekyll::Hooks.register(:documents, :post_write, priority: :normal) do |document|
185
- @log_docs.info { "Jekyll::Hooks.register(:documents, :post_write) invoked." }
186
- Dumpers.dump_document(@log_docs, "Jekyll::Hooks.register(:documents, :post_write)", document)
183
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_write) invoked.' }
184
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_write)', document)
187
185
  end
188
186
 
189
187
  ########## :posts hooks
@@ -192,16 +190,16 @@ module JekyllPluginHooks
192
190
 
193
191
  # Called whenever any post is initialized
194
192
  Jekyll::Hooks.register(:posts, :post_init, priority: :normal) do |post|
195
- @log_posts.info { "Jekyll::Hooks.register(:posts, :post_init) invoked." }
196
- Dumpers.dump_document(@log_posts, "Jekyll::Hooks.register(:posts, :post_init)", post)
193
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_init) invoked.' }
194
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_init)', post)
197
195
  end
198
196
 
199
197
  # Called just before rendering a post
200
198
  Jekyll::Hooks.register(:posts, :pre_render, priority: :normal) do |post, payload|
201
199
  # post is a Jekyll::Document
202
- @log_posts.info { "Jekyll::Hooks.register(:posts, :pre_render) invoked." }
203
- Dumpers.dump_document(@log_posts, "Jekyll::Hooks.register(:posts, :pre_render)", post)
204
- Dumpers.dump_payload(@log_posts, ":posts, :pre_render payload", payload)
200
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :pre_render) invoked.' }
201
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :pre_render)', post)
202
+ Dumpers.dump_payload(@log_posts, ':posts, :pre_render payload', payload)
205
203
  end
206
204
 
207
205
  # Called after converting the post content, but before rendering the post layout.
@@ -213,21 +211,21 @@ module JekyllPluginHooks
213
211
  # post.output.gsub!('programming PHP', 'banging rocks together')
214
212
  # end
215
213
  Jekyll::Hooks.register(:posts, :post_convert, priority: :normal) do |post|
216
- @log_posts.info { "Jekyll::Hooks.register(:posts, :post_convert) invoked." }
217
- Dumpers.dump_document(@log_posts, "Jekyll::Hooks.register(:posts, :post_convert)", post)
214
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_convert) invoked.' }
215
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_convert)', post)
218
216
  end
219
217
 
220
218
  # Called after rendering a post, but before writing it to disk.
221
219
  # Changing `post.conent` has no effect on visible output.
222
220
  Jekyll::Hooks.register(:posts, :post_render, priority: :normal) do |post|
223
- @log_posts.info { "Jekyll::Hooks.register(:posts, :post_render) invoked." }
224
- Dumpers.dump_document(@log_posts, "Jekyll::Hooks.register(:posts, :post_render)", post)
221
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_render) invoked.' }
222
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_render)', post)
225
223
  end
226
224
 
227
225
  # Called after writing a post to disk
228
226
  Jekyll::Hooks.register(:posts, :post_write, priority: :normal) do |post|
229
- @log_posts.info { "Jekyll::Hooks.register(:posts, :post_write) invoked." }
230
- Dumpers.dump_document(@log_posts, "Jekyll::Hooks.register(:posts, :post_write)", post)
227
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_write) invoked.' }
228
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_write)', post)
231
229
  end
232
230
 
233
231
  ########## :clean hooks
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module JekyllPluginTemplateVersion
4
- VERSION = "0.1.3"
2
+ VERSION = '0.2.0'.freeze
5
3
  end
@@ -1,15 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll"
4
- require "jekyll_plugin_logger"
5
- require_relative "jekyll_plugin_template/version"
6
- require_relative "jekyll_block_tag_plugin"
7
- require_relative "jekyll_filter_template"
8
- require_relative "jekyll_tag_plugin"
9
- require_relative "jekyll_hooks"
10
- require_relative "jekyll_hook_examples"
11
- require_relative "category_index_generator"
12
- require_relative "category_combiner"
1
+ require 'jekyll'
2
+ require 'jekyll_plugin_logger'
3
+ require_relative 'jekyll_plugin_template/version'
4
+ require_relative 'jekyll_block_tag_plugin'
5
+ require_relative 'jekyll_filter_template'
6
+ require_relative 'jekyll_tag_plugin'
7
+ require_relative 'jekyll_hooks'
8
+ require_relative 'jekyll_hook_examples'
9
+ require_relative 'category_index_generator'
10
+ require_relative 'category_combiner'
13
11
 
14
12
  module JekyllPluginTemplate
15
13
  include JekyllBlockTagPlugin
@@ -1,11 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll_plugin_logger"
4
- require "key_value_parser"
5
- require "shellwords"
1
+ require 'jekyll_plugin_support'
6
2
 
7
3
  module JekyllPluginTagTemplate
8
- PLUGIN_NAME = "tag_template"
4
+ PLUGIN_NAME = 'tag_template'.freeze
9
5
  end
10
6
 
11
7
  # This Jekyll tag plugin creates an emoji of the desired size and alignment.
@@ -27,58 +23,46 @@ end
27
23
  # MyTag: debug
28
24
  module JekyllTagPlugin
29
25
  # This class implements the Jekyll tag functionality
30
- class MyTag < Liquid::Tag
26
+ class MyTag < JekyllSupport::JekyllTag
27
+ include JekyllPluginTemplateVersion
28
+
31
29
  # Supported emojis (GitHub symbol, hex code) - see https://gist.github.com/rxaviers/7360908 and
32
30
  # https://www.quackit.com/character_sets/emoji/emoji_v3.0/unicode_emoji_v3.0_characters_all.cfm
33
31
  @@emojis = {
34
32
  'angry' => '&#x1F620;',
35
33
  'boom' => '&#x1F4A5;', # used when requested emoji is not recognized
34
+ 'grin' => '&#128512;',
35
+ 'horns' => '&#128520;',
36
36
  'kiss' => '&#x1F619;',
37
+ 'open' => '&#128515;',
38
+ 'poop' => '&#x1F4A9;',
39
+ 'sad' => '&#128546;',
37
40
  'scream' => '&#x1F631;',
38
41
  'smiley' => '&#x1F601;', # default emoji
39
42
  'smirk' => '&#x1F60F;',
40
43
  'two_hearts' => '&#x1F495;',
41
- }
44
+ }.sort_by { |k, v| [k] }.to_h
42
45
 
43
46
  # @param tag_name [String] is the name of the tag, which we already know.
44
47
  # @param argument_string [String] the arguments from the web page.
45
48
  # @param tokens [Liquid::ParseContext] tokenized command line
46
49
  # @return [void]
47
- def initialize(tag_name, argument_string, tokens)
48
- super
49
- @logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
50
-
51
- argv = Shellwords.split(argument_string) # Scans name/value arguments
52
- params = KeyValueParser.new.parse(argv) # Extracts key/value pairs, default value for non-existant keys is nil
53
-
54
- @emoji_name = params[:name] || "smiley"
55
- @emoji_align = params[:align] || "inline" # Could be inline, right or left
56
- @emoji_size = params[:size] || "3em"
57
- @emoji_hex_code = @@emojis[@emoji_name] || @@emojis['boom']
58
- end
59
-
60
- # Method prescribed by the Jekyll plugin lifecycle.
61
- # Several variables are created to illustrate how they are made.
62
- # @param liquid_context [Liquid::Context]
63
- # @return [String]
64
- def render(liquid_context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
65
- @site = liquid_context.registers[:site]
66
- @config = @site.config
67
- @mode = @config["env"]["JEKYLL_ENV"] || "development"
50
+ def render_impl
51
+ @emoji_name = @helper.parameter_specified?('name') || 'smiley' # Ignored if `list` is specified
52
+ @emoji_align = @helper.parameter_specified?('align') || 'inline' # Allowable values are: inline, right or left
53
+ @emoji_size = @helper.parameter_specified?('size') || '3em'
54
+ @emoji_and_name = @helper.parameter_specified?('emoji_and_name')
55
+ @list = @helper.parameter_specified?('list')
56
+ @emoji_hex_code = @@emojis[@emoji_name] if @emoji_name || @@emojis['boom']
68
57
 
69
58
  # variables defined in pages are stored as hash values in liquid_context
70
- _assigned_page_variable = liquid_context['assigned_page_variable']
59
+ # _assigned_page_variable = @liquid_context['assigned_page_variable']
71
60
 
72
- # The names of front matter variables are hash keys for @page
73
- @page = liquid_context.registers[:page] # @page is a Jekyll::Drops::DocumentDrop
74
-
75
- @envs = liquid_context.environments.first
76
- @layout_hash = @envs['layout']
77
- # @layout_hash = @page['layout']
61
+ @layout_hash = @page['layout']
78
62
 
79
63
  @logger.debug do
80
64
  <<~HEREDOC
81
- liquid_context.scopes=#{liquid_context.scopes}
65
+ liquid_context.scopes=#{@liquid_context.scopes}
82
66
  mode="#{@mode}"
83
67
  page attributes:
84
68
  #{@page.sort
@@ -88,26 +72,42 @@ module JekyllTagPlugin
88
72
  HEREDOC
89
73
  end
90
74
 
91
- assemble_emoji
75
+ # Return the value of this Jekyll tag
76
+ if @list
77
+ list
78
+ else
79
+ assemble_emoji(@emoji_name, @emoji_hex_code)
80
+ end
92
81
  end
93
82
 
94
- def assemble_emoji # rubocop:disable Metrics/MethodLength
83
+ private
84
+
85
+ def assemble_emoji(emoji_name, emoji_hex_code)
95
86
  case @emoji_align
96
- when "inline"
97
- align = ""
98
- when "right"
99
- align = "float: right; margin-left: 5px;"
100
- when "left"
101
- align = "float: left; margin-right: 5px;"
87
+ when 'inline'
88
+ align = ''
89
+ when 'right'
90
+ align = ' float: right; margin-left: 5px;'
91
+ when 'left'
92
+ align = ' float: left; margin-right: 5px;'
102
93
  else
103
94
  @logger.error { "Invalid emoji alignment #{@emoji_align}" }
104
- align = ""
95
+ align = ''
105
96
  end
106
- # Compute the return value of this Jekyll tag
107
- "<span style='font-size: #{@emoji_size}; #{align}'>#{@emoji_hex_code}</span>"
97
+
98
+ name = " <code>#{emoji_name}</code>" if @emoji_and_name
99
+
100
+ "<span style='font-size: #{@emoji_size};#{align}'>#{emoji_hex_code}</span>#{name}"
108
101
  end
102
+
103
+ def list
104
+ "<ul class='emoji_list'>\n" +
105
+ (@@emojis.map do |ename, hex_code|
106
+ " <li>#{ assemble_emoji(ename, hex_code) }</li>\n"
107
+ end).join +
108
+ "</ul>\n"
109
+ end
110
+
111
+ JekyllPluginHelper.register(self, JekyllPluginTagTemplate::PLUGIN_NAME)
109
112
  end
110
113
  end
111
-
112
- PluginMetaLogger.instance.info { "Loaded #{JekyllPluginTagTemplate::PLUGIN_NAME} v#{JekyllPluginTemplateVersion::VERSION} plugin." }
113
- Liquid::Template.register_tag(JekyllPluginTagTemplate::PLUGIN_NAME, JekyllTagPlugin::MyTag)
@@ -1,26 +1,24 @@
1
- # frozen_string_literal: true
2
-
3
- require "fileutils"
4
- require "jekyll"
5
- require "key_value_parser"
6
- require "shellwords"
7
- require_relative "../lib/jekyll_plugin_template"
1
+ require 'fileutils'
2
+ require 'jekyll'
3
+ require 'key_value_parser'
4
+ require 'shellwords'
5
+ require_relative '../lib/jekyll_plugin_template'
8
6
 
9
7
  RSpec.describe(KeyValueParser) do
10
- it "parses arguments" do
11
- argv = "param0 param1=value1 param2='value2' param3=\"value3's tricky\" remainder of line".shellsplit
8
+ it 'parses arguments' do
9
+ argv = 'param0 param1=value1 param2=\'value2\' param3="value3\'s tricky" remainder of line'.shellsplit
12
10
  parser = KeyValueParser.new
13
11
  options = parser.parse(argv)
14
12
  # puts options.map { |k, v| "#{k} = #{v}" }.join("\n")
15
13
 
16
14
  expect(options[:param0]).to eq(true)
17
- expect(options[:param1]).to eq("value1")
18
- expect(options[:param2]).to eq("value2")
15
+ expect(options[:param1]).to eq('value1')
16
+ expect(options[:param2]).to eq('value2')
19
17
  expect(options[:param3]).to eq("value3's tricky")
20
18
  expect(options[:unknown]).to be_nil
21
19
 
22
- [:param0, :param1, :param2, :param3].each { |key| options.delete key }
23
- remainder_of_line = options.keys.join(" ")
24
- expect(remainder_of_line).to eq("remainder of line")
20
+ %i[param0 param1 param2 param3].each { |key| options.delete key }
21
+ remainder_of_line = options.keys.join(' ')
22
+ expect(remainder_of_line).to eq('remainder of line')
25
23
  end
26
24
  end
@@ -1,6 +1,4 @@
1
- # frozen_string_literal: true
2
-
3
- require "nokogiri"
1
+ require 'nokogiri'
4
2
 
5
3
  class NokoTest
6
4
  webpage = <<~END_PAGE
@@ -16,9 +14,9 @@ class NokoTest
16
14
  END_PAGE
17
15
 
18
16
  html = Nokogiri.HTML(webpage)
19
- html.css("p").each do |node|
17
+ html.css('p').each do |node|
20
18
  # This strips any HTML tags from node.content:
21
- node.content = node.content.gsub("angry", "happy")
19
+ node.content = node.content.gsub('angry', 'happy')
22
20
  end
23
21
  puts "\n\nHTML:\n#{html}"
24
22
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  class OldName
4
- old_name = "blah"
2
+ old_name = 'blah'
5
3
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module OldNameVersion
4
- VERSION = "0.1.0"
2
+ VERSION = '0.1.0'.freeze
5
3
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  class OldName
4
- old_name = "blah"
2
+ old_name = 'blah'
5
3
  end
@@ -1,9 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/old_name/version"
1
+ require_relative 'lib/old_name/version'
4
2
 
5
3
  Gem::Specification.new do |spec|
6
- github = "https://github.com/mslinn/old_name"
7
- spec.name = "old_name"
4
+ github = 'https://github.com/mslinn/old_name'
5
+ spec.name = 'old_name'
8
6
  spec.version = OldName::VERSION
9
7
  end
@@ -1,21 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- load "bin/run_this_first"
1
+ load 'bin/run_this_first'
4
2
 
5
3
  RSpec.configure do |config|
6
4
  config.add_setting :work_dir
7
- config.work_dir = "/tmp/jekyll_plugin_template"
5
+ config.work_dir = '/tmp/jekyll_plugin_template'
8
6
 
9
7
  config.after(:suite) do
10
8
  FileUtils.rm_rf(config.work_dir)
11
9
  end
12
10
  config.before(:suite) do
13
- FileUtils.cp_r "spec/run_this_first_data", config.work_dir, :verbose => true
11
+ FileUtils.cp_r 'spec/run_this_first_data', config.work_dir, :verbose => true
14
12
  end
15
13
  config.filter_run :focus
16
- config.order = "random"
14
+ config.order = 'random'
17
15
  config.run_all_when_everything_filtered = true
18
16
 
19
17
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
20
- config.example_status_persistence_file_path = "spec/first_status_persistence.txt"
18
+ config.example_status_persistence_file_path = 'spec/first_status_persistence.txt'
21
19
  end
@@ -1,40 +1,38 @@
1
- # frozen_string_literal: true
2
-
3
- require "fileutils"
4
- require_relative "run_this_first_helper"
5
- load "bin/run_this_first"
1
+ require 'fileutils'
2
+ require_relative 'run_this_first_helper'
3
+ load 'bin/run_this_first'
6
4
 
7
5
  RSpec.describe(JekyllPluginTemplateModule) do
8
- it "rename_identifiers" do
6
+ it 'rename_identifiers' do
9
7
  run_this_first = JekyllPluginTemplateModule::RunThisFirst.new(RSpec.configuration.work_dir)
10
- run_this_first.rename_identifiers("old_variable_name", "new_variable_name")
8
+ run_this_first.rename_identifiers('old_variable_name', 'new_variable_name')
11
9
 
12
- gemspec = File.read("old_name.gemspec")
10
+ gemspec = File.read('old_name.gemspec')
13
11
  expect(gemspec).to include <<~END_GEMSPEC
14
- require_relative "lib/new_name/version"
12
+ require_relative 'lib/new_name/version'
15
13
 
16
14
  Gem::Specification.new do |spec|
17
- github = "https://github.com/mslinn/new_name"
18
- spec.name = "new_name"
15
+ github = 'https://github.com/mslinn/new_name'
16
+ spec.name = 'new_name'
19
17
  spec.version = NewNameVersion::VERSION
20
18
  end
21
19
  END_GEMSPEC
22
20
 
23
- version_rb = File.read("old_name/old_name/version.rb")
24
- expect(version_rb).to include("class NewName")
21
+ version_rb = File.read('old_name/old_name/version.rb')
22
+ expect(version_rb).to include('class NewName')
25
23
 
26
- old_name_rb = File.read("old_name/old_name/old_name.rb")
27
- expect(old_name_rb).to include("new_name")
24
+ old_name_rb = File.read('old_name/old_name/old_name.rb')
25
+ expect(old_name_rb).to include('new_name')
28
26
  end
29
27
 
30
- it "rename_files" do
28
+ it 'rename_files' do
31
29
  run_this_first = JekyllPluginTemplateModule::RunThisFirst.new(RSpec.configuration.work_dir)
32
- run_this_first.rename_files("old_name", "new_name")
33
- expect(Dir["."]).to match_array[
34
- "new_name.gemspec",
35
- "lib/new_name.rb",
36
- "lib/new_name/new_name.rb",
37
- "lib/new_name/version.rb"
30
+ run_this_first.rename_files('old_name', 'new_name')
31
+ expect(Dir['.']).to match_array[
32
+ 'new_name.gemspec',
33
+ 'lib/new_name.rb',
34
+ 'lib/new_name/new_name.rb',
35
+ 'lib/new_name/version.rb'
38
36
  ]
39
37
  end
40
38
  end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,17 @@
1
- # frozen_string_literal: true
1
+ require 'jekyll'
2
+ require 'fileutils'
3
+ require 'key_value_parser'
4
+ require 'shellwords'
2
5
 
3
- require "jekyll"
4
- require "fileutils"
5
- require "key_value_parser"
6
- require "shellwords"
7
-
8
- require_relative "../lib/jekyll_plugin_template"
6
+ require_relative '../lib/jekyll_plugin_template'
9
7
 
10
8
  Jekyll.logger.log_level = :info
11
9
 
12
10
  RSpec.configure do |config|
13
11
  config.filter_run :focus
14
- config.order = "random"
12
+ config.order = 'random'
15
13
  config.run_all_when_everything_filtered = true
16
14
 
17
15
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
18
- config.example_status_persistence_file_path = "spec/status_persistence.txt"
16
+ config.example_status_persistence_file_path = 'spec/status_persistence.txt'
19
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_plugin_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firstname Lastname
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-25 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -25,33 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.5.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: jekyll_plugin_logger
28
+ name: jekyll_plugin_support
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
31
+ - - "~>"
39
32
  - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: key-value-parser
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: 0.5.0
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: 0.5.0
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: git
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,32 +80,18 @@ dependencies:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: shellwords
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: talk_like_a_pirate
113
85
  requirement: !ruby/object:Gem::Requirement
114
86
  requirements:
115
- - - ">="
87
+ - - "~>"
116
88
  - !ruby/object:Gem::Version
117
89
  version: 0.2.2
118
90
  type: :runtime
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
- - - ">="
94
+ - - "~>"
123
95
  - !ruby/object:Gem::Version
124
96
  version: 0.2.2
125
97
  - !ruby/object:Gem::Dependency
@@ -171,7 +143,6 @@ files:
171
143
  - spec/run_this_first_helper.rb
172
144
  - spec/run_this_first_spec.rb
173
145
  - spec/spec_helper.rb
174
- - spec/status_persistence.txt
175
146
  homepage: https://www.mslinn.com/blog/2020/12/30/jekyll-plugin-template-collection.html
176
147
  licenses:
177
148
  - CC0-1.0
@@ -1,5 +0,0 @@
1
- example_id | status | run_time |
2
- ------------------------------------------ | ------ | --------------- |
3
- ./spec/jekyll_plugin_template_spec.rb[1:1] | passed | 0.02165 seconds |
4
- ./spec/run_this_first_spec.rb[1:1] | failed | 0.00134 seconds |
5
- ./spec/run_this_first_spec.rb[1:2] | failed | 2.84 seconds |