neapolitan 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +2 -2
- data/HISTORY.rdoc +10 -0
- data/lib/neapolitan.yml +2 -2
- data/lib/neapolitan/part.rb +8 -4
- data/lib/neapolitan/template.rb +25 -12
- metadata +18 -18
data/.ruby
CHANGED
@@ -60,7 +60,7 @@ revision: 0
|
|
60
60
|
created: '2009-08-25'
|
61
61
|
summary: Kid in the Candy Store Templating
|
62
62
|
title: Neapolitan
|
63
|
-
version: 0.4.
|
63
|
+
version: 0.4.1
|
64
64
|
name: neapolitan
|
65
65
|
description: ! 'Neapolitan is a meta-templating engine. Like a candy store it allows
|
66
66
|
you to pick
|
@@ -69,4 +69,4 @@ description: ! 'Neapolitan is a meta-templating engine. Like a candy store it al
|
|
69
69
|
|
70
70
|
document. Selections include eruby, textile, markdown and many others.'
|
71
71
|
organization: rubyworks
|
72
|
-
date: '2011-
|
72
|
+
date: '2011-12-15'
|
data/HISTORY.rdoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= RELEASE HISTORY
|
2
2
|
|
3
|
+
== 0.4.1 / 2011-12-15
|
4
|
+
|
5
|
+
This release simply improves the parsing of a templates YAML front
|
6
|
+
matter, so the top bar (i.e. `---`) is completely optional.
|
7
|
+
|
8
|
+
Changes:
|
9
|
+
|
10
|
+
* Better parsing of YAML from matter.
|
11
|
+
|
12
|
+
|
3
13
|
== 0.4.0 / 2011-11-30
|
4
14
|
|
5
15
|
This release updates Neapolitan for use with the latest version
|
data/lib/neapolitan.yml
CHANGED
@@ -60,7 +60,7 @@ revision: 0
|
|
60
60
|
created: '2009-08-25'
|
61
61
|
summary: Kid in the Candy Store Templating
|
62
62
|
title: Neapolitan
|
63
|
-
version: 0.4.
|
63
|
+
version: 0.4.1
|
64
64
|
name: neapolitan
|
65
65
|
description: ! 'Neapolitan is a meta-templating engine. Like a candy store it allows
|
66
66
|
you to pick
|
@@ -69,4 +69,4 @@ description: ! 'Neapolitan is a meta-templating engine. Like a candy store it al
|
|
69
69
|
|
70
70
|
document. Selections include eruby, textile, markdown and many others.'
|
71
71
|
organization: rubyworks
|
72
|
-
date: '2011-
|
72
|
+
date: '2011-12-15'
|
data/lib/neapolitan/part.rb
CHANGED
@@ -6,10 +6,14 @@ module Neapolitan
|
|
6
6
|
|
7
7
|
# Parse text body and create new part.
|
8
8
|
def self.parse(template, body)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if body.start_with?('---')
|
10
|
+
index = body.index("\n")
|
11
|
+
format = body[0...index].strip.sub(/^---/,'').strip
|
12
|
+
text = body[index+1..-1].strip
|
13
|
+
else
|
14
|
+
text = body
|
15
|
+
format = ''
|
16
|
+
end
|
13
17
|
new(template, text, format)
|
14
18
|
end
|
15
19
|
|
data/lib/neapolitan/template.rb
CHANGED
@@ -217,23 +217,36 @@ module Neapolitan
|
|
217
217
|
|
218
218
|
# Parse template document into metadata and parts.
|
219
219
|
def parse
|
220
|
-
parts =
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
parts.shift if parts.first.strip.empty?
|
227
|
-
data = YAML::load(parts.first)
|
228
|
-
if Hash === data
|
229
|
-
parts.shift
|
220
|
+
parts = []
|
221
|
+
part = ''
|
222
|
+
text.each_line do |line|
|
223
|
+
if line.start_with?('---')
|
224
|
+
parts << part unless part == ''
|
225
|
+
part = line
|
230
226
|
else
|
231
|
-
|
227
|
+
part << line
|
228
|
+
end
|
229
|
+
end
|
230
|
+
parts << part unless part == ''
|
231
|
+
|
232
|
+
data = {}
|
233
|
+
if parts.size > 1
|
234
|
+
first = parts.first.lines.first.strip
|
235
|
+
case first
|
236
|
+
when '---', /[^-]/, /^---\s*settings/
|
237
|
+
data = YAML::load(parts.first)
|
238
|
+
if Hash === data
|
239
|
+
parts.shift
|
240
|
+
else
|
241
|
+
data = {}
|
242
|
+
end
|
232
243
|
end
|
233
244
|
end
|
234
|
-
|
235
245
|
parse_metadata(data)
|
236
246
|
|
247
|
+
# remove empty sections
|
248
|
+
#parts = parts.reject{ |part| part.strip == '---' }
|
249
|
+
|
237
250
|
@parts = parts.map{ |part| Part.parse(self, part) }
|
238
251
|
end
|
239
252
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neapolitan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: malt
|
16
|
-
requirement: &
|
16
|
+
requirement: &24515340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24515340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: detroit
|
27
|
-
requirement: &
|
27
|
+
requirement: &24514720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *24514720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &24513740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *24513740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: qed
|
49
|
-
requirement: &
|
49
|
+
requirement: &24505480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *24505480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: coderay
|
60
|
-
requirement: &
|
60
|
+
requirement: &24504880 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *24504880
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: RedCloth
|
71
|
-
requirement: &
|
71
|
+
requirement: &24504160 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *24504160
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &24503580 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *24503580
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: liquid
|
93
|
-
requirement: &
|
93
|
+
requirement: &24502860 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *24502860
|
102
102
|
description: ! 'Neapolitan is a meta-templating engine. Like a candy store it allows
|
103
103
|
you to pick
|
104
104
|
|