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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wst/contents.rb +22 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fae230e835b7e2fd7863918f5cf3bd54c182d01
4
- data.tar.gz: 4b3a7aad1c65d2589b57fb38374f52832fac5df0
3
+ metadata.gz: 7296240a0651e39d2ff904cccec2544c2145bf77
4
+ data.tar.gz: 86c2592b2cb19417b22802e51a32a9f393693fca
5
5
  SHA512:
6
- metadata.gz: 1844d006495971332df6ded39a66b459529c016cf82f8ac264668c447a3711f3d156c13542055167e432c22a629d8491298c9b50c3b4e0577f9bcc0905f787aa
7
- data.tar.gz: 48a742b2bf6b129ce74f86727d364225d6d85c5a6687bb468913a0cfd4555e0c1f8ac98b6bca00f74c651c23bf37e4ca68e84a54672697ddcb719faf0dc47e97
6
+ metadata.gz: 1a09529f99e65d646d909aaa17fe94e7a792f71baf1e0828ae8976303a7c741e8c4fa5aea905349ab027dfdda4355500c4c4692b7afee1e6e12329ce5e689dfd
7
+ data.tar.gz: b75ade3096a9e643cbd16077a192de655f650c1fe211a7285bca335de6149b4ba49a718b3eaa83c2ee3f71194809175c5790bf441f5e8358a903db0ce37a1e0b
@@ -5,22 +5,36 @@ require 'wst/page'
5
5
  module Wst
6
6
  class Contents
7
7
  def initialize
8
- @all = all_contents
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] show_non_publised Get all contents or only published
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
- return @all if show_non_published
16
- @all.select { |c| c.published }
17
+ get @all, show_non_published
17
18
  end
18
19
 
19
- private
20
- # Get all contents, publised or not
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 all_contents
23
- [Page.all, Post.all].flatten
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wst-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Brissaud