pith 0.2.3 → 0.3.0
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/bin/pith +5 -6
- data/features/relative_linking.feature +12 -12
- data/lib/pith/console_logger.rb +15 -8
- data/lib/pith/input.rb +83 -68
- data/lib/pith/output.rb +107 -0
- data/lib/pith/pathname_ext.rb +6 -1
- data/lib/pith/project.rb +73 -48
- data/lib/pith/render_context.rb +35 -32
- data/lib/pith/server.rb +30 -10
- data/lib/pith/version.rb +1 -1
- data/spec/pith/input_spec.rb +57 -20
- data/spec/pith/pathname_ext_spec.rb +29 -0
- data/spec/pith/project_spec.rb +58 -56
- data/spec/pith/server_spec.rb +101 -0
- data/spec/spec_helper.rb +1 -0
- metadata +34 -30
- data/features/reloading.feature +0 -48
- data/spec/pith/metadata_spec.rb~ +0 -46
- data/spec/pith/plugins/publication_spec.rb~ +0 -39
- data/spec/pith/project_spec.rb~ +0 -137
- data/spec/spec_helper.rb~ +0 -18
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pith/pathname_ext'
|
3
|
+
|
4
|
+
describe Pathname do
|
5
|
+
|
6
|
+
let(:pathname) { Pathname("foo/bar") }
|
7
|
+
|
8
|
+
describe "#in?" do
|
9
|
+
|
10
|
+
it "returns false for siblings" do
|
11
|
+
pathname.in?("foo/baz").should == false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns true for ancestors" do
|
15
|
+
pathname.in?("foo").should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns false for other prefixes" do
|
19
|
+
pathname.in?("fo").should == false
|
20
|
+
pathname.in?("foo/b").should == false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false for itself" do
|
24
|
+
pathname.in?("foo/bar").should == false
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/pith/project_spec.rb
CHANGED
@@ -4,48 +4,41 @@ require 'pith/project'
|
|
4
4
|
describe Pith::Project do
|
5
5
|
|
6
6
|
before do
|
7
|
-
$input_dir.mkpath
|
8
7
|
@project = Pith::Project.new(:input_dir => $input_dir, :output_dir => $output_dir)
|
9
8
|
end
|
10
9
|
|
11
10
|
describe "#build" do
|
12
|
-
|
11
|
+
|
13
12
|
before do
|
14
13
|
@project.build
|
15
14
|
end
|
16
|
-
|
15
|
+
|
17
16
|
it "creates the output directory" do
|
18
17
|
$output_dir.should be_directory
|
19
18
|
end
|
20
|
-
|
19
|
+
|
21
20
|
end
|
22
21
|
|
23
22
|
describe "#input" do
|
24
23
|
|
25
|
-
|
24
|
+
before do
|
25
|
+
@input_file = $input_dir + "input.html.haml"
|
26
|
+
@input_file.touch
|
27
|
+
@project.sync
|
28
|
+
end
|
26
29
|
|
27
|
-
|
28
|
-
@input_file = $input_dir + "input.html.haml"
|
29
|
-
@input_file.touch
|
30
|
-
end
|
30
|
+
describe "(with a template input path)" do
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "returns an Input object" do
|
33
33
|
@input = @project.input("input.html.haml")
|
34
34
|
@input.should be_kind_of(Pith::Input)
|
35
35
|
@input.file.should == @input_file
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
before do
|
43
|
-
@input_file = $input_dir + "input.html.haml"
|
44
|
-
@input_file.touch
|
45
|
-
end
|
46
|
-
|
47
|
-
it "can also be used to locate the Input" do
|
48
|
-
@project.input("input.html").should == @project.input("input.html.haml")
|
38
|
+
it "returns the same object the second time" do
|
39
|
+
first_time = @project.input("input.html.haml")
|
40
|
+
second_time = @project.input("input.html.haml")
|
41
|
+
second_time.should equal(first_time)
|
49
42
|
end
|
50
43
|
|
51
44
|
end
|
@@ -60,73 +53,82 @@ describe Pith::Project do
|
|
60
53
|
|
61
54
|
end
|
62
55
|
|
63
|
-
describe "
|
56
|
+
describe "#output" do
|
64
57
|
|
65
58
|
before do
|
66
59
|
@input_file = $input_dir + "input.html.haml"
|
67
60
|
@input_file.touch
|
61
|
+
@project.sync
|
68
62
|
end
|
69
63
|
|
70
|
-
describe "a
|
71
|
-
it "returns the same Input object" do
|
64
|
+
describe "(with a template output path)" do
|
72
65
|
|
73
|
-
|
74
|
-
first_time.should_not be_nil
|
66
|
+
let(:output) { @project.output("input.html") }
|
75
67
|
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
it "returns the matching Output" do
|
69
|
+
output.should be_kind_of(Pith::Output)
|
70
|
+
output.file.should == $output_dir + "input.html"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
79
74
|
|
75
|
+
describe "(with a bogus output path)" do
|
76
|
+
|
77
|
+
let(:output) { @project.output("bogus.html.haml") }
|
78
|
+
|
79
|
+
it "returns nil" do
|
80
|
+
output.should be_nil
|
80
81
|
end
|
82
|
+
|
81
83
|
end
|
82
84
|
|
83
85
|
end
|
84
86
|
|
85
|
-
describe "when an input file is
|
87
|
+
describe "when an input file is removed" do
|
86
88
|
|
87
89
|
before do
|
88
90
|
@input_file = $input_dir + "input.html.haml"
|
89
91
|
@input_file.touch(Time.now - 10)
|
92
|
+
@project.sync
|
93
|
+
@project.input("input.html.haml").should_not be_nil
|
94
|
+
@project.output("input.html").should_not be_nil
|
95
|
+
FileUtils.rm(@input_file)
|
96
|
+
@project.sync
|
90
97
|
end
|
91
98
|
|
92
|
-
describe "
|
93
|
-
it "returns
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
@input_file.touch(Time.now)
|
99
|
-
|
100
|
-
@project.refresh
|
101
|
-
second_time = @project.input("input.html.haml")
|
102
|
-
second_time.should_not be_nil
|
103
|
-
second_time.should_not equal(first_time)
|
99
|
+
describe "#input" do
|
100
|
+
it "returns nil" do
|
101
|
+
@project.input("input.html.haml").should be_nil
|
102
|
+
end
|
103
|
+
end
|
104
104
|
|
105
|
+
describe "#output" do
|
106
|
+
it "returns nil" do
|
107
|
+
@project.output("input.html").should be_nil
|
105
108
|
end
|
106
109
|
end
|
107
110
|
|
108
111
|
end
|
109
112
|
|
110
|
-
describe "
|
113
|
+
describe "#ignore_patterns" do
|
111
114
|
|
112
|
-
|
113
|
-
@
|
114
|
-
@input_file.touch(Time.now - 10)
|
115
|
+
it "is a set" do
|
116
|
+
@project.ignore_patterns.should be_kind_of(Set)
|
115
117
|
end
|
116
118
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
it "includes some sensible defaults" do
|
120
|
+
@project.ignore_patterns.should include("_*")
|
121
|
+
@project.ignore_patterns.should include(".git")
|
122
|
+
@project.ignore_patterns.should include(".svn")
|
123
|
+
end
|
122
124
|
|
123
|
-
|
125
|
+
end
|
124
126
|
|
125
|
-
|
126
|
-
second_time = @project.input("input.html.haml")
|
127
|
-
second_time.should be_nil
|
127
|
+
describe "#ignore" do
|
128
128
|
|
129
|
-
|
129
|
+
it "adds to ignore_patterns" do
|
130
|
+
@project.ignore("foo")
|
131
|
+
@project.ignore_patterns
|
130
132
|
end
|
131
133
|
|
132
134
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pith/server'
|
3
|
+
require 'rack/mock'
|
4
|
+
|
5
|
+
describe Pith::Server::OutputFinder do
|
6
|
+
|
7
|
+
let(:output_path) { "dir/index.html" }
|
8
|
+
let(:output) { stub(:path => Pathname(output_path), :build => true) }
|
9
|
+
|
10
|
+
let(:project) do
|
11
|
+
stub(:outputs => [output], :sync_every => nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:app) do
|
15
|
+
lambda do |env|
|
16
|
+
[
|
17
|
+
200,
|
18
|
+
{ "Location" => env["PATH_INFO"] },
|
19
|
+
["OKAY"]
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:middleware) do
|
25
|
+
Pith::Server::OutputFinder.new(app, project)
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:request_uri) { "/foo" }
|
29
|
+
let(:request_env) do
|
30
|
+
Rack::MockRequest.env_for(request_uri)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:result) do
|
34
|
+
middleware.call(request_env)
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:result_status) do
|
38
|
+
result[0]
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:result_headers) do
|
42
|
+
result[1]
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:result_path) do
|
46
|
+
result_headers["Location"]
|
47
|
+
end
|
48
|
+
|
49
|
+
context "request for a non-existant file" do
|
50
|
+
|
51
|
+
let(:request_uri) { "/bogus.html" }
|
52
|
+
|
53
|
+
it "does not build the output" do
|
54
|
+
output.should_not_receive(:build)
|
55
|
+
result_path
|
56
|
+
end
|
57
|
+
|
58
|
+
it "passes on the env unchanged" do
|
59
|
+
result_path.should == "/bogus.html"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.can_request_output(description, uri)
|
65
|
+
|
66
|
+
context "request for output #{description}" do
|
67
|
+
|
68
|
+
let(:request_uri) { uri }
|
69
|
+
|
70
|
+
it "builds the output" do
|
71
|
+
output.should_receive(:build)
|
72
|
+
result_path
|
73
|
+
end
|
74
|
+
|
75
|
+
it "passes on request" do
|
76
|
+
result_path.should == "/dir/index.html"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
can_request_output "directly", "/dir/index.html"
|
84
|
+
|
85
|
+
can_request_output "without .html", "/dir/index"
|
86
|
+
|
87
|
+
can_request_output "directory with slash", "/dir/"
|
88
|
+
|
89
|
+
context "request for directory without slash" do
|
90
|
+
|
91
|
+
let(:request_uri) { "/dir" }
|
92
|
+
|
93
|
+
it "redirects" do
|
94
|
+
result_status.should == 302
|
95
|
+
result_headers["Location"].should == "/dir/"
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,15 @@ dependencies:
|
|
21
21
|
version: '1.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: adsf
|
27
|
-
requirement: &70245266533620 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70245266533620
|
29
|
+
version: '1.3'
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: rack
|
38
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
@@ -43,10 +37,15 @@ dependencies:
|
|
43
37
|
version: 1.2.1
|
44
38
|
type: :runtime
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.1
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: thin
|
49
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
51
|
- - ! '>='
|
@@ -54,10 +53,15 @@ dependencies:
|
|
54
53
|
version: 1.2.7
|
55
54
|
type: :runtime
|
56
55
|
prerelease: false
|
57
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.7
|
58
62
|
- !ruby/object:Gem::Dependency
|
59
63
|
name: clamp
|
60
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
61
65
|
none: false
|
62
66
|
requirements:
|
63
67
|
- - ! '>='
|
@@ -65,7 +69,12 @@ dependencies:
|
|
65
69
|
version: 0.3.0
|
66
70
|
type: :runtime
|
67
71
|
prerelease: false
|
68
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.3.0
|
69
78
|
description: ! 'Pith builds static websites, using markup/template languages including
|
70
79
|
Haml, Sass, ERb, Liquid, Markdown and Textile.
|
71
80
|
|
@@ -81,6 +90,7 @@ files:
|
|
81
90
|
- lib/pith/input.rb
|
82
91
|
- lib/pith/input.rb~
|
83
92
|
- lib/pith/metadata.rb~
|
93
|
+
- lib/pith/output.rb
|
84
94
|
- lib/pith/pathname_ext.rb
|
85
95
|
- lib/pith/pathname_ext.rb~
|
86
96
|
- lib/pith/plugins/publication/input.rb
|
@@ -111,13 +121,11 @@ files:
|
|
111
121
|
- README.markdown
|
112
122
|
- Rakefile
|
113
123
|
- spec/pith/input_spec.rb
|
114
|
-
- spec/pith/
|
124
|
+
- spec/pith/pathname_ext_spec.rb
|
115
125
|
- spec/pith/plugins/publication_spec.rb
|
116
|
-
- spec/pith/plugins/publication_spec.rb~
|
117
126
|
- spec/pith/project_spec.rb
|
118
|
-
- spec/pith/
|
127
|
+
- spec/pith/server_spec.rb
|
119
128
|
- spec/spec_helper.rb
|
120
|
-
- spec/spec_helper.rb~
|
121
129
|
- features/cleanup.feature
|
122
130
|
- features/content_for.feature
|
123
131
|
- features/content_for.feature~
|
@@ -141,7 +149,6 @@ files:
|
|
141
149
|
- features/pipeline.feature
|
142
150
|
- features/relative_linking.feature
|
143
151
|
- features/relative_linking.feature~
|
144
|
-
- features/reloading.feature
|
145
152
|
- features/resources.feature
|
146
153
|
- features/step_definitions/build_steps.rb
|
147
154
|
- features/step_definitions/build_steps.rb~
|
@@ -169,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
176
|
version: '0'
|
170
177
|
segments:
|
171
178
|
- 0
|
172
|
-
hash:
|
179
|
+
hash: -22568693852038165
|
173
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
181
|
none: false
|
175
182
|
requirements:
|
@@ -178,23 +185,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
185
|
version: '0'
|
179
186
|
segments:
|
180
187
|
- 0
|
181
|
-
hash:
|
188
|
+
hash: -22568693852038165
|
182
189
|
requirements: []
|
183
190
|
rubyforge_project:
|
184
|
-
rubygems_version: 1.8.
|
191
|
+
rubygems_version: 1.8.21
|
185
192
|
signing_key:
|
186
193
|
specification_version: 3
|
187
194
|
summary: A static website generator
|
188
195
|
test_files:
|
189
196
|
- Rakefile
|
190
197
|
- spec/pith/input_spec.rb
|
191
|
-
- spec/pith/
|
198
|
+
- spec/pith/pathname_ext_spec.rb
|
192
199
|
- spec/pith/plugins/publication_spec.rb
|
193
|
-
- spec/pith/plugins/publication_spec.rb~
|
194
200
|
- spec/pith/project_spec.rb
|
195
|
-
- spec/pith/
|
201
|
+
- spec/pith/server_spec.rb
|
196
202
|
- spec/spec_helper.rb
|
197
|
-
- spec/spec_helper.rb~
|
198
203
|
- features/cleanup.feature
|
199
204
|
- features/content_for.feature
|
200
205
|
- features/content_for.feature~
|
@@ -218,7 +223,6 @@ test_files:
|
|
218
223
|
- features/pipeline.feature
|
219
224
|
- features/relative_linking.feature
|
220
225
|
- features/relative_linking.feature~
|
221
|
-
- features/reloading.feature
|
222
226
|
- features/resources.feature
|
223
227
|
- features/step_definitions/build_steps.rb
|
224
228
|
- features/step_definitions/build_steps.rb~
|