wormwood 0.0.2 → 0.0.4
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/README.md +11 -5
- data/bin/wormwood +2 -2
- data/lib/wormwood/version.rb +1 -1
- data/lib/wormwood.rb +10 -9
- data/test/lib/wormwood/build_test.rb +3 -1
- data/test/test_helper.rb +1 -0
- data/wormwood.gemspec +2 -3
- metadata +5 -5
data/README.md
CHANGED
@@ -2,15 +2,21 @@
|
|
2
2
|
|
3
3
|
Wormwood is an event-driven file rendering utility inspired by [Jekyll](https://github.com/mojombo/jekyll).
|
4
4
|
|
5
|
-
Wormwood watches for changes to a template directory (
|
5
|
+
Wormwood watches for changes to a template directory ( _./_ by default), renders the changed files (via [Tilt](https://github.com/rtomayko/tilt)), and writes the rendered output to an output directory ( _public_ by default).
|
6
6
|
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
|
-
1. Create a
|
11
|
-
2.
|
12
|
-
3.
|
13
|
-
|
10
|
+
1. Create a file [Tilt](https://github.com/rtomayko/tilt)) knows how to render, e.g., _foo.erb_
|
11
|
+
2. Run `wormwood`
|
12
|
+
3. Edit _foo.erb_ and observe changes applied to _foo.html_
|
13
|
+
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
You can specify _source_ and _destination_ directories as options. For example:
|
18
|
+
|
19
|
+
wormwood -s templates -d public
|
14
20
|
|
15
21
|
|
16
22
|
## Installation
|
data/bin/wormwood
CHANGED
@@ -10,7 +10,7 @@ program :description, 'Wormwood is an event-driven file rendering utility inspir
|
|
10
10
|
default_command :watch
|
11
11
|
|
12
12
|
global_option '-s', '--source [DIR]', 'Watches specified directory path (defaults to ./)'
|
13
|
-
global_option '-d', '--destination [DIR]', 'Writes to specified directory path (defaults to ./
|
13
|
+
global_option '-d', '--destination [DIR]', 'Writes to specified directory path (defaults to ./)'
|
14
14
|
|
15
15
|
command :watch do |c|
|
16
16
|
c.syntax = 'wormwood [options]'
|
@@ -18,7 +18,7 @@ command :watch do |c|
|
|
18
18
|
c.action do |args, options|
|
19
19
|
options.default \
|
20
20
|
:source => './',
|
21
|
-
:destination => './
|
21
|
+
:destination => './'
|
22
22
|
Wormwood.watch(options)
|
23
23
|
end
|
24
24
|
end
|
data/lib/wormwood/version.rb
CHANGED
data/lib/wormwood.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
require 'wormwood/version'
|
2
3
|
require 'directory_watcher'
|
4
|
+
require 'fileutils'
|
3
5
|
require 'tilt'
|
4
6
|
|
5
7
|
module Wormwood
|
8
|
+
GLOB = '**/*.{erb,rhtml,markdown,mkd,md}'
|
6
9
|
|
7
10
|
# ref: https://github.com/mojombo/jekyll/blob/master/lib/jekyll/commands/build.rb
|
8
11
|
# ref: https://github.com/TwP/directory_watcher/blob/master/lib/directory_watcher.rb
|
9
12
|
def self.watch(options)
|
10
|
-
dw = DirectoryWatcher.new(options.source)
|
13
|
+
dw = DirectoryWatcher.new(options.source, :glob => GLOB, :pre_load => true)
|
11
14
|
dw.interval = 1
|
12
15
|
dw.add_observer do |*events|
|
13
16
|
build events.collect{|e| e.path}, options
|
@@ -18,14 +21,12 @@ module Wormwood
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.build paths, options
|
21
|
-
paths.each do |
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
puts "wormwood build error: #{e.inspect}"
|
28
|
-
end
|
24
|
+
paths.each do |source_path|
|
25
|
+
dest_path = File.dirname(source_path).sub(options.source, options.destination)
|
26
|
+
FileUtils.mkdir_p(dest_path) unless File.exists? dest_path
|
27
|
+
File.write \
|
28
|
+
"#{dest_path}/#{File.basename(source_path, ".*")}.html",
|
29
|
+
Tilt.new(source_path).render
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -6,7 +6,9 @@ describe Wormwood do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "writes to the correct destination" do
|
9
|
-
Wormwood.build
|
9
|
+
Wormwood.build \
|
10
|
+
[source_dir("foo.erb")],
|
11
|
+
OpenStruct.new({'source' => source_dir, 'destination' => dest_dir})
|
10
12
|
assert File.exist?(dest_dir('foo.html'))
|
11
13
|
end
|
12
14
|
end
|
data/test/test_helper.rb
CHANGED
data/wormwood.gemspec
CHANGED
@@ -3,16 +3,15 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'wormwood/version'
|
5
5
|
|
6
|
-
|
7
6
|
Gem::Specification.new do |gem|
|
8
7
|
gem.name = "wormwood"
|
9
8
|
gem.version = Wormwood::VERSION
|
10
9
|
gem.authors = ["Erik Eldridge"]
|
11
10
|
gem.email = "contact@erikeldridge.com"
|
12
11
|
gem.description = "Wormwood is an event-driven file rendering utility inspired by Jekyll."
|
13
|
-
gem.summary = "Wormwood watches for changes to a template directory (\"
|
12
|
+
gem.summary = "Wormwood watches for changes to a template directory (\"./\" by default), "+
|
14
13
|
"renders the changed files (via Tilt), and writes the rendered output to "+
|
15
|
-
"an output directory (\"
|
14
|
+
"an output directory (\"./\" by default)."
|
16
15
|
gem.homepage = "http://github.com/erikeldridge/wormwood"
|
17
16
|
|
18
17
|
gem.files = `git ls-files`.split($/)
|
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.4
|
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-02-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
@@ -100,9 +100,9 @@ rubyforge_project:
|
|
100
100
|
rubygems_version: 1.8.24
|
101
101
|
signing_key:
|
102
102
|
specification_version: 3
|
103
|
-
summary: Wormwood watches for changes to a template directory ("
|
104
|
-
|
105
|
-
|
103
|
+
summary: Wormwood watches for changes to a template directory ("./" by default), renders
|
104
|
+
the changed files (via Tilt), and writes the rendered output to an output directory
|
105
|
+
("./" by default).
|
106
106
|
test_files:
|
107
107
|
- test/lib/wormwood/build_test.rb
|
108
108
|
- test/test_helper.rb
|