wst-parser 0.2.1 → 0.2.2
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/wst/contents.rb +22 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7296240a0651e39d2ff904cccec2544c2145bf77
|
4
|
+
data.tar.gz: 86c2592b2cb19417b22802e51a32a9f393693fca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a09529f99e65d646d909aaa17fe94e7a792f71baf1e0828ae8976303a7c741e8c4fa5aea905349ab027dfdda4355500c4c4692b7afee1e6e12329ce5e689dfd
|
7
|
+
data.tar.gz: b75ade3096a9e643cbd16077a192de655f650c1fe211a7285bca335de6149b4ba49a718b3eaa83c2ee3f71194809175c5790bf441f5e8358a903db0ce37a1e0b
|
data/lib/wst/contents.rb
CHANGED
@@ -5,22 +5,36 @@ require 'wst/page'
|
|
5
5
|
module Wst
|
6
6
|
class Contents
|
7
7
|
def initialize
|
8
|
-
@
|
8
|
+
@posts = Post.all
|
9
|
+
@pages = Page.all
|
10
|
+
@all = [@posts, @pages].flatten
|
9
11
|
end
|
10
12
|
|
11
13
|
# Get all contents
|
12
|
-
# @param [Boolean]
|
14
|
+
# @param [Boolean] show_non_published Get all contents or only published
|
13
15
|
# @return [Array<Content>] Contents
|
14
16
|
def all(show_non_published = false)
|
15
|
-
|
16
|
-
@all.select { |c| c.published }
|
17
|
+
get @all, show_non_published
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
# Get all
|
20
|
+
# Get all pages
|
21
|
+
# @param [Boolean] show_non_published Get all pages or only published
|
22
|
+
# @return [Array<Content>] Contents
|
23
|
+
def pages(show_non_published = false)
|
24
|
+
get @pages, show_non_published
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get all posts
|
28
|
+
# @param [Boolean] show_non_published Get all posts or only published
|
21
29
|
# @return [Array<Content>] Contents
|
22
|
-
def
|
23
|
-
|
30
|
+
def posts(show_non_published = false)
|
31
|
+
get @posts, show_non_published
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def get(contents, show_non_published)
|
36
|
+
return contents if show_non_published
|
37
|
+
contents.select { |c| c.published }
|
24
38
|
end
|
25
39
|
end
|
26
40
|
end
|