lavender 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENCE +13 -0
- data/README.rdoc +20 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/bin/lavender +4 -0
- data/lib/lavender.rb +8 -0
- data/lib/lavender/command.rb +31 -0
- data/lib/lavender/config.rb +75 -0
- data/lib/lavender/converter.rb +47 -0
- data/lib/lavender/renderer.rb +24 -0
- data/lib/lavender/static.rb +59 -0
- data/spec/command_spec.rb +18 -0
- data/spec/config_spec.rb +26 -0
- data/spec/converter_spec.rb +172 -0
- data/spec/renderer_spec.rb +45 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/static_spec.rb +100 -0
- data/spec/support/stub_files.rb +15 -0
- metadata +126 -0
data/.gitignore
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright © 2010, Tom Adams <tom@holizz.com>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
= lavender
|
2
|
+
|
3
|
+
Minimalistic YAML-based CMS
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
...
|
8
|
+
|
9
|
+
== Inspiration
|
10
|
+
|
11
|
+
- http://blog.peepcode.com/tutorials/2010/about-this-blog
|
12
|
+
- http://jekyllrb.com/
|
13
|
+
|
14
|
+
== Author
|
15
|
+
|
16
|
+
Tom Adams <tom@holizz.com>
|
17
|
+
|
18
|
+
== Copying
|
19
|
+
|
20
|
+
ISC licence (see LICENCE for the full text).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = 'lavender'
|
5
|
+
gem.summary = %Q{Minimalistic YAML-based CMS}
|
6
|
+
gem.email = 'tom@holizz.com'
|
7
|
+
gem.homepage = 'http://github.com/holizz/lavender'
|
8
|
+
gem.authors = ['Tom Adams']
|
9
|
+
gem.add_dependency 'haml'
|
10
|
+
gem.add_development_dependency 'rspec'
|
11
|
+
gem.add_development_dependency 'jeweler'
|
12
|
+
end
|
13
|
+
Jeweler::GemcutterTasks.new
|
14
|
+
rescue LoadError
|
15
|
+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rspec/core/rake_task'
|
19
|
+
RSpec::Core::RakeTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/lavender
ADDED
data/lib/lavender.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Lavender
|
2
|
+
class Command
|
3
|
+
def self.run args
|
4
|
+
case args.first
|
5
|
+
when 'help'
|
6
|
+
self.help
|
7
|
+
when nil
|
8
|
+
self.help
|
9
|
+
|
10
|
+
when 'compile'
|
11
|
+
static = Lavender::Static.new true
|
12
|
+
static.run
|
13
|
+
when 'server'
|
14
|
+
raise ArgumentError, "Not yet implemented"
|
15
|
+
|
16
|
+
else
|
17
|
+
raise ArgumentError, "Command not recognised"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.help
|
22
|
+
puts <<END
|
23
|
+
Usage: lavender command
|
24
|
+
|
25
|
+
Commands:
|
26
|
+
help This message
|
27
|
+
compile Compiles the project in the current working directory
|
28
|
+
END
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Lavender
|
2
|
+
class Config
|
3
|
+
|
4
|
+
class OpenStruct
|
5
|
+
def method_missing(method)
|
6
|
+
method = method.to_s
|
7
|
+
if @hsh[method].is_a? Hash
|
8
|
+
OpenStruct.new(@hsh[method])
|
9
|
+
else
|
10
|
+
@hsh[method]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
def initialize(hsh)
|
14
|
+
@hsh = hsh
|
15
|
+
end
|
16
|
+
def to_hash
|
17
|
+
@hsh
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method, *args)
|
22
|
+
@obj.send(method, *args)
|
23
|
+
end
|
24
|
+
|
25
|
+
LOCATIONS = %w[config.yml]
|
26
|
+
|
27
|
+
def initialize config = nil
|
28
|
+
@config = config
|
29
|
+
@config ||= {
|
30
|
+
'defaults' => {'layout' => 'default', 'processor' => 'haml'},
|
31
|
+
'paths' => {
|
32
|
+
'pages' => 'pages',
|
33
|
+
'layouts' => 'layouts',
|
34
|
+
'compiled' => 'compiled',
|
35
|
+
'public' => 'public'
|
36
|
+
},
|
37
|
+
'pwd' => Dir.pwd
|
38
|
+
}
|
39
|
+
|
40
|
+
user_config = {}
|
41
|
+
LOCATIONS.each do |y|
|
42
|
+
if File.exist? y
|
43
|
+
user_config = YAML::load_file y
|
44
|
+
break
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
@config = recursive_merge user_config, @config
|
49
|
+
|
50
|
+
@obj = OpenStruct.new @config
|
51
|
+
end
|
52
|
+
|
53
|
+
def recursive_merge primary, secondary
|
54
|
+
# merges secondary into primary
|
55
|
+
|
56
|
+
return primary unless primary.is_a? Hash
|
57
|
+
|
58
|
+
output = {}
|
59
|
+
|
60
|
+
primary.each_key do |k|
|
61
|
+
if secondary.has_key? k
|
62
|
+
output[k] = recursive_merge primary[k], secondary[k]
|
63
|
+
else
|
64
|
+
output[k] = user_config[k]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
(secondary.keys-primary.keys).each do |k|
|
69
|
+
output[k] = secondary[k]
|
70
|
+
end
|
71
|
+
|
72
|
+
output
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Lavender
|
2
|
+
class Converter
|
3
|
+
def initialize options
|
4
|
+
@options = options
|
5
|
+
@options[:defaults] ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def render
|
9
|
+
yaml = @options[:page]
|
10
|
+
conf = nil
|
11
|
+
page = nil
|
12
|
+
|
13
|
+
if yaml.match /\A---\s?\n(.+?\n)---\s?\n(.*)\Z/m
|
14
|
+
conf = YAML.load($1)
|
15
|
+
page = $2
|
16
|
+
else
|
17
|
+
conf = {}
|
18
|
+
page = yaml
|
19
|
+
end
|
20
|
+
|
21
|
+
pro = if conf.has_key? 'processor'
|
22
|
+
conf['processor']
|
23
|
+
else
|
24
|
+
@options[:defaults][:processor]
|
25
|
+
end
|
26
|
+
pro = pro.to_sym unless pro.nil?
|
27
|
+
r = Renderer.new(pro, page)
|
28
|
+
output = r.render(conf)
|
29
|
+
|
30
|
+
layout = if conf.has_key? 'layout'
|
31
|
+
conf['layout']
|
32
|
+
else
|
33
|
+
@options[:defaults][:layout]
|
34
|
+
end
|
35
|
+
layout = layout.to_sym unless layout.nil?
|
36
|
+
if layout
|
37
|
+
hsh = @options[:layouts][layout]
|
38
|
+
pro = hsh.keys.first
|
39
|
+
content = hsh[pro]
|
40
|
+
r = Renderer.new(pro, content)
|
41
|
+
output = r.render(conf) { output }
|
42
|
+
end
|
43
|
+
|
44
|
+
output
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Lavender
|
2
|
+
class Renderer
|
3
|
+
def initialize type, input
|
4
|
+
@type = type
|
5
|
+
@input = input
|
6
|
+
end
|
7
|
+
|
8
|
+
def render vars = {}, &block
|
9
|
+
@vars = vars
|
10
|
+
|
11
|
+
case @type
|
12
|
+
when :raw
|
13
|
+
@input
|
14
|
+
when :erb
|
15
|
+
def method_missing name
|
16
|
+
@vars[name] || @vars[name.to_s]
|
17
|
+
end
|
18
|
+
ERB.new(@input).result(binding)
|
19
|
+
when :haml
|
20
|
+
Haml::Engine.new(@input).to_html(Object.new, @vars, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Lavender
|
4
|
+
class Static
|
5
|
+
def initialize verbose = false
|
6
|
+
@config = Lavender::Config.new
|
7
|
+
@verbose = verbose
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
# Public
|
12
|
+
Dir["#{path(:public)}/**/*"].each do |file|
|
13
|
+
out = file.sub(/^#{path(:public)}/, path(:compiled))
|
14
|
+
write_file out, File.read(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Layouts
|
18
|
+
layouts = {}
|
19
|
+
Dir["#{path(:layouts)}/**/*"].each do |file|
|
20
|
+
name, ext = file.sub(/^#{path(:layouts)}\//,'').match(/^(.+)\.([^\.]+)$/)[1..-1]
|
21
|
+
layouts[name.to_sym] = {ext.to_sym => File.read(file)}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Pages
|
25
|
+
Dir["#{path(:pages)}/**/*.yml"].each do |file|
|
26
|
+
target = file.sub(/^#{path(:pages)}/, path(:compiled))
|
27
|
+
target.sub!(/\.yml$/, '')
|
28
|
+
|
29
|
+
conv = Lavender::Converter.new(:page => File.read(file), :layouts => layouts, :defaults => defaults)
|
30
|
+
|
31
|
+
write_file target, conv.render
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def path path
|
36
|
+
File.join(@config.pwd, @config.paths.send(path))
|
37
|
+
end
|
38
|
+
|
39
|
+
def defaults
|
40
|
+
@config.defaults.to_hash.reduce({}) do |a,b|
|
41
|
+
c = b.last
|
42
|
+
c = c.to_sym if c.is_a? String
|
43
|
+
a[b.first.to_sym] = c
|
44
|
+
a
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def write_file path, data
|
49
|
+
FileUtils.mkdir_p File.dirname(path)
|
50
|
+
File.open(path, 'w+') do |f|
|
51
|
+
f.write data
|
52
|
+
end
|
53
|
+
if @verbose
|
54
|
+
basepath = path.sub(/^#{@config.pwd}\//,'')
|
55
|
+
puts " create: #{basepath}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lavender::Command do
|
4
|
+
it "should call Static correctly" do
|
5
|
+
m=RSpec::Mocks::Mock.new
|
6
|
+
m.stub!(:run)
|
7
|
+
Lavender::Static.should_receive(:new).with(true).and_return(m)
|
8
|
+
Lavender::Command.run(%w[compile])
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have a placeholder for Server" do
|
12
|
+
lambda { Lavender::Command.run(%w[server]) }.should raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should bork on unrecognised commands" do
|
16
|
+
lambda { Lavender::Command.run(%w[on the ning nang nong]) }.should raise_error
|
17
|
+
end
|
18
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lavender::Config do
|
4
|
+
before do
|
5
|
+
FakeFS.activate!
|
6
|
+
stub_files 'config.yml' => <<END
|
7
|
+
---
|
8
|
+
defaults:
|
9
|
+
layout: main
|
10
|
+
END
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
FakeFS.deactivate!
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should take values from the config file" do
|
18
|
+
config = Lavender::Config.new
|
19
|
+
config.defaults.layout.should == 'main'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have pre-defined default values" do
|
23
|
+
config = Lavender::Config.new
|
24
|
+
config.defaults.processor.should == 'haml'
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lavender::Converter do
|
4
|
+
it "should render anything that isn't YAML with the default layout/processor" do
|
5
|
+
layout = <<END
|
6
|
+
<body>
|
7
|
+
<%= yield %>
|
8
|
+
</body>
|
9
|
+
END
|
10
|
+
|
11
|
+
page = <<END
|
12
|
+
%p My paragraph
|
13
|
+
END
|
14
|
+
|
15
|
+
c = Lavender::Converter.new(:page => page, :layouts => {:default => {:erb => layout}}, :defaults => {:layout => :default, :processor => :haml})
|
16
|
+
c.render.should == <<END
|
17
|
+
<body>
|
18
|
+
<p>My paragraph</p>
|
19
|
+
|
20
|
+
</body>
|
21
|
+
END
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should render pages with the given template processor" do
|
25
|
+
page = <<END
|
26
|
+
---
|
27
|
+
processor: erb
|
28
|
+
layout: null
|
29
|
+
text: content
|
30
|
+
---
|
31
|
+
<p>Document <%= text %>.</p>
|
32
|
+
END
|
33
|
+
|
34
|
+
c = Lavender::Converter.new(:page => page)
|
35
|
+
|
36
|
+
c.render.should == <<END
|
37
|
+
<p>Document content.</p>
|
38
|
+
END
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should render pages with a layout" do
|
42
|
+
page = <<END
|
43
|
+
---
|
44
|
+
processor: haml
|
45
|
+
layout: default
|
46
|
+
title: your face
|
47
|
+
---
|
48
|
+
%p Document content.
|
49
|
+
END
|
50
|
+
layout = <<END
|
51
|
+
%html
|
52
|
+
%head
|
53
|
+
%title= title
|
54
|
+
%body
|
55
|
+
= yield
|
56
|
+
END
|
57
|
+
|
58
|
+
c = Lavender::Converter.new(:page => page, :layouts => {:default => {:haml => layout}})
|
59
|
+
|
60
|
+
c.render.should == <<END
|
61
|
+
<html>
|
62
|
+
<head>
|
63
|
+
<title>your face</title>
|
64
|
+
</head>
|
65
|
+
<body>
|
66
|
+
<p>Document content.</p>
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
END
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should allow mixing templating languages" do
|
73
|
+
page = <<END
|
74
|
+
---
|
75
|
+
processor: haml
|
76
|
+
layout: page
|
77
|
+
title: your face
|
78
|
+
---
|
79
|
+
%p Document content.
|
80
|
+
END
|
81
|
+
layout = <<END
|
82
|
+
<html>
|
83
|
+
<head>
|
84
|
+
<title><%= title %></title>
|
85
|
+
</head>
|
86
|
+
<body>
|
87
|
+
<%= yield %>
|
88
|
+
</body>
|
89
|
+
</html>
|
90
|
+
END
|
91
|
+
|
92
|
+
c = Lavender::Converter.new(:page => page, :layouts => {:page => {:erb => layout}})
|
93
|
+
|
94
|
+
c.render.should == <<END
|
95
|
+
<html>
|
96
|
+
<head>
|
97
|
+
<title>your face</title>
|
98
|
+
</head>
|
99
|
+
<body>
|
100
|
+
<p>Document content.</p>
|
101
|
+
|
102
|
+
</body>
|
103
|
+
</html>
|
104
|
+
END
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should use a default processor and layout" do
|
108
|
+
page = <<END
|
109
|
+
---
|
110
|
+
title: your face
|
111
|
+
---
|
112
|
+
%p Document content.
|
113
|
+
END
|
114
|
+
layout = <<END
|
115
|
+
<html>
|
116
|
+
<head>
|
117
|
+
<title><%= title %></title>
|
118
|
+
</head>
|
119
|
+
<body>
|
120
|
+
<%= yield %>
|
121
|
+
</body>
|
122
|
+
</html>
|
123
|
+
END
|
124
|
+
|
125
|
+
c = Lavender::Converter.new(:page => page, :layouts => {:default => {:erb => layout}}, :defaults => {:layout => :default, :processor => :haml})
|
126
|
+
|
127
|
+
c.render.should == <<END
|
128
|
+
<html>
|
129
|
+
<head>
|
130
|
+
<title>your face</title>
|
131
|
+
</head>
|
132
|
+
<body>
|
133
|
+
<p>Document content.</p>
|
134
|
+
|
135
|
+
</body>
|
136
|
+
</html>
|
137
|
+
END
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should not try to parse HAML as YAML" do
|
141
|
+
page = <<END
|
142
|
+
---
|
143
|
+
layout: null
|
144
|
+
---
|
145
|
+
%p
|
146
|
+
%img{:src => "hamsterdance.gif"}
|
147
|
+
END
|
148
|
+
|
149
|
+
c = Lavender::Converter.new(:page => page, :defaults => {:processor => :haml})
|
150
|
+
|
151
|
+
c.render.should == <<END
|
152
|
+
<p>
|
153
|
+
<img src='hamsterdance.gif' />
|
154
|
+
</p>
|
155
|
+
END
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should not try to parse HAML as YAML (no preamble)" do
|
159
|
+
page = <<END
|
160
|
+
%p
|
161
|
+
%img{:src => "hamsterdance.gif"}
|
162
|
+
END
|
163
|
+
|
164
|
+
c = Lavender::Converter.new(:page => page, :defaults => {:processor => :haml})
|
165
|
+
|
166
|
+
c.render.should == <<END
|
167
|
+
<p>
|
168
|
+
<img src='hamsterdance.gif' />
|
169
|
+
</p>
|
170
|
+
END
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lavender::Renderer do
|
4
|
+
it "should render raw stuff as-is" do
|
5
|
+
page = '<p>My paragraph</p>'
|
6
|
+
r = Lavender::Renderer.new(:raw, page)
|
7
|
+
r.render.should == page
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should render ERB" do
|
11
|
+
page = '<p>Document <%= "content" %>.</p>'
|
12
|
+
r = Lavender::Renderer.new(:erb, page)
|
13
|
+
r.render.should == '<p>Document content.</p>'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should render HAML" do
|
17
|
+
page = '%p Document content.'
|
18
|
+
r = Lavender::Renderer.new(:haml, page)
|
19
|
+
r.render.should == "<p>Document content.</p>\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should set variables" do
|
23
|
+
# ERB
|
24
|
+
page = '<p>Document <%= text %>.</p>'
|
25
|
+
r = Lavender::Renderer.new(:erb, page)
|
26
|
+
r.render({:text => 'content'}).should == '<p>Document content.</p>'
|
27
|
+
|
28
|
+
# HAML
|
29
|
+
page = '%p= "Document #{text}."'
|
30
|
+
r = Lavender::Renderer.new(:haml, page)
|
31
|
+
r.render({:text => 'content'}).should == "<p>Document content.</p>\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should yield" do
|
35
|
+
# ERB
|
36
|
+
page = '<p>Document <%= yield %>.</p>'
|
37
|
+
r = Lavender::Renderer.new(:erb, page)
|
38
|
+
r.render{ 'content' }.should == '<p>Document content.</p>'
|
39
|
+
|
40
|
+
# HAML
|
41
|
+
page = '%p= "Document #{yield}."'
|
42
|
+
r = Lavender::Renderer.new(:haml, page) { 'content' }
|
43
|
+
r.render{ 'content' }.should == "<p>Document content.</p>\n"
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/static_spec.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lavender::Static do
|
4
|
+
before do
|
5
|
+
FakeFS.activate!
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
FakeFS.deactivate!
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should compile raw files" do
|
13
|
+
stub_files_and_run 'pages/index.html.yml' => <<END
|
14
|
+
---
|
15
|
+
layout: null
|
16
|
+
processor: raw
|
17
|
+
---
|
18
|
+
<audio src="girlfriendboy.wav"></audio>
|
19
|
+
END
|
20
|
+
|
21
|
+
File.should exist 'compiled/index.html'
|
22
|
+
File.read('compiled/index.html').should == <<END
|
23
|
+
<audio src="girlfriendboy.wav"></audio>
|
24
|
+
END
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should ignore non-.yml files" do
|
28
|
+
stub_files_and_run 'pages/igonreme.txt' => <<END
|
29
|
+
Ignore this!!!
|
30
|
+
END
|
31
|
+
File.should_not exist 'compiled/ignoreme.txt'
|
32
|
+
File.should_not exist 'compiled/ignoreme'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should handle layouts and processing languages" do
|
36
|
+
stub_files_and_run(
|
37
|
+
'pages/hamster.html.yml' => <<END,
|
38
|
+
%p Text
|
39
|
+
END
|
40
|
+
'layouts/main.erb' => <<END)
|
41
|
+
<body>
|
42
|
+
<%= yield %>
|
43
|
+
</body>
|
44
|
+
END
|
45
|
+
File.should exist 'compiled/hamster.html'
|
46
|
+
File.read('compiled/hamster.html').should == <<END
|
47
|
+
<body>
|
48
|
+
<p>Text</p>
|
49
|
+
|
50
|
+
</body>
|
51
|
+
END
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should handle layouts in subdirectories" do
|
55
|
+
stub_files_and_run(
|
56
|
+
'pages/refectory.html.yml' => <<END,
|
57
|
+
---
|
58
|
+
layout: clarissa/explains
|
59
|
+
processor: raw
|
60
|
+
---
|
61
|
+
Hello there
|
62
|
+
END
|
63
|
+
'layouts/clarissa/explains.erb' => <<END)
|
64
|
+
<noscript>
|
65
|
+
<%= yield %>
|
66
|
+
</noscript>
|
67
|
+
END
|
68
|
+
File.should exist 'compiled/refectory.html'
|
69
|
+
File.read('compiled/refectory.html').should == <<END
|
70
|
+
<noscript>
|
71
|
+
Hello there
|
72
|
+
|
73
|
+
</noscript>
|
74
|
+
END
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should create directories" do
|
78
|
+
stub_files_and_run 'pages/s/ash.html.yml' => <<END
|
79
|
+
---
|
80
|
+
layout: null
|
81
|
+
processor: raw
|
82
|
+
---
|
83
|
+
Hello there
|
84
|
+
END
|
85
|
+
File.should exist 'compiled/s/ash.html'
|
86
|
+
File.read('compiled/s/ash.html').should == <<END
|
87
|
+
Hello there
|
88
|
+
END
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should copy over public" do
|
92
|
+
stub_files_and_run 'public/t.txt' => <<END
|
93
|
+
Some plain text
|
94
|
+
END
|
95
|
+
File.should exist 'compiled/t.txt'
|
96
|
+
File.read('compiled/t.txt').should == <<END
|
97
|
+
Some plain text
|
98
|
+
END
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
def stub_files files
|
2
|
+
files.each_pair do |name,content|
|
3
|
+
dir = File.dirname(name)
|
4
|
+
FileUtils.mkdir_p dir unless File.directory? dir
|
5
|
+
File.open(name,'w+') do |f|
|
6
|
+
f.write content
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def stub_files_and_run files
|
12
|
+
stub_files files
|
13
|
+
c = Lavender::Static.new
|
14
|
+
c.run
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lavender
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Tom Adams
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-16 00:00:00 -04:00
|
18
|
+
default_executable: lavender
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: haml
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
description:
|
60
|
+
email: tom@holizz.com
|
61
|
+
executables:
|
62
|
+
- lavender
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- README.rdoc
|
67
|
+
files:
|
68
|
+
- .gitignore
|
69
|
+
- LICENCE
|
70
|
+
- README.rdoc
|
71
|
+
- Rakefile
|
72
|
+
- VERSION
|
73
|
+
- bin/lavender
|
74
|
+
- lib/lavender.rb
|
75
|
+
- lib/lavender/command.rb
|
76
|
+
- lib/lavender/config.rb
|
77
|
+
- lib/lavender/converter.rb
|
78
|
+
- lib/lavender/renderer.rb
|
79
|
+
- lib/lavender/static.rb
|
80
|
+
- spec/command_spec.rb
|
81
|
+
- spec/config_spec.rb
|
82
|
+
- spec/converter_spec.rb
|
83
|
+
- spec/renderer_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
- spec/static_spec.rb
|
86
|
+
- spec/support/stub_files.rb
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://github.com/holizz/lavender
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options:
|
93
|
+
- --charset=UTF-8
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.3.7
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: Minimalistic YAML-based CMS
|
119
|
+
test_files:
|
120
|
+
- spec/converter_spec.rb
|
121
|
+
- spec/command_spec.rb
|
122
|
+
- spec/static_spec.rb
|
123
|
+
- spec/renderer_spec.rb
|
124
|
+
- spec/support/stub_files.rb
|
125
|
+
- spec/config_spec.rb
|
126
|
+
- spec/spec_helper.rb
|