jekyll_draft 1.1.1 → 2.0.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: 2024b9ea176d56e527de8b6adfcb10c5072f6ea93d3c9d661cf64859e6c69dbc
4
- data.tar.gz: d4518a8a07e342bd9586628c4d66a796ae284d89bd4808f805f0f77614b53ea5
3
+ metadata.gz: 5123990f175f9d09091e7f092a202b075067497e9b17dabf3eda397c48d9b11e
4
+ data.tar.gz: 80f3912e94858f6ccc373d2a155f0b6f907c79c13ea6bb8495837d019656508b
5
5
  SHA512:
6
- metadata.gz: a5c3c44b58c2983dc6399822b0b223a387d06c3f624d0891748539569cf5abe72ab7ae1e109101c9fbeaae99002a3d8e02984e75af086940c866b2377997b282
7
- data.tar.gz: bdef2fa61858f15620e7e54a43199ec434115a91147db7fe485b052f45c3a7cb0be1227e682da7bc6a8b1bdaef2f8d664f14b4f60dd73aaa9ec08ded17f918d0
6
+ metadata.gz: 406222aeae0160d0ff1ef9c5c5d5ad9af0a4f357541dd43742a58c229bc6094343960c215efd498cee33d37fb76457aac1e6d0d5183c4f16277cbf044f4c0f79
7
+ data.tar.gz: eed26a657a04c4907700ef805fb41d67b2ed4842058f12918d3231035c46b2c6fe7c17b065a3a8c625410401f5376c86d3db4d40f607baa7e8c89320f623d6f5
data/.rubocop.yml CHANGED
@@ -1,15 +1,111 @@
1
+ require:
2
+ # - rubocop-jekyll
3
+ - rubocop-md
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ # inherit_gem:
9
+ # rubocop-jekyll: .rubocop.yml
10
+
1
11
  AllCops:
2
12
  Exclude:
3
- - vendor/**/*
4
- - Gemfile*
13
+ - demo/_site/**/*
14
+ - binstub/**/*
15
+ - vendor/**/*
16
+ - Gemfile*
17
+ - _site/**/*
5
18
  NewCops: enable
6
- TargetRubyVersion: 2.6
7
19
 
8
- Layout/HashAlignment:
20
+ Gemspec/DeprecatedAttributeAssignment:
21
+ Enabled: false
22
+
23
+ Gemspec/RequireMFA:
24
+ Enabled: false
25
+
26
+ Gemspec/RequiredRubyVersion:
9
27
  Enabled: false
10
28
 
29
+ Layout/HashAlignment:
30
+ EnforcedColonStyle: table
31
+ EnforcedHashRocketStyle: table
32
+
33
+ Layout/InitialIndentation:
34
+ Exclude:
35
+ - README.md
36
+
11
37
  Layout/LineLength:
12
38
  Max: 150
13
39
 
40
+ Layout/MultilineMethodCallIndentation:
41
+ Enabled: false
42
+
43
+ Lint/RedundantCopDisableDirective:
44
+ Exclude:
45
+ - jekyll_draft.gemspec
46
+
47
+ Metrics/AbcSize:
48
+ Max: 45
49
+
50
+ Metrics/BlockLength:
51
+ Exclude:
52
+ - jekyll_draft.gemspec
53
+ - spec/**/*
54
+
55
+ Metrics/ClassLength:
56
+ Exclude:
57
+ - spec/**/*
58
+ Max: 50
59
+
60
+ Metrics/CyclomaticComplexity:
61
+ Max: 20
62
+
63
+ Metrics/MethodLength:
64
+ Max: 40
65
+
66
+ Metrics/PerceivedComplexity:
67
+ Max: 15
68
+
69
+ Naming/FileName:
70
+ Exclude:
71
+ - Rakefile
72
+
73
+ RSpec/ExampleLength:
74
+ Max: 20
75
+
76
+ RSpec/MultipleExpectations:
77
+ Max: 15
78
+
79
+ RSpec/NoExpectationExample:
80
+ Enabled: false
81
+
82
+ Style/CommandLiteral:
83
+ Enabled: false
84
+
85
+ Style/CommentedKeyword:
86
+ Enabled: false
87
+
88
+ Style/Documentation:
89
+ Enabled: false
90
+
14
91
  Style/FrozenStringLiteralComment:
15
92
  Enabled: false
