wst-parser 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wst/content.rb +14 -0
  3. data/lib/wst/page.rb +16 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7296240a0651e39d2ff904cccec2544c2145bf77
4
- data.tar.gz: 86c2592b2cb19417b22802e51a32a9f393693fca
3
+ metadata.gz: 9a690d57dac83d9f5dd6b85bb0b5868186a40dde
4
+ data.tar.gz: 0f0f129d630759820b614f29e9640fb60e8335c7
5
5
  SHA512:
6
- metadata.gz: 1a09529f99e65d646d909aaa17fe94e7a792f71baf1e0828ae8976303a7c741e8c4fa5aea905349ab027dfdda4355500c4c4692b7afee1e6e12329ce5e689dfd
7
- data.tar.gz: b75ade3096a9e643cbd16077a192de655f650c1fe211a7285bca335de6149b4ba49a718b3eaa83c2ee3f71194809175c5790bf441f5e8358a903db0ce37a1e0b
6
+ metadata.gz: 1f26738511cedf11ee3faee05e39599307b3830c4ae1b876ad4d7f8f83cfc87627cb70fa3928008a474cc1115a1ad4ce5528458fd64cf9b06cc5c725c7cdcd76
7
+ data.tar.gz: bf5a972f916b962111355bedb10cf091ccfb874d2f485acee31c7ec70bb0f6075dbf3cfc6ffe64a32e73509ce5a013a669a83b5cf04e8f3c101c2f0f4531cabb
data/lib/wst/content.rb CHANGED
@@ -7,6 +7,20 @@ module Wst
7
7
  class Content
8
8
  include Configuration
9
9
 
10
+ class << self
11
+ # param [String] file_path Relative path of the file to save
12
+ # param [Hash] datas Header datas
13
+ # param [String] content Content to write
14
+ def save! file_path, datas, content
15
+ File.open(file_path, "w") do |file|
16
+ file.write datas.to_yaml
17
+ file.write "---\n"
18
+ file.write "\n"
19
+ file.write content
20
+ end
21
+ end
22
+ end
23
+
10
24
  def initialize file_path, child = nil
11
25
  @file_path = file_path
12
26
  @plain_content = ""
data/lib/wst/page.rb CHANGED
@@ -84,6 +84,22 @@ module Wst
84
84
  (xml_pages + haml_pages + md_pages).sort
85
85
  end
86
86
 
87
+ # param [String] file_path Relative path of the file to save
88
+ # param [Hash] datas Header datas
89
+ # param [String] content Content to write
90
+ def save! file_path, datas, content
91
+ Content.save! file_path, datas, content
92
+ page = nil
93
+ if file_path =~ XmlPage.matcher
94
+ page = XmlPage.new file_path
95
+ elsif file_path =~ HamlPage.matcher
96
+ page = HamlPage.new file_path
97
+ elsif file_path =~ MdPage.matcher
98
+ page = MdPage.new file_path
99
+ end
100
+ page
101
+ end
102
+
87
103
  private
88
104
 
89
105
  def xml_pages
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.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Brissaud