jekyll_draft 1.1.2 → 2.0.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 +10 -5
- data/CHANGELOG.md +23 -6
- data/README.md +34 -12
- data/jekyll_draft.gemspec +3 -3
- data/lib/draft.rb +29 -0
- data/lib/draft_html.rb +13 -0
- data/lib/else.rb +13 -0
- data/lib/if_draft.rb +17 -0
- data/lib/jekyll_draft/version.rb +2 -2
- data/lib/jekyll_draft.rb +8 -87
- data/spec/draft_spec.rb +12 -0
- data/spec/jekyll/draft_spec.rb +11 -1
- data/spec/jekyll/mocks.rb +62 -0
- data/spec/spec_helper.rb +2 -4
- data/spec/status_persistence.txt +3 -4
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5123990f175f9d09091e7f092a202b075067497e9b17dabf3eda397c48d9b11e
|
4
|
+
data.tar.gz: 80f3912e94858f6ccc373d2a155f0b6f907c79c13ea6bb8495837d019656508b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406222aeae0160d0ff1ef9c5c5d5ad9af0a4f357541dd43742a58c229bc6094343960c215efd498cee33d37fb76457aac1e6d0d5183c4f16277cbf044f4c0f79
|
7
|
+
data.tar.gz: eed26a657a04c4907700ef805fb41d67b2ed4842058f12918d3231035c46b2c6fe7c17b065a3a8c625410401f5376c86d3db4d40f607baa7e8c89320f623d6f5
|
data/.rubocop.yml
CHANGED
@@ -11,11 +11,11 @@ require:
|
|
11
11
|
AllCops:
|
12
12
|
Exclude:
|
13
13
|
- demo/_site/**/*
|
14
|
-
-
|
14
|
+
- binstub/**/*
|
15
15
|
- vendor/**/*
|
16
16
|
- Gemfile*
|
17
|
+
- _site/**/*
|
17
18
|
NewCops: enable
|
18
|
-
TargetRubyVersion: 2.6
|
19
19
|
|
20
20
|
Gemspec/DeprecatedAttributeAssignment:
|
21
21
|
Enabled: false
|
@@ -23,10 +23,12 @@ Gemspec/DeprecatedAttributeAssignment:
|
|
23
23
|
Gemspec/RequireMFA:
|
24
24
|
Enabled: false
|
25
25
|
|
26
|
+
Gemspec/RequiredRubyVersion:
|
27
|
+
Enabled: false
|
28
|
+
|
26
29
|
Layout/HashAlignment:
|
27
30
|
EnforcedColonStyle: table
|
28
|
-
|
29
|
-
- jekyll_draft.gemspec
|
31
|
+
EnforcedHashRocketStyle: table
|
30
32
|
|
31
33
|
Layout/InitialIndentation:
|
32
34
|
Exclude:
|
@@ -53,7 +55,7 @@ Metrics/BlockLength:
|
|
53
55
|
Metrics/ClassLength:
|
54
56
|
Exclude:
|
55
57
|
- spec/**/*
|
56
|
-
Max:
|
58
|
+
Max: 50
|
57
59
|
|
58
60
|
Metrics/CyclomaticComplexity:
|
59
61
|
Max: 20
|
@@ -74,6 +76,9 @@ RSpec/ExampleLength:
|
|
74
76
|
RSpec/MultipleExpectations:
|
75
77
|
Max: 15
|
76
78
|
|
79
|
+
RSpec/NoExpectationExample:
|
80
|
+
Enabled: false
|
81
|
+
|
77
82
|
Style/CommandLiteral:
|
78
83
|
Enabled: false
|
79
84
|
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +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
|
+
|
1
9
|
## 1.1.2 / 2023-02-25
|
2
|
-
|
10
|
+
|
11
|
+
* Avoids Jekyll generating the message `Deprecation: Document#published is now a key in the #data hash.`
|
12
|
+
|
3
13
|
|
4
14
|
## 1.1.1 / 2023-02-16
|
5
|
-
|
15
|
+
|
16
|
+
* Avoids Jekyll generating the message `Deprecation: Document#draft is now a key in the #data hash.`
|
17
|
+
|
6
18
|
|
7
19
|
## 1.1.0 / 2023-02-05
|
8
|
-
|
9
|
-
|
20
|
+
|
21
|
+
* Works with CSS classes instead of generating CSS styling
|
22
|
+
* Improved how unpublished documents are recognized
|
23
|
+
|
10
24
|
|
11
25
|
## 1.0.1 / 2022-08-05
|
12
|
-
|
26
|
+
|
27
|
+
* Improved how drafts are recognized
|
28
|
+
|
13
29
|
|
14
30
|
## 1.0.0 / 2022-04-02
|
15
|
-
|
31
|
+
|
32
|
+
* Initial version
|
data/README.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
jekyll_draft
|
2
|
-
[](https://badge.fury.io/rb/jekyll_draft)
|
3
|
-
===========
|
1
|
+
# jekyll_draft [](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
|
-
|
32
|
+
```shell
|
33
|
+
$ bundle
|
34
|
+
```
|
34
35
|
|
35
36
|
|
36
37
|
## Usage
|
37
38
|
|
38
39
|
### `is_draft`
|
39
40
|
|
40
|
-
|
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
|
-
|
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
|
+
`" <i class='jekyll_draft'>Draft</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
|
-
|
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
|
-
|
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/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/
|
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 =
|
32
|
+
spec.version = DraftVersion::VERSION
|
33
33
|
|
34
34
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
35
|
-
spec.add_dependency '
|
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
|
data/lib/jekyll_draft/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '
|
1
|
+
module DraftVersion
|
2
|
+
VERSION = '2.0.0'.freeze
|
3
3
|
end
|
data/lib/jekyll_draft.rb
CHANGED
@@ -1,93 +1,14 @@
|
|
1
1
|
# @author Copyright 2022 {https://www.mslinn.com Michael Slinn}
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'jekyll_plugin_support'
|
4
4
|
require 'yaml'
|
5
|
+
require_relative 'jekyll_draft/version' unless defined?(VERSION)
|
5
6
|
|
6
|
-
#
|
7
|
-
|
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
|
-
|
10
|
+
DraftError = JekyllSupport.define_error
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
# Looks in data before checking for property.
|
58
|
-
# @return true if published was specified in a document's front matter, and the value is false
|
59
|
-
def is_unpublished(doc) # rubocop:disable Naming/PredicateName
|
60
|
-
return !doc.data['published'] if doc.respond_to?(:data) && doc.data.key?('published')
|
61
|
-
|
62
|
-
return !doc.published if doc.respond_to?(:published)
|
63
|
-
|
64
|
-
return !doc['published'] if doc.key?('published')
|
65
|
-
|
66
|
-
false
|
67
|
-
end
|
68
|
-
|
69
|
-
module_function :draft?, :draft_html, :is_unpublished, :published_was_specified, :root
|
70
|
-
end
|
71
|
-
|
72
|
-
# Jekyll filters interface
|
73
|
-
module DraftFilter
|
74
|
-
def is_draft(doc) # rubocop:disable Naming/PredicateName
|
75
|
-
Draft.draft?(doc)
|
76
|
-
end
|
77
|
-
|
78
|
-
def draft_html(doc)
|
79
|
-
Draft.draft_html(doc)
|
80
|
-
end
|
81
|
-
|
82
|
-
def is_unpublished(doc) # rubocop:disable Naming/PredicateName
|
83
|
-
Draft.is_unpublished(doc)
|
84
|
-
end
|
85
|
-
|
86
|
-
def root(doc, site)
|
87
|
-
Draft.root(doc, site)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
Liquid::Template.register_filter(DraftFilter)
|
92
|
-
PluginMetaLogger.instance.info { 'Loaded DraftFilter plugin.' }
|
93
|
-
end
|
12
|
+
require_relative 'draft'
|
13
|
+
require_relative 'else'
|
14
|
+
require_relative 'if_draft'
|
data/spec/draft_spec.rb
ADDED
@@ -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
|
data/spec/jekyll/draft_spec.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
require 'jekyll'
|
2
2
|
require 'jekyll_plugin_logger'
|
3
|
+
require 'rspec/match_ignoring_whitespace'
|
3
4
|
require_relative '../../lib/jekyll_draft'
|
5
|
+
require_relative 'mocks'
|
4
6
|
|
5
7
|
RSpec.describe(Jekyll::Draft) do
|
6
8
|
include described_class
|
7
9
|
|
10
|
+
let(:logger) do
|
11
|
+
PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:parse_context) { TestParseContext.new }
|
15
|
+
|
8
16
|
it 'detects drafts' do
|
9
|
-
|
17
|
+
# expect(result).to match_ignoring_whitespace <<-END_RESULT
|
18
|
+
# <img src="./blah.webp">
|
19
|
+
# END_RESULT
|
10
20
|
end
|
11
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.
|
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
|
data/spec/status_persistence.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
./spec/
|
4
|
-
./spec/basename_dirname_spec.rb[1:2] | passed | 0.0002 seconds |
|
1
|
+
example_id | status | run_time |
|
2
|
+
-------------------------------- | ------ | --------------- |
|
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:
|
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-
|
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:
|
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
|
62
|
+
- spec/draft_spec.rb
|
58
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/
|
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/
|
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.
|
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:
|
99
|
+
- spec/draft_spec.rb
|
93
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
|
...
|