93
+
94
+ Style/PercentLiteralDelimiters:
95
+ Enabled: false
96
+
97
+ Style/RegexpLiteral:
98
+ Enabled: false
99
+
100
+ Style/StringConcatenation:
101
+ Exclude:
102
+ - spec/**/*
103
+
104
+ Style/StringLiterals:
105
+ Enabled: false
106
+
107
+ Style/StringLiteralsInInterpolation:
108
+ Enabled: false
109
+
110
+ Style/TrailingCommaInHashLiteral:
111
+ EnforcedStyleForMultiline: comma
data/CHANGELOG.md CHANGED
@@ -1,12 +1,32 @@
1
+ # Change Log
2
+
3
+ ## 2.0.0 / 2023-11-29
4
+
5
+ * Made into a Jekyll block tag, because the filter implementation had problems with infinite recursing Jekyll exerpts.
6
+ This was a complete rewrite, incompatible with previous version.
7
+
8
+
9
+ ## 1.1.2 / 2023-02-25
10
+
11
+ * Avoids Jekyll generating the message `Deprecation: Document#published is now a key in the #data hash.`
12
+
13
+
1
14
  ## 1.1.1 / 2023-02-16
2
- * Avoids Jekyll generating the message `Deprecation: Document#draft is now a key in the #data hash.`
15
+
16
+ * Avoids Jekyll generating the message `Deprecation: Document#draft is now a key in the #data hash.`
17
+
3
18
 
4
19
  ## 1.1.0 / 2023-02-05
5
- * Works with CSS classes instead of generating CSS styling
6
- * Improved how unpublished documents are recognized
20
+
21
+ * Works with CSS classes instead of generating CSS styling
22
+ * Improved how unpublished documents are recognized
23
+
7
24
 
8
25
  ## 1.0.1 / 2022-08-05
9
- * Improved how drafts are recognized
26
+
27
+ * Improved how drafts are recognized
28
+
10
29
 
11
30
  ## 1.0.0 / 2022-04-02
