wormwood 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wormwood.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Erik Eldridge
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Wormwood
2
+
3
+ Wormwood is an event-driven file rendering utility inspired by [Jekyll](https://github.com/mojombo/jekyll).
4
+
5
+ Wormwood watches for changes to a template directory (_raw_ 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
+
7
+
8
+ ## Usage
9
+
10
+ 1. Create a _raw_ directory
11
+ 2. Create a _public_ directory
12
+ 3. Run `wormwood`
13
+ 4. Edit files in _raw_ and observe the changes rendered in _public_
14
+
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'wormwood'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install wormwood
29
+
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/wormwood ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'commander/import'
4
+ require 'wormwood'
5
+
6
+ program :name, 'wormwood'
7
+ program :version, Wormwood::VERSION
8
+ program :description, 'Wormwood is an event-driven file rendering utility inspired by Jekyll.'
9
+
10
+ default_command :watch
11
+
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 ./public)'
14
+
15
+ command :watch do |c|
16
+ c.syntax = 'wormwood [options]'
17
+ c.description = 'Watches source directory for changes, and writes rendered changes to the destination directory.'
18
+ c.action do |args, options|
19
+ options.default \
20
+ :source => './',
21
+ :destination => './public'
22
+ Wormwood.watch(options)
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Wormwood
2
+ VERSION = "0.0.2"
3
+ end
data/lib/wormwood.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'wormwood/version'
2
+ require 'directory_watcher'
3
+ require 'tilt'
4
+
5
+ module Wormwood
6
+
7
+ # ref: https://github.com/mojombo/jekyll/blob/master/lib/jekyll/commands/build.rb
8
+ # ref: https://github.com/TwP/directory_watcher/blob/master/lib/directory_watcher.rb
9
+ def self.watch(options)
10
+ dw = DirectoryWatcher.new(options.source)
11
+ dw.interval = 1
12
+ dw.add_observer do |*events|
13
+ build events.collect{|e| e.path}, options
14
+ end
15
+ dw.start
16
+ trap("INT") {exit 0}
17
+ loop { sleep 1000 }
18
+ end
19
+
20
+ def self.build paths, options
21
+ paths.each do |path|
22
+ begin
23
+ File.write \
24
+ "#{options.destination}/#{File.basename(path, ".*")}.html",
25
+ Tilt.new(path).render
26
+ rescue Exception => e
27
+ puts "wormwood build error: #{e.inspect}"
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,12 @@
1
+ require_relative '../../test_helper'
2
+ describe Wormwood do
3
+ before do
4
+ clear_dest
5
+ create_source
6
+ end
7
+
8
+ it "writes to the correct destination" do
9
+ Wormwood.build [source_dir("foo.erb")], {'source' => source_dir, 'destination' => dest_dir}
10
+ assert File.exist?(dest_dir('foo.html'))
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'fileutils'
4
+ require_relative '../lib/wormwood.rb'
5
+
6
+ def create_source
7
+ unless File.exists? source_dir
8
+ FileUtils.mkdir_p(source_dir)
9
+ File.write(source_dir('foo.erb'), "content")
10
+ end
11
+ end
12
+
13
+ # ref: https://github.com/mojombo/jekyll/blob/master/test/helper.rb
14
+ def dest_dir(*subdirs)
15
+ File.join(File.dirname(__FILE__), 'tmp/dest', *subdirs)
16
+ end
17
+
18
+ def source_dir(*subdirs)
19
+ File.join(File.dirname(__FILE__), 'tmp/source', *subdirs)
20
+ end
21
+
22
+ def clear_dest
23
+ FileUtils.rm_rf(dest_dir)
24
+ FileUtils.mkdir_p(dest_dir)
25
+ end
data/wormwood.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wormwood/version'
5
+
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "wormwood"
9
+ gem.version = Wormwood::VERSION
10
+ gem.authors = ["Erik Eldridge"]
11
+ gem.email = "contact@erikeldridge.com"
12
+ gem.description = "Wormwood is an event-driven file rendering utility inspired by Jekyll."
13
+ gem.summary = "Wormwood watches for changes to a template directory (\"raw\" by default), "+
14
+ "renders the changed files (via Tilt), and writes the rendered output to "+
15
+ "an output directory (\"public\" by default)."
16
+ gem.homepage = "http://github.com/erikeldridge/wormwood"
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+
23
+ gem.add_runtime_dependency('commander', "~> 4.1.3")
24
+ gem.add_runtime_dependency('directory_watcher', "~> 1.1")
25
+ gem.add_runtime_dependency('tilt', "~> 1.3.3")
26
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wormwood
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Erik Eldridge
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: commander
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 4.1.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 4.1.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: directory_watcher
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: tilt
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.3
62
+ description: Wormwood is an event-driven file rendering utility inspired by Jekyll.
63
+ email: contact@erikeldridge.com
64
+ executables:
65
+ - wormwood
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/wormwood
75
+ - lib/wormwood.rb
76
+ - lib/wormwood/version.rb
77
+ - test/lib/wormwood/build_test.rb
78
+ - test/test_helper.rb
79
+ - wormwood.gemspec
80
+ homepage: http://github.com/erikeldridge/wormwood
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.24
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Wormwood watches for changes to a template directory ("raw" by default),
104
+ renders the changed files (via Tilt), and writes the rendered output to an output
105
+ directory ("public" by default).
106
+ test_files:
107
+ - test/lib/wormwood/build_test.rb
108
+ - test/test_helper.rb