pith 0.0.11 → 0.0.12
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/Rakefile +4 -0
- data/features/error_handling.feature +16 -0
- data/features/ignorance.feature +19 -28
- data/features/step_definitions/build_steps.rb +8 -0
- data/features/support/rspec_matchers.rb +2 -0
- data/lib/pith/console_logger.rb +14 -3
- data/lib/pith/exception_ext.rb +9 -0
- data/lib/pith/input/abstract.rb +5 -1
- data/lib/pith/input/template.rb +11 -2
- data/lib/pith/project.rb +4 -0
- data/lib/pith/version.rb +1 -1
- data/lib/pith/watcher.rb +0 -3
- data/spec/pith/input/template_spec.rb +2 -2
- metadata +80 -21
data/Rakefile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: error handling
|
2
|
+
|
3
|
+
I want to be told when something goes wrong
|
4
|
+
|
5
|
+
Scenario: bad haml
|
6
|
+
|
7
|
+
Given input file "index.html.haml" contains
|
8
|
+
"""
|
9
|
+
%h2{class="this is not valid ruby"} Heading
|
10
|
+
|
11
|
+
%p Content
|
12
|
+
"""
|
13
|
+
|
14
|
+
When I build the site
|
15
|
+
|
16
|
+
Then output file "index.html" should contain /syntax error/
|
data/features/ignorance.feature
CHANGED
@@ -1,37 +1,28 @@
|
|
1
1
|
Feature: ignorable files are ignored
|
2
2
|
|
3
|
-
I want
|
3
|
+
I want certain files (or directories) to be ignored
|
4
4
|
So that I can place supporting files anywhere within the input directory
|
5
|
-
|
6
|
-
Scenario: a layout template at the input root
|
7
5
|
|
8
|
-
|
9
|
-
"""
|
10
|
-
Blah de blah
|
11
|
-
"""
|
12
|
-
|
13
|
-
When I build the site
|
14
|
-
|
15
|
-
Then output file "_layout" should not exist
|
16
|
-
|
17
|
-
Scenario: a partial in an ignored subdirectory
|
6
|
+
Scenario Outline: ignorable templates
|
18
7
|
|
19
|
-
Given input file
|
20
|
-
"""
|
21
|
-
Blah de blah
|
22
|
-
"""
|
23
|
-
|
8
|
+
Given input file <input> exists
|
24
9
|
When I build the site
|
25
|
-
|
26
|
-
Then output file "_partials/foo.html" should not exist
|
10
|
+
Then output file <output> should not exist
|
27
11
|
|
28
|
-
|
12
|
+
Examples:
|
13
|
+
| input | output |
|
14
|
+
| "_layout.haml" | "_layout" |
|
15
|
+
| "_partials/foo.html.haml" | "_partials/foo.html" |
|
16
|
+
| "partials/_foo.html.haml" | "partials/_foo.html" |
|
29
17
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
"""
|
34
|
-
|
18
|
+
Scenario Outline: ignorable resources
|
19
|
+
|
20
|
+
Given input file <file> exists
|
35
21
|
When I build the site
|
36
|
-
|
37
|
-
|
22
|
+
Then output file <file> should not exist
|
23
|
+
|
24
|
+
Examples:
|
25
|
+
| file |
|
26
|
+
| "_data/xyz.json" |
|
27
|
+
| ".git/config" |
|
28
|
+
| "xyz/.svn/blah" |
|
@@ -49,6 +49,10 @@ Then /^output file "([^\"]*)" should contain "([^\"]*)"$/ do |path, content|
|
|
49
49
|
@outputs[path].clean.should == content.clean
|
50
50
|
end
|
51
51
|
|
52
|
+
Then %r{^output file "([^\"]*)" should contain /([^\/]*)/$} do |path, regexp|
|
53
|
+
@outputs[path].clean.should =~ Regexp.compile(regexp)
|
54
|
+
end
|
55
|
+
|
52
56
|
Then /^output file "([^\"]*)" should contain$/ do |path, content|
|
53
57
|
@outputs[path].clean.should == content.clean
|
54
58
|
end
|
@@ -64,3 +68,7 @@ end
|
|
64
68
|
Then /^output file "([^"]*)" should not be re\-generated$/ do |path|
|
65
69
|
@project.logger.messages.should_not contain(/--> +#{path}/)
|
66
70
|
end
|
71
|
+
|
72
|
+
Then /^output file "([^\"]*)" should contain an error$/ do |path|
|
73
|
+
@outputs[path].clean.should == "foo"
|
74
|
+
end
|
data/lib/pith/console_logger.rb
CHANGED
@@ -2,13 +2,24 @@ module Pith
|
|
2
2
|
|
3
3
|
class ConsoleLogger
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(out = STDOUT, err = STDERR)
|
6
|
+
@out = out
|
7
|
+
@err = err
|
7
8
|
end
|
8
9
|
|
9
10
|
def info(message, &block)
|
10
11
|
message ||= block.call
|
11
|
-
@
|
12
|
+
@out.puts(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def warn(message, &block)
|
16
|
+
message ||= block.call
|
17
|
+
@err.puts(message)
|
18
|
+
end
|
19
|
+
|
20
|
+
def error(message, &block)
|
21
|
+
message ||= block.call
|
22
|
+
@err.puts("ERROR: " + message)
|
12
23
|
end
|
13
24
|
|
14
25
|
end
|
data/lib/pith/input/abstract.rb
CHANGED
@@ -59,7 +59,11 @@ module Pith
|
|
59
59
|
# Returns true if it can.
|
60
60
|
#
|
61
61
|
def ignorable?
|
62
|
-
path.
|
62
|
+
path.each_filename do |path_component|
|
63
|
+
project.ignore_patterns.each do |pattern|
|
64
|
+
return true if File.fnmatch(pattern, path_component)
|
65
|
+
end
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
protected
|
data/lib/pith/input/template.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "pathname"
|
3
|
+
require "pith/exception_ext"
|
3
4
|
require "pith/input/abstract"
|
4
5
|
require "pith/render_context"
|
5
6
|
require "tilt"
|
@@ -22,7 +23,6 @@ module Pith
|
|
22
23
|
path.to_str =~ /^(.+)\.(.+)$/ || raise("huh?")
|
23
24
|
@output_path = Pathname($1)
|
24
25
|
@type = $2
|
25
|
-
load
|
26
26
|
end
|
27
27
|
|
28
28
|
attr_reader :output_path, :type
|
@@ -41,7 +41,13 @@ module Pith
|
|
41
41
|
output_file.parent.mkpath
|
42
42
|
render_context = RenderContext.new(project)
|
43
43
|
output_file.open("w") do |out|
|
44
|
-
|
44
|
+
begin
|
45
|
+
out.puts(render_context.render(self))
|
46
|
+
rescue Exception => e
|
47
|
+
logger.warn e.summary(:max_backtrace => 5)
|
48
|
+
out.puts "<pre>"
|
49
|
+
out.puts e.summary
|
50
|
+
end
|
45
51
|
end
|
46
52
|
@dependencies = render_context.dependencies
|
47
53
|
end
|
@@ -49,6 +55,7 @@ module Pith
|
|
49
55
|
# Render this input using Tilt
|
50
56
|
#
|
51
57
|
def render(context, locals = {}, &block)
|
58
|
+
load
|
52
59
|
@tilt_template.render(context, locals, &block)
|
53
60
|
end
|
54
61
|
|
@@ -72,6 +79,7 @@ module Pith
|
|
72
79
|
# Returns a Hash.
|
73
80
|
#
|
74
81
|
def meta
|
82
|
+
load
|
75
83
|
@meta
|
76
84
|
end
|
77
85
|
|
@@ -100,6 +108,7 @@ module Pith
|
|
100
108
|
# Read input file, extracting YAML meta-data header, and template content.
|
101
109
|
#
|
102
110
|
def load
|
111
|
+
return false if @tilt_template
|
103
112
|
@meta = {}
|
104
113
|
file.open do |input|
|
105
114
|
header = input.gets
|
data/lib/pith/project.rb
CHANGED
@@ -8,13 +8,17 @@ module Pith
|
|
8
8
|
|
9
9
|
class Project
|
10
10
|
|
11
|
+
DEFAULT_IGNORE_PATTERNS = ["_*", ".git", ".svn"].freeze
|
12
|
+
|
11
13
|
def initialize(attributes = {})
|
14
|
+
@ignore_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
12
15
|
attributes.each do |k,v|
|
13
16
|
send("#{k}=", v)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
attr_reader :input_dir
|
21
|
+
attr_reader :ignore_patterns
|
18
22
|
|
19
23
|
def input_dir=(dir)
|
20
24
|
@input_dir = Pathname(dir)
|
data/lib/pith/version.rb
CHANGED
data/lib/pith/watcher.rb
CHANGED
@@ -34,8 +34,8 @@ describe Pith::Input::Template do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns false for non-template paths" do
|
37
|
-
Pith::Input::Template.can_handle?("foo.html").
|
38
|
-
Pith::Input::Template.can_handle?("foo").
|
37
|
+
Pith::Input::Template.can_handle?("foo.html").should_not be_true
|
38
|
+
Pith::Input::Template.can_handle?("foo").should_not be_true
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Williams
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-30 00:00:00 +11:00
|
19
19
|
default_executable: pith
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,11 +26,11 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 13
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
-
|
33
|
-
version: "
|
31
|
+
- 1
|
32
|
+
- 1
|
33
|
+
version: "1.1"
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -55,14 +55,14 @@ dependencies:
|
|
55
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ~>
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
60
|
+
hash: 29
|
61
61
|
segments:
|
62
62
|
- 1
|
63
|
+
- 2
|
63
64
|
- 1
|
64
|
-
|
65
|
-
version: 1.1.0
|
65
|
+
version: 1.2.1
|
66
66
|
type: :runtime
|
67
67
|
version_requirements: *id003
|
68
68
|
- !ruby/object:Gem::Dependency
|
@@ -71,23 +71,37 @@ dependencies:
|
|
71
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
76
|
+
hash: 17
|
77
77
|
segments:
|
78
78
|
- 1
|
79
79
|
- 2
|
80
|
-
-
|
81
|
-
version: 1.2.
|
80
|
+
- 7
|
81
|
+
version: 1.2.7
|
82
82
|
type: :runtime
|
83
83
|
version_requirements: *id004
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: rake
|
86
86
|
prerelease: false
|
87
87
|
requirement: &id005 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
type: :development
|
97
|
+
version_requirements: *id005
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ~>
|
91
105
|
- !ruby/object:Gem::Version
|
92
106
|
hash: 13
|
93
107
|
segments:
|
@@ -96,14 +110,14 @@ dependencies:
|
|
96
110
|
- 9
|
97
111
|
version: 1.2.9
|
98
112
|
type: :development
|
99
|
-
version_requirements: *
|
113
|
+
version_requirements: *id006
|
100
114
|
- !ruby/object:Gem::Dependency
|
101
115
|
name: cucumber
|
102
116
|
prerelease: false
|
103
|
-
requirement: &
|
117
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
104
118
|
none: false
|
105
119
|
requirements:
|
106
|
-
- -
|
120
|
+
- - ~>
|
107
121
|
- !ruby/object:Gem::Version
|
108
122
|
hash: 57
|
109
123
|
segments:
|
@@ -112,7 +126,49 @@ dependencies:
|
|
112
126
|
- 3
|
113
127
|
version: 0.8.3
|
114
128
|
type: :development
|
115
|
-
version_requirements: *
|
129
|
+
version_requirements: *id007
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: haml
|
132
|
+
prerelease: false
|
133
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
type: :development
|
143
|
+
version_requirements: *id008
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: RedCloth
|
146
|
+
prerelease: false
|
147
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
hash: 3
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
version: "0"
|
156
|
+
type: :development
|
157
|
+
version_requirements: *id009
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rdiscount
|
160
|
+
prerelease: false
|
161
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
hash: 3
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
version: "0"
|
170
|
+
type: :development
|
171
|
+
version_requirements: *id010
|
116
172
|
description: |
|
117
173
|
Pith builds static websites, using markup/template languages including Haml, Sass, ERb, Liquid, Markdown and Textile.
|
118
174
|
|
@@ -126,6 +182,7 @@ extra_rdoc_files: []
|
|
126
182
|
files:
|
127
183
|
- lib/pith/console_logger.rb
|
128
184
|
- lib/pith/console_logger.rb~
|
185
|
+
- lib/pith/exception_ext.rb
|
129
186
|
- lib/pith/input/abstract.rb
|
130
187
|
- lib/pith/input/abstract.rb~
|
131
188
|
- lib/pith/input/base.rb~
|
@@ -181,6 +238,7 @@ files:
|
|
181
238
|
- features/cleanup.feature
|
182
239
|
- features/content_for.feature
|
183
240
|
- features/content_for.feature~
|
241
|
+
- features/error_handling.feature
|
184
242
|
- features/haml.feature
|
185
243
|
- features/haml.feature~
|
186
244
|
- features/helpers.feature
|
@@ -260,6 +318,7 @@ test_files:
|
|
260
318
|
- features/cleanup.feature
|
261
319
|
- features/content_for.feature
|
262
320
|
- features/content_for.feature~
|
321
|
+
- features/error_handling.feature
|
263
322
|
- features/haml.feature
|
264
323
|
- features/haml.feature~
|
265
324
|
- features/helpers.feature
|