12
- * Initial version
31
+
32
+ * Initial version
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
- jekyll_draft
2
- [![Gem Version](https://badge.fury.io/rb/jekyll_draft.svg)](https://badge.fury.io/rb/jekyll_draft)
3
- ===========
1
+ # jekyll_draft [![Gem Version](https://badge.fury.io/rb/jekyll_draft.svg)](https://badge.fury.io/rb/jekyll_draft)
4
2
 
5
3
  This is a Jekyll plugin that provides two Liquid filters: `is_draft` and `draft_html`.
6
4
 
7
- More information is available on my website about [my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
5
+ More information is available on my website about [my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#draft).
8
6
 
9
7
 
10
8
  ## Installation
11
9
 
12
10
  Add the following to your CSS:
11
+
13
12
  ```css
14
13
  .jekyll_draft {
15
14
  background-color: #fefeab;
@@ -30,40 +29,54 @@ end
30
29
 
31
30
  And then execute:
32
31
 
33
- $ bundle install
32
+ ```shell
33
+ $ bundle
34
+ ```
34
35
 
35
36
 
36
37
  ## Usage
37
38
 
38
39
  ### `is_draft`
39
40
 
40
- Filters a page according to the directory it resides in, and its front matter.
41
- ```
41
+ This filter detects if a page is invisible when published in `production` mode,
42
+ and either returns `true` or `false`.
43
+
44
+ ```html
42
45
  {{ page | is_draft }} => true
43
46
  ```
44
47
 
45
48
  ### `draft_html`
46
- Filters a page according to the directory it resides in, and its front matter.
49
+
50
+ This filter generates HTML to display if a page is invisible when published in `production` mode.
47
51
  If the page is not a draft then the empty string is returned.
48
- ```
52
+ The generated HTML for draft pages is:<br>
53
+ `" &lt;i class='jekyll_draft'>Draft&lt;/i>"`
54
+
55
+ ```html
49
56
  {{ page | draft_html }} => " <i class='bg_light_yellow' style='padding-left: 0.5em; padding-right: 0.5em;'>Draft</i>"
50
57
  ```
51
58
 
59
+
52
60
  ### Invoking From Another Jekyll Plugin
61
+
53
62
  ```ruby
54
63
  require 'jekyll_draft'
55
64
 
56
- p 'Found a draft' if Jekyll::Draft.is_draft post
65
+ puts 'Found a draft' if Jekyll::Draft.is_draft post
57
66
 
58
67
  draft = Jekyll::Draft.draft_html post
59
68
  ```
60
69
 
70
+
61
71
  ## Demo
72
+
62
73
  The [`demo`](./demo) directory contains a demonstration website, which uses the plugin.
63
74
  To run, type:
75
+
64
76
  ```console
65
77
  $ demo/_bin/debug -r
66
78
  ```
79
+
67
80
  Now point your web browser to http://localhost:4444
68
81
 
69
82
 
@@ -72,28 +85,36 @@ Now point your web browser to http://localhost:4444
72
85
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
73
86
 
74
87
  Install development dependencies like this:
75
- ```
76
- $ BUNDLE_WITH="development" bundle install
88
+
89
+ ```shell
90
+ $ BUNDLE_WITH="development" bundle
77
91
  ```
78
92
 
79
93
  To install this gem onto your local machine, run:
94
+
80
95
  ```shell
81
96
  $ bundle exec rake install
82
97
  ```
83
98
 
84
99
  To release a new version,
100
+
85
101
  1. Update the version number in `version.rb`.
86
102
  2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
87
103
  3. Run the following:
104
+
88
105
  ```shell
89
106
  $ bundle exec rake release
90
107
  ```
108
+
91
109
  The above creates a git tag for the version, commits the created tag,
92
110
  and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
93
111
 
112
+
94
113
  ### Debugging
114
+
95
115
  Run `bin/attach` and pass the directory name of a Jekyll website that has a suitable script called `_bin/debug`.
96
116
  The `demo` subdirectory fits this description.
117
+
97
118
  ```console
98
119
  $ bin/attach demo
99
120
  Successfully uninstalled jekyll_draft-0.1.0
@@ -101,6 +122,7 @@ jekyll_draft 0.1.0 built to pkg/jekyll_draft-0.1.0.gem.
101
122
  jekyll_draft (0.1.0) installed.
102
123
  Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
103
124
  ```
125
+
104
126
  Now attach to the debugger process.
105
127
  This git repo includes a [Visual Studio Code launcher](./.vscode/launch.json) for this purpose labeled `Listen for rdebug-ide`.
106
128
 
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
5
3
 
6
4
  RSpec::Core::RakeTask.new(:spec)
7
- task :default => :spec
5
+ task default: :spec
data/jekyll_draft.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
10
10
  END_OF_DESC
11
11
  spec.email = ['mslinn@mslinn.com']
12
12
  spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
13
- spec.homepage = 'https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#basename'
13
+ spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_draft.html'
14
14
  spec.license = 'MIT'
15
15
  spec.metadata = {
16
16
  'allowed_push_host' => 'https://rubygems.org',
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
29
29
  spec.required_ruby_version = '>= 2.6.0'
30
30
  spec.summary = 'This Jekyll filter detects draft documents.'
31
31
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
32
- spec.version = JekyllDraftVersion::VERSION
32
+ spec.version = DraftVersion::VERSION
33
33
 
34
34
  spec.add_dependency 'jekyll', '>= 3.5.0'
35
- spec.add_dependency 'jekyll_plugin_logger'
35
+ spec.add_dependency 'jekyll_plugin_support'
36
36
  end
data/lib/draft.rb ADDED
@@ -0,0 +1,29 @@
1
+ # Define these methods outside of the JekyllDraft class so they can be invoked externally and tested more easily
2
+ module Draft
3
+ # @return true by checking in this order:
4
+ # - document is in _drafts directory, detectable by doc['draft']==true
5
+ # - document front matter contains 'published: false'
6
+ def draft?(doc)
7
+ return true if doc.respond_to?(:draft) && doc.draft
8
+ return true if doc.key?('draft') && doc['draft'] # ignore !doc['draft']
9
+ return !doc['published'] if doc.key?('published')
10
+
11
+ false
12
+ rescue StandardError => e
13
+ @logger.error { e }
14
+ false
15
+ end
16
+
17
+ # @param doc [Jekyll::Drops::DocumentDrop]
18
+ # @return HTML that indicates if a doc is a draft or not
19
+ def draft_html
20
+ return '' unless is_draft
21
+
22
+ " <i class='jekyll_draft'>Draft</i>"
23
+ rescue StandardError => e
24
+ @logger.error { e }
25
+ ''
26
+ end
27
+
28
+ module_function :draft?, :draft_html
29
+ end
data/lib/draft_html.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'jekyll_plugin_support'
2
+
3
+ class Else < JekyllSupport::JekyllTag
4
+ VERSION = '0.1.0'.freeze
5
+ PLUGIN_NAME = 'else'.freeze
6
+
7
+ def render_impl
8
+ " <i class='jekyll_draft'>Draft</i>" if Draft.draft?(@page)
9
+ end
10
+
11
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
12
+ PluginMetaLogger.instance.info { "Loaded #{PLUGIN_NAME.class} v#{DraftVersion::VERSION} plugin." }
13
+ end
data/lib/else.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'jekyll_plugin_support'
2
+
3
+ class Else < JekyllSupport::JekyllTag
4
+ VERSION = '0.1.0'.freeze
5
+ PLUGIN_NAME = 'else'.freeze
6
+
7
+ def render_impl
8
+ RECORD_SEPARATOR
9
+ end
10
+
11
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
12
+ PluginMetaLogger.instance.info { "Loaded #{PLUGIN_NAME.class} v#{DraftVersion::VERSION} plugin." }
13
+ end
data/lib/if_draft.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'jekyll_plugin_support'
2
+
3
+ # Jekyll inline plugin that detects draft documents
4
+ class JekyllDraft < JekyllSupport::JekyllBlock
5
+ PLUGIN_NAME = 'if_draft'.freeze
6
+ VERSION = DraftVersion::VERSION
7
+
8
+ def render_impl(content)
9
+ true_value, false_value, extra = content.split(RECORD_SEPARATOR)
10
+ raise DraftError, "Warning: More than one else clause detected" if extra
11
+
12
+ Draft.draft?(@page) ? true_value : false_value
13
+ end
14
+
15
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
16
+ PluginMetaLogger.instance.info { "Loaded #{PLUGIN_NAME.class} v#{DraftVersion::VERSION} plugin." }
17
+ end
@@ -1,3 +1,3 @@
1
- module JekyllDraftVersion
2
- VERSION = '1.1.1'.freeze
1
+ module DraftVersion
2
+ VERSION = '2.0.0'.freeze
3
3
  end
data/lib/jekyll_draft.rb CHANGED
@@ -1,92 +1,14 @@
1
1
  # @author Copyright 2022 {https://www.mslinn.com Michael Slinn}
2
2
 
3
- require 'jekyll_plugin_logger'
3
+ require 'jekyll_plugin_support'
4
4
  require 'yaml'
5
+ require_relative 'jekyll_draft/version' unless defined?(VERSION)
5
6
 
6
- # Jekyll filter that detects draft documents
7
- module Jekyll
8
- # Define these methods outside of module DraftFilter so they can be invoked externally and tested easily
9
- module Draft
10
- # @return true if document front matter contains published that is not true,
11
- # or document is in _drafts.
12
- # If draft and published are both specified in front matter then published has priority.
13
- def draft?(doc)
14
- abort 'Jekyll::Draft.draft? doc is nil!'.red if doc.nil?
7
+ # Unicode record separator https://www.compart.com/en/unicode/U+241E
8
+ RECORD_SEPARATOR = "\u{241E}".freeze
15
9
 
16
- return is_unpublished(doc) if published_was_specified(doc)
10
+ DraftError = JekyllSupport.define_error
17
11
 
18
- # Try Jekyll's naming convention to determine draft status
19
- return doc.data['draft'] if doc.respond_to?('data') && doc.data.key?('draft')
20
- return doc.draft if doc.respond_to?(:draft)
21
-
22
- false
23
- end
24
-
25
- # @return HTML that indicates if a doc is a draft or not
26
- def draft_html(doc)
27
- return '' unless draft?(doc)
28
-
29
- " <i class='jekyll_draft'>Draft</i>"
30
- end
31
-
32
- # @return path to root of the collection that doc is a member of
33
- def root(doc, site)
34
- return '/index.html' unless doc.respond_to?(:collection)
35
-
36
- collection_name = doc.collection
37
- docs = site.key?(collection_name) ? site[collection_name] : site.collections[collection_name].docs
38
- index = docs.find { |d| d.url.end_with? 'index.html' }
39
- return index.url if index
40
-
41
- docs.min.url
42
- end
43
-
44
- # Non-standard name used so this method could be invoked from Liquid
45
- # @return true if published was specified in a document's front matter, and the value is false
46
- def published_was_specified(doc)
47
- return true if doc.respond_to?('published')
48
-
49
- return false unless doc.respond_to?('data')
50
-
51
- return true if doc.data.key?('published')
52
-
53
- false
54
- end
55
-
56
- # Non-standard name used so this method could be invoked from Liquid
57
- # @return true if published was specified in a document's front matter, and the value is false
58
- def is_unpublished(doc) # rubocop:disable Naming/PredicateName
59
- return !doc.published if doc.respond_to?('published')
60
-
61
- return !doc['published'] if doc.key?('published')
62
-
63
- return !doc.data['published'] if doc.respond_to?('data') && doc.data.key?('published')
64
-
65
- false
66
- end
67
-
68
- module_function :draft?, :draft_html, :is_unpublished, :published_was_specified, :root
69
- end
70
-
71
- # Jekyll filters interface
72
- module DraftFilter
73
- def is_draft(doc) # rubocop:disable Naming/PredicateName
74
- Draft.draft?(doc)
75
- end
76
-
77
- def draft_html(doc)
78
- Draft.draft_html(doc)
79
- end
80
-
81
- def is_unpublished(doc) # rubocop:disable Naming/PredicateName
82
- Draft.is_unpublished(doc)
83
- end
84
-
85
- def root(doc, site)
86
- Draft.root(doc, site)
87
- end
88
- end
89
-
90
- Liquid::Template.register_filter(DraftFilter)
91
- PluginMetaLogger.instance.info { 'Loaded DraftFilter plugin.' }
92
- end
12
+ require_relative 'draft'
13
+ require_relative 'else'
14
+ require_relative 'if_draft'
@@ -0,0 +1,12 @@
1
+ require 'rspec/match_ignoring_whitespace'
2
+ require_relative 'lib/draft'
3
+
4
+ class JekyllPluginHelperOptionsTest
5
+ RSpec.describe Jekyll::Draft do
6
+ it 'does nothing' do
7
+ # TODO: mock doc
8
+ # described_class.draft? doc
9
+ expect(true).to be_truthy
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'jekyll'
2
+ require 'jekyll_plugin_logger'
3
+ require 'rspec/match_ignoring_whitespace'
4
+ require_relative '../../lib/jekyll_draft'
5
+ require_relative 'mocks'
6
+
7
+ RSpec.describe(Jekyll::Draft) do
8
+ include described_class
9
+
10
+ let(:logger) do
11
+ PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
12
+ end
13
+
14
+ let(:parse_context) { TestParseContext.new }
15
+
16
+ it 'detects drafts' do
17
+ # expect(result).to match_ignoring_whitespace <<-END_RESULT
18
+ # <img src="./blah.webp">
19
+ # END_RESULT
20
+ end
21
+ end
@@ -0,0 +1,62 @@
1
+ Registers = Struct.new(:page, :site)
2
+
3
+ # Mock for Collections
4
+ class Collections
5
+ def values
6
+ []
7
+ end
8
+ end
9
+
10
+ # Mock for Site
11
+ class SiteMock
12
+ attr_reader :config
13
+
14
+ def initialize
15
+ @config = YAML.safe_load(File.read('../demo/_config.yml'))
16
+ @config['env'] = { 'JEKYLL_ENV' => 'development' }
17
+ end
18
+
19
+ def collections
20
+ Collections.new
21
+ end
22
+ end
23
+
24
+ # Mock for Liquid::Context
25
+ class TestLiquidContext < Liquid::Context
26
+ def initialize
27
+ super
28
+
29
+ page = {
30
+ "content" => "blah blah",
31
+ "description" => "Jekyll draft demo",
32
+ "dir" => "/",
33
+ "excerpt" => nil,
34
+ "layout" => "default",
35
+ "name" => "index.html",
36
+ "path" => "index.html",
37
+ "title" => "Welcome",
38
+ "url" => "/",
39
+ }
40
+
41
+ @content = "This is the content"
42
+ @registers = Registers.new(
43
+ page,
44
+ SiteMock.new
45
+ )
46
+ end
47
+ end
48
+
49
+ # Mock for Liquid::ParseContent
50
+ class TestParseContext < Liquid::ParseContext
51
+ attr_reader :line_number, :registers
52
+
53
+ def initialize
54
+ super
55
+ @line_number = 123
56
+
57
+ @registers = Registers.new(
58
+ { 'path' => 'path/to/page.html' },
59
+ SiteMock.new
60
+ )
61
+ end
62
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,10 +2,8 @@ require 'jekyll'
2
2
  require_relative '../lib/jekyll_draft'
3
3
 
4
4
  RSpec.configure do |config|
5
- config.filter_run :focus
6
- config.order = 'random'
7
- config.run_all_when_everything_filtered = true
8
-
5
+ config.filter_run_when_matching focus: true
6
+ # config.order = 'random'
9
7
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
10
8
  config.example_status_persistence_file_path = 'spec/status_persistence.txt'
11
9
  end
@@ -1,3 +1,3 @@
1
1
  example_id | status | run_time |
2
2
  -------------------------------- | ------ | --------------- |
3
- ./spec/jekyll_draft_spec.rb[1:1] | passed | 0.00903 seconds |
3
+ ./spec/jekyll/draft_spec.rb[1:1] | passed | 0.00007 seconds |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_draft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.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-16 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -25,7 +25,7 @@ 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
31
  - - ">="
@@ -53,19 +53,25 @@ files:
53
53
  - README.md
54
54
  - Rakefile
55
55
  - jekyll_draft.gemspec
56
+ - lib/draft.rb
57
+ - lib/draft_html.rb
58
+ - lib/else.rb
59
+ - lib/if_draft.rb
56
60
  - lib/jekyll_draft.rb
57
61
  - lib/jekyll_draft/version.rb
58
- - spec/jekyll_draft_spec.rb
62
+ - spec/draft_spec.rb
63
+ - spec/jekyll/draft_spec.rb
64
+ - spec/jekyll/mocks.rb
59
65
  - spec/spec_helper.rb
60
66
  - spec/status_persistence.txt
61
- homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#basename
67
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_draft.html
62
68
  licenses:
63
69
  - MIT
64
70
  metadata:
65
71
  allowed_push_host: https://rubygems.org
66
72
  bug_tracker_uri: https://github.com/mslinn/jekyll_draft/issues
67
73
  changelog_uri: https://github.com/mslinn/jekyll_draft/CHANGELOG.md
68
- homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#basename
74
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_draft.html
69
75
  source_code_uri: https://github.com/mslinn/jekyll_draft
70
76
  post_install_message: |2+
71
77
 
@@ -85,12 +91,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
91
  - !ruby/object:Gem::Version
86
92
  version: '0'
87
93
  requirements: []
88
- rubygems_version: 3.3.3
94
+ rubygems_version: 3.3.7
89
95
  signing_key:
90
96
  specification_version: 4
91
97
  summary: This Jekyll filter detects draft documents.
92
98
  test_files:
93
- - spec/jekyll_draft_spec.rb
99
+ - spec/draft_spec.rb
100
+ - spec/jekyll/draft_spec.rb
101
+ - spec/jekyll/mocks.rb
94
102
  - spec/spec_helper.rb
95
103
  - spec/status_persistence.txt
96
104
  ...
@@ -1,35 +0,0 @@
1
- require 'jekyll'
2
- require 'jekyll_plugin_logger'
3
- require_relative '../lib/jekyll_draft'
4
-
5
- RSpec.describe(Jekyll::Draft) do # rubocop:disable Metrics/BlockLength
6
- include Jekyll::Draft
7
-
8
- let(:page_draft) do
9
- page_ = double('Jekyll::Page')
10
- allow(page_).to receive(:draft) { true }
11
- page_
12
- end
13
- let(:page_not_draft) do
14
- page_ = double('Jekyll::Page')
15
- allow(page_).to receive(:draft) { false }
16
- page_
17
- end
18
- let(:page_published) do
19
- page_ = double('Jekyll::Page')
20
- allow(page_).to receive(:published) { true }
21
- page_
22
- end
23
- let(:page_not_published) do
24
- page_ = double('Jekyll::Page')
25
- allow(page_).to receive(:published) { false }
26
- page_
27
- end
28
-
29
- it 'detects drafts' do
30
- expect(draft?(page_draft)).to be_truthy
31
- expect(draft?(page_not_draft)).to be_falsey
32
- expect(draft?(page_published)).to be_falsey
33
- expect(draft?(page_not_published)).to be_truthy
34
- end
35
- end