wormwood 0.0.5 → 0.0.6
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.
- data/.gitignore +1 -0
- data/README.md +15 -5
- data/bin/wormwood +10 -4
- data/lib/wormwood/version.rb +1 -1
- data/lib/wormwood.rb +6 -4
- data/test/lib/wormwood/build_test.rb +7 -1
- data/test/test_helper.rb +2 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
Wormwood is an event-driven file rendering utility inspired by [Jekyll](https://github.com/mojombo/jekyll).
|
4
4
|
|
5
|
-
Wormwood
|
6
|
-
|
5
|
+
Wormwood:
|
6
|
+
1. watches for changes to a template directory ( _./_ by default)
|
7
|
+
2. renders the changed files (via [Tilt](https://github.com/rtomayko/tilt))
|
8
|
+
3. writes the rendered output to an output directory ( _./_ by default).
|
7
9
|
|
8
10
|
## Usage
|
9
11
|
|
10
|
-
1. Create a file [Tilt](https://github.com/rtomayko/tilt)
|
11
|
-
2.
|
12
|
-
3.
|
12
|
+
1. Create a file [Tilt](https://github.com/rtomayko/tilt) knows how to render, e.g., _foo.erb_
|
13
|
+
2. Create a file named "layout" in the same directory, with a Tilt-supported extension, e.g., _layout.erb_
|
14
|
+
3. Reference _content_ in the layout, e.g., `<%= content %>`
|
15
|
+
4. Run `wormwood`
|
16
|
+
5. Edit _foo.erb_ and observe changes applied to _foo.html_
|
13
17
|
|
14
18
|
|
15
19
|
## Configuration
|
@@ -18,6 +22,12 @@ You can specify _source_ and _destination_ directories as options. For example:
|
|
18
22
|
|
19
23
|
wormwood -s templates -d public
|
20
24
|
|
25
|
+
Other options:
|
26
|
+
|
27
|
+
`--layout` specifies the layout file name (without the extension), e.g., `wormwood --layout default`. Defaults to "layout".
|
28
|
+
|
29
|
+
`--variable` specifies the variable name used to insert the rendered content into the layout, e.g., `wormwood --variable yield`. Defaults to "content".
|
30
|
+
|
21
31
|
|
22
32
|
## Installation
|
23
33
|
|
data/bin/wormwood
CHANGED
@@ -9,8 +9,10 @@ program :description, 'Event-driven template rendering inspired by Jekyll.'
|
|
9
9
|
|
10
10
|
default_command :watch
|
11
11
|
|
12
|
-
global_option '
|
13
|
-
global_option '
|
12
|
+
global_option '--source [DIR]', 'Watches specified directory path (defaults to "./")'
|
13
|
+
global_option '--destination [DIR]', 'Writes to specified directory path (defaults to "./")'
|
14
|
+
global_option '--layout [NAME]', 'The layout file name (defaults to "layout")'
|
15
|
+
global_option '--variable [NAME]', 'The layout variable name (defaults to "content")'
|
14
16
|
|
15
17
|
command :watch do |c|
|
16
18
|
c.syntax = 'wormwood watch [options]'
|
@@ -18,7 +20,9 @@ command :watch do |c|
|
|
18
20
|
c.action do |args, options|
|
19
21
|
options.default \
|
20
22
|
:source => './',
|
21
|
-
:destination => './'
|
23
|
+
:destination => './',
|
24
|
+
:layout => 'layout',
|
25
|
+
:variable => 'content'
|
22
26
|
Wormwood.watch(options)
|
23
27
|
end
|
24
28
|
end
|
@@ -29,7 +33,9 @@ command :build do |c|
|
|
29
33
|
c.action do |args, options|
|
30
34
|
options.default \
|
31
35
|
:source => './',
|
32
|
-
:destination => './'
|
36
|
+
:destination => './',
|
37
|
+
:layout => 'layout',
|
38
|
+
:variable => 'content'
|
33
39
|
Wormwood.build(Dir[Wormwood::GLOB], options)
|
34
40
|
end
|
35
41
|
end
|
data/lib/wormwood/version.rb
CHANGED
data/lib/wormwood.rb
CHANGED
@@ -21,12 +21,14 @@ module Wormwood
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.build paths, options
|
24
|
+
layout_path = Dir.glob(File.join(options.source, "#{options.layout}*")).first
|
24
25
|
paths.each do |source_path|
|
25
|
-
dest_path = File.
|
26
|
-
|
26
|
+
dest_path = File.join \
|
27
|
+
options.destination,
|
28
|
+
"#{File.basename(source_path, ".*")}.html"
|
27
29
|
File.write \
|
28
|
-
|
29
|
-
Tilt.new(source_path).render
|
30
|
+
dest_path,
|
31
|
+
Tilt.new(layout_path).render(nil, {options.variable => Tilt.new(source_path).render})
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -8,7 +8,13 @@ describe Wormwood do
|
|
8
8
|
it "writes to the correct destination" do
|
9
9
|
Wormwood.build \
|
10
10
|
[source_dir("foo.erb")],
|
11
|
-
OpenStruct.new({
|
11
|
+
OpenStruct.new({
|
12
|
+
'source' => source_dir,
|
13
|
+
'destination' => dest_dir,
|
14
|
+
'layout' => 'layout',
|
15
|
+
'variable' => 'content'
|
16
|
+
})
|
12
17
|
assert File.exist?(dest_dir('foo.html'))
|
18
|
+
assert "asd" == File.read(dest_dir('foo.html'))
|
13
19
|
end
|
14
20
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,7 +7,8 @@ require_relative '../lib/wormwood.rb'
|
|
7
7
|
def create_source
|
8
8
|
unless File.exists? source_dir
|
9
9
|
FileUtils.mkdir_p(source_dir)
|
10
|
-
File.write(source_dir('
|
10
|
+
File.write(source_dir('layout.erb'), "<%= content %>")
|
11
|
+
File.write(source_dir('foo.erb'), "asd")
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wormwood
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|