jekyll-released-posts 0.0.1 → 1.0.1
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/lib/jekyll-released-posts.rb +36 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631e1302b6a77165f75c841df556a67f1912bfcd1ba44ecd99f718d8582a74f6
|
4
|
+
data.tar.gz: 0bc5a628d1b3d24aafb95d52ea8f34940bd4f5a58cb129cb357fd983af42f6e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acb399667f8e0b963386a056f7ce4ac5e43812586ad3ea64d50343cd1dab1a5fc68c7439c9141de4139cb56fdf291ff4fa49c64e5aa77660a156d20e94abd99f
|
7
|
+
data.tar.gz: 51649bdce76c4f2c349944b72ce8ff5915b29d68781d43b7621b1c41f1fd132291ee2eeb7bc2aeee57a15ebb052744f46a00293f2be6f431b96b0a72fee24afe
|
@@ -1,10 +1,42 @@
|
|
1
1
|
require "jekyll"
|
2
2
|
|
3
|
+
# An approximation of Maybe.orElse
|
4
|
+
# REFACTOR Replace with maddox's better_or_else gem.
|
5
|
+
class Object
|
6
|
+
def or_else
|
7
|
+
self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class NilClass
|
12
|
+
def or_else
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
module JekyllReleasedPosts
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
18
|
+
# REFACTOR Move this into some kind of ReleasedPost specialization of Jekyll Document/Post/whatever
|
19
|
+
# REFACTOR How to add this as a virtual attribute on Jekyll Post/Document?
|
20
|
+
class ReleasedPost
|
21
|
+
def initialize(jekyll_document)
|
22
|
+
@jekyll_document = jekyll_document
|
8
23
|
end
|
24
|
+
|
25
|
+
def released?(as_of: Time.now)
|
26
|
+
@jekyll_document.data["released"].or_else { @jekyll_document.date <= as_of }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# CONTRACT Something has already defined Jekyll::Site.
|
32
|
+
# (Good news! If Jekyll doesn't do it, we're fucked.)
|
33
|
+
Jekyll::Drops::SiteDrop.class_eval do
|
34
|
+
# REFACTOR Replace this with a method that computes on the fly
|
35
|
+
def released_posts
|
36
|
+
# CONTRACT self.posts already only selects published posts (or so we believe)
|
37
|
+
# REFACTOR Move this into a filter on any array of Document objects and not only site.posts
|
38
|
+
posts.select { | document |
|
39
|
+
JekyllReleasedPosts::ReleasedPost.new(document).released?(as_of: Time.now)
|
40
|
+
}
|
9
41
|
end
|
10
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-released-posts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J. B. Rainsberger
|
8
|
+
- Pat Maddox
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: When you want to publish a post, but not promote it yet on your welcome
|
14
15
|
page, you might want to call it 'released'.
|