benoit 0.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -2
- data/.rspec +1 -1
- data/Assetfile +19 -4
- data/Gemfile.lock +29 -5
- data/Guardfile +28 -0
- data/Rakefile +2 -0
- data/benoit.gemspec +5 -0
- data/bin/benoit +25 -7
- data/lib/benoit/cadenza.rb +2 -0
- data/lib/benoit/cadenza/blocks.rb +18 -0
- data/lib/benoit/compiler_error.rb +5 -1
- data/lib/benoit/filters/base_filter.rb +4 -5
- data/lib/benoit/filters/cadenza_filter.rb +19 -16
- data/lib/benoit/filters/markdown_filter.rb +36 -4
- data/lib/benoit/logger.rb +2 -2
- data/lib/benoit/pipeline_project.rb +23 -23
- data/lib/benoit/server.rb +47 -0
- data/lib/benoit/server/remote.rb +29 -0
- data/lib/benoit/utils/finds_layouts_for_template.rb +28 -30
- data/lib/benoit/version.rb +1 -1
- data/spec/features/build_command.feature +1 -1
- data/spec/features/frontmatter_metadata.feature +3 -21
- data/spec/features/javascript_files.feature +1 -0
- data/spec/features/markdown_files.feature +41 -0
- data/spec/features/output_filters.feature +2 -7
- data/spec/features/page_layouts.feature +4 -28
- data/spec/features/pagination.feature +1 -0
- data/spec/lib/filters/base_filter_spec.rb +4 -33
- data/spec/lib/filters/markdown_filter_spec.rb +31 -8
- data/spec/lib/filters/sass_filter_spec.rb +2 -2
- data/spec/lib/site_context_spec.rb +2 -2
- data/spec/steps/staticly_steps.rb +1 -1
- data/spec/support/spec_helpers/memory_file_wrapper.rb +2 -6
- data/vendor/rake-pipeline/GETTING_STARTED.md +11 -11
- data/vendor/rake-pipeline/bin/rakep +1 -1
- data/vendor/rake-pipeline/lib/rake-pipeline.rb +2 -49
- data/vendor/rake-pipeline/lib/rake-pipeline/cli.rb +0 -1
- data/vendor/rake-pipeline/lib/rake-pipeline/file_wrapper.rb +2 -9
- data/vendor/rake-pipeline/lib/rake-pipeline/filter.rb +1 -19
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest.rb +4 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/middleware.rb +1 -2
- data/vendor/rake-pipeline/lib/rake-pipeline/project.rb +3 -2
- data/vendor/rake-pipeline/rake-pipeline.gemspec +1 -1
- data/vendor/rake-pipeline/spec/cli_spec.rb +0 -2
- data/vendor/rake-pipeline/spec/concat_filter_spec.rb +4 -4
- data/vendor/rake-pipeline/spec/filter_spec.rb +0 -35
- data/vendor/rake-pipeline/spec/gsub_filter_spec.rb +5 -5
- data/vendor/rake-pipeline/spec/ordering_concat_filter_spec.rb +4 -4
- data/vendor/rake-pipeline/spec/rake_acceptance_spec.rb +18 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/filters.rb +1 -1
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_file_wrapper.rb +2 -6
- metadata +77 -2
@@ -16,6 +16,14 @@ describe Benoit::Filters::MarkdownFilter do
|
|
16
16
|
EOS
|
17
17
|
}
|
18
18
|
|
19
|
+
let(:markdown_extends_input) {
|
20
|
+
<<-EOS.unindent
|
21
|
+
{% extends "_layout.html" %}
|
22
|
+
|
23
|
+
[some link](http://www.example.com)
|
24
|
+
EOS
|
25
|
+
}
|
26
|
+
|
19
27
|
let(:expected_output) {
|
20
28
|
<<-EOS.unindent
|
21
29
|
<p><a href="http://www.example.com">some link</a></p>
|
@@ -25,19 +33,27 @@ describe Benoit::Filters::MarkdownFilter do
|
|
25
33
|
EOS
|
26
34
|
}
|
27
35
|
|
36
|
+
let(:expected_extends_output) {
|
37
|
+
<<-EOS
|
38
|
+
{% extends "_layout.html" %}
|
39
|
+
|
40
|
+
<p><a href="http://www.example.com">some link</a></p>
|
41
|
+
EOS
|
42
|
+
}
|
43
|
+
|
28
44
|
def input_file(name, content)
|
29
|
-
MemoryFileWrapper.new("/path/to/input", name, "UTF-8",
|
45
|
+
MemoryFileWrapper.new("/path/to/input", name, "UTF-8", content)
|
30
46
|
end
|
31
47
|
|
32
48
|
def output_file(name)
|
33
|
-
MemoryFileWrapper.new("/path/to/output", name, "UTF-8"
|
49
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8")
|
34
50
|
end
|
35
51
|
|
36
|
-
def setup_filter(filter, input_filename='page.markdown')
|
52
|
+
def setup_filter(filter, input_filename='page.markdown', content=markdown_input)
|
37
53
|
filter.file_wrapper_class = MemoryFileWrapper
|
38
54
|
filter.manifest = MemoryManifest.new
|
39
55
|
filter.last_manifest = MemoryManifest.new
|
40
|
-
filter.input_files = [input_file(input_filename,
|
56
|
+
filter.input_files = [input_file(input_filename, content)]
|
41
57
|
filter.output_root= "/path/to/output"
|
42
58
|
filter.rake_application = Rake::Application.new
|
43
59
|
filter
|
@@ -49,9 +65,6 @@ describe Benoit::Filters::MarkdownFilter do
|
|
49
65
|
input_file = filter.input_files.first
|
50
66
|
output_file = output_file("page.html")
|
51
67
|
|
52
|
-
page = { "content" => markdown_input }
|
53
|
-
filter.current_site = { input_file.path => page, output_file.path => page }
|
54
|
-
|
55
68
|
expect(filter.output_files).to eq([output_file])
|
56
69
|
|
57
70
|
tasks = filter.generate_rake_tasks
|
@@ -59,7 +72,17 @@ describe Benoit::Filters::MarkdownFilter do
|
|
59
72
|
|
60
73
|
file = MemoryFileWrapper.files["/path/to/output/page.html"]
|
61
74
|
expect(file.body).to eq(expected_output)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "keeps extends tag in place" do
|
78
|
+
filter = setup_filter described_class.new, 'page.markdown', markdown_extends_input
|
79
|
+
|
80
|
+
input_file = filter.input_files.first
|
62
81
|
|
63
|
-
|
82
|
+
tasks = filter.generate_rake_tasks
|
83
|
+
tasks.each(&:invoke)
|
84
|
+
|
85
|
+
file = MemoryFileWrapper.files["/path/to/output/page.html"]
|
86
|
+
expect(file.body).to eq(expected_extends_output)
|
64
87
|
end
|
65
88
|
end
|
@@ -24,11 +24,11 @@ describe Benoit::Filters::SassFilter do
|
|
24
24
|
|
25
25
|
def input_file
|
26
26
|
path = scss_input_path
|
27
|
-
FileWrapper.new(File.dirname(path), File.basename(path), "UTF-8"
|
27
|
+
FileWrapper.new(File.dirname(path), File.basename(path), "UTF-8")
|
28
28
|
end
|
29
29
|
|
30
30
|
def output_file(name)
|
31
|
-
MemoryFileWrapper.new("/path/to/output", name, "UTF-8"
|
31
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8")
|
32
32
|
end
|
33
33
|
|
34
34
|
def setup_filter(filter)
|
@@ -61,8 +61,8 @@ describe SiteContext::ContextObject do
|
|
61
61
|
|
62
62
|
describe "for non-existant collections" do
|
63
63
|
subject { context.blah }
|
64
|
-
it "
|
65
|
-
expect(
|
64
|
+
it "returns an empty array" do
|
65
|
+
expect(subject).to eq([])
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -90,7 +90,7 @@ module BenoitSteps
|
|
90
90
|
end
|
91
91
|
|
92
92
|
step "a cache directory should exist for that site" do
|
93
|
-
path = File.expand_path(File.join("
|
93
|
+
path = File.expand_path(File.join("/tmp", ".benoit", "tmpcache", @site.name))
|
94
94
|
step 'a directory named "%s" should exist' % path
|
95
95
|
end
|
96
96
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Rake::Pipeline
|
2
2
|
module SpecHelpers
|
3
|
-
class MemoryFileWrapper < Struct.new(:root, :path, :encoding, :
|
3
|
+
class MemoryFileWrapper < Struct.new(:root, :path, :encoding, :body)
|
4
4
|
|
5
5
|
@@files = {}
|
6
6
|
@@data = {}
|
@@ -14,11 +14,7 @@ class Rake::Pipeline
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def with_encoding(new_encoding)
|
17
|
-
self.class.new(root, path, new_encoding,
|
18
|
-
end
|
19
|
-
|
20
|
-
def original_inputs
|
21
|
-
Set.new([])
|
17
|
+
self.class.new(root, path, new_encoding, body)
|
22
18
|
end
|
23
19
|
|
24
20
|
def fullpath
|
@@ -36,6 +36,9 @@ and 2 files are outputs. The `source` directory is input and the output
|
|
36
36
|
will go into `compiled`. Here's the `Assetfile` to do just that:
|
37
37
|
|
38
38
|
```ruby
|
39
|
+
# Set the Pipeline's output directory
|
40
|
+
output "compiled"
|
41
|
+
|
39
42
|
# input defines operations on a set of files. All files processed in
|
40
43
|
# this block go into the output directory
|
41
44
|
input "source" do
|
@@ -53,9 +56,6 @@ input "source" do
|
|
53
56
|
concat "application.js"
|
54
57
|
end
|
55
58
|
end
|
56
|
-
|
57
|
-
# Set the Pipeline's output directory
|
58
|
-
output "compiled"
|
59
59
|
```
|
60
60
|
|
61
61
|
Now run `rakep build` from the project root to compile everything.
|
@@ -93,6 +93,9 @@ different location. In short, `concat` is aliased to `copy` as well.
|
|
93
93
|
Here's the updated `Assetfile`:
|
94
94
|
|
95
95
|
```ruby
|
96
|
+
# Set the Pipeline's output directory
|
97
|
+
output "compiled"
|
98
|
+
|
96
99
|
# input defines operations on a set of files. All files processed in
|
97
100
|
# this block go into the output directory
|
98
101
|
input "source" do
|
@@ -119,9 +122,6 @@ input "source" do
|
|
119
122
|
copy
|
120
123
|
end
|
121
124
|
end
|
122
|
-
|
123
|
-
# Set the Pipeline's output directory
|
124
|
-
output "compiled"
|
125
125
|
```
|
126
126
|
|
127
127
|
Now we can run `rakep server` inside the projects root. You'll see some
|
@@ -160,13 +160,13 @@ file. You can overide this or do much more fancy things. This is covered
|
|
160
160
|
in a different file. We could use this filter like this:
|
161
161
|
|
162
162
|
```ruby
|
163
|
+
output "compiled"
|
164
|
+
|
163
165
|
input "source" do
|
164
166
|
match "**/*.coffee" do
|
165
167
|
filter CoffeeScript
|
166
168
|
end
|
167
169
|
end
|
168
|
-
|
169
|
-
output "compiled"
|
170
170
|
```
|
171
171
|
|
172
172
|
Now this filter doesn't do anything at the moment besides copy the
|
@@ -205,7 +205,7 @@ require "coffee-script"
|
|
205
205
|
|
206
206
|
class CoffeeScriptFilter < Rake::Pipeline::Filter
|
207
207
|
def initialize(&block)
|
208
|
-
&block ||= proc { |input| input.path.gsub(/\.coffee
|
208
|
+
&block ||= proc { |input| input.path.gsub(/\.coffee/, ".js")
|
209
209
|
super(&block)
|
210
210
|
end
|
211
211
|
|
@@ -220,6 +220,8 @@ end
|
|
220
220
|
Let's take a fresh look at the `Assetfile` now.
|
221
221
|
|
222
222
|
```ruby
|
223
|
+
output "compiled"
|
224
|
+
|
223
225
|
input "source" do
|
224
226
|
match "javascript/**/*.coffee" do
|
225
227
|
# Compile all .coffee files into.js
|
@@ -239,8 +241,6 @@ input "source" do
|
|
239
241
|
copy
|
240
242
|
end
|
241
243
|
end
|
242
|
-
|
243
|
-
output "compiled"
|
244
244
|
```
|
245
245
|
|
246
246
|
Calling the filter without a block uses the default block in the filter.
|
@@ -10,6 +10,7 @@ require "rake-pipeline/reject_matcher"
|
|
10
10
|
require "rake-pipeline/sorted_pipeline"
|
11
11
|
require "rake-pipeline/error"
|
12
12
|
require "rake-pipeline/project"
|
13
|
+
require "rake-pipeline/cli"
|
13
14
|
require "rake-pipeline/graph"
|
14
15
|
|
15
16
|
if defined?(Rails::Railtie)
|
@@ -118,8 +119,6 @@ module Rake
|
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
121
|
-
ALLOWED_HOOKS = [:before_pipeline, :before_filter, :before_task, :after_task, :after_filter, :after_pipeline, :filters_ready, :rake_tasks_ready]
|
122
|
-
|
123
122
|
# @return [Hash[String, String]] the directory paths for the input files
|
124
123
|
# and their matching globs.
|
125
124
|
attr_accessor :inputs
|
@@ -147,9 +146,6 @@ module Rake
|
|
147
146
|
# @return [Project] the Project that created this pipeline
|
148
147
|
attr_accessor :project
|
149
148
|
|
150
|
-
attr_accessor :before_invoke
|
151
|
-
attr_accessor :after_invoke
|
152
|
-
|
153
149
|
# @param [Hash] options
|
154
150
|
# @option options [Hash] :inputs
|
155
151
|
# set the pipeline's {#inputs}.
|
@@ -212,23 +208,6 @@ module Rake
|
|
212
208
|
self
|
213
209
|
end
|
214
210
|
|
215
|
-
def call_hook(hook, *args)
|
216
|
-
if self.hooks[hook].respond_to? :call
|
217
|
-
args = [self].concat(args)
|
218
|
-
self.hooks[hook].call(*args)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
def register_invocation_hook(name, hook=nil, &block)
|
223
|
-
return unless ALLOWED_HOOKS.include? name
|
224
|
-
self.hooks ||= {}
|
225
|
-
self.hooks[name] = hook || block
|
226
|
-
end
|
227
|
-
|
228
|
-
def hooks
|
229
|
-
@hooks ||= {}
|
230
|
-
end
|
231
|
-
|
232
211
|
# Copy the current pipeline's attributes over.
|
233
212
|
#
|
234
213
|
# @param [Class] target_class the class to create a new
|
@@ -346,32 +325,8 @@ module Rake
|
|
346
325
|
|
347
326
|
setup
|
348
327
|
|
349
|
-
|
350
|
-
filters.each do |filter|
|
351
|
-
invoke_filter_tasks(filter)
|
352
|
-
end
|
353
|
-
self.call_hook(:after_pipeline)
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def invoke_filter_tasks(filter)
|
358
|
-
if filter.respond_to? :filters
|
359
|
-
filter.filters.each do |filter|
|
360
|
-
invoke_tasks(filter)
|
361
|
-
end
|
362
|
-
else
|
363
|
-
invoke_tasks(filter)
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
def invoke_tasks(filter)
|
368
|
-
self.call_hook :before_filter, filter
|
369
|
-
filter.rake_tasks.each do |task|
|
370
|
-
self.call_hook(:before_task, task)
|
371
|
-
task.invoke
|
372
|
-
self.call_hook(:after_task, task)
|
328
|
+
@rake_tasks.each { |task| task.invoke }
|
373
329
|
end
|
374
|
-
self.call_hook :after_filter, filter
|
375
330
|
end
|
376
331
|
|
377
332
|
# Set up the filters and generate rake tasks. In general, this method
|
@@ -381,9 +336,7 @@ module Rake
|
|
381
336
|
# @api private
|
382
337
|
def setup
|
383
338
|
setup_filters
|
384
|
-
call_hook :filters_ready
|
385
339
|
generate_rake_tasks
|
386
|
-
call_hook :rake_tasks_ready
|
387
340
|
record_input_files
|
388
341
|
end
|
389
342
|
|
@@ -23,16 +23,13 @@ module Rake
|
|
23
23
|
# +BINARY+ if they are declared as processing binary data.
|
24
24
|
attr_accessor :encoding
|
25
25
|
|
26
|
-
attr_accessor :original_inputs
|
27
|
-
|
28
26
|
# Create a new {FileWrapper}, passing in optional root, path, and
|
29
27
|
# encoding. Any of the parameters can be ommitted and supplied later.
|
30
28
|
#
|
31
29
|
# @return [void]
|
32
|
-
def initialize(root=nil, path=nil, encoding="UTF-8"
|
30
|
+
def initialize(root=nil, path=nil, encoding="UTF-8")
|
33
31
|
@root, @path, @encoding = root, path, encoding
|
34
32
|
@created_file = nil
|
35
|
-
@original_inputs = original_inputs
|
36
33
|
end
|
37
34
|
|
38
35
|
# Create a new {FileWrapper FileWrapper} with the same root and
|
@@ -42,11 +39,7 @@ module Rake
|
|
42
39
|
# @param [String] encoding the encoding for the new object
|
43
40
|
# @return [FileWrapper]
|
44
41
|
def with_encoding(encoding)
|
45
|
-
self.class.new(@root, @path, encoding
|
46
|
-
end
|
47
|
-
|
48
|
-
def original_inputs
|
49
|
-
@original_inputs ||= Set.new([self])
|
42
|
+
self.class.new(@root, @path, encoding)
|
50
43
|
end
|
51
44
|
|
52
45
|
# A {FileWrapper} is equal to another {FileWrapper} for hashing purposes
|
@@ -235,28 +235,10 @@ module Rake
|
|
235
235
|
|
236
236
|
def output_wrappers(input)
|
237
237
|
output_paths(input).map do |path|
|
238
|
-
|
239
|
-
collected_wrappers[path].tap do |wrapper|
|
240
|
-
original_inputs =
|
241
|
-
if input.original_inputs.any?
|
242
|
-
input.original_inputs
|
243
|
-
else
|
244
|
-
[input]
|
245
|
-
end
|
246
|
-
wrapper.original_inputs.merge original_inputs
|
247
|
-
end
|
248
|
-
else
|
249
|
-
wrapper = file_wrapper_class.new(output_root, path, encoding,
|
250
|
-
input.original_inputs)
|
251
|
-
collected_wrappers[path] = wrapper
|
252
|
-
end
|
238
|
+
file_wrapper_class.new(output_root, path, encoding)
|
253
239
|
end
|
254
240
|
end
|
255
241
|
|
256
|
-
def collected_wrappers
|
257
|
-
@collected_wrappers ||= {}
|
258
|
-
end
|
259
|
-
|
260
242
|
def output_paths(input)
|
261
243
|
args = [ input.path ]
|
262
244
|
args << input if output_name_generator.arity == 2
|
@@ -133,6 +133,7 @@ module Rake
|
|
133
133
|
|
134
134
|
# Remove the project's temporary and output files.
|
135
135
|
def clean
|
136
|
+
last_manifest.clear
|
136
137
|
files_to_clean.each { |file| FileUtils.rm_rf(file) }
|
137
138
|
end
|
138
139
|
|
@@ -277,7 +278,7 @@ module Rake
|
|
277
278
|
end
|
278
279
|
|
279
280
|
def dirty?
|
280
|
-
assetfile_dirty? ||
|
281
|
+
assetfile_dirty? || files_deleted? || files_dirty?
|
281
282
|
end
|
282
283
|
|
283
284
|
def assetfile_dirty?
|
@@ -311,7 +312,7 @@ module Rake
|
|
311
312
|
end
|
312
313
|
|
313
314
|
def files_deleted?
|
314
|
-
|
315
|
+
last_manifest.files.each_key do |input_file|
|
315
316
|
return true if !File.exists?(input_file)
|
316
317
|
end
|
317
318
|
|
@@ -4,8 +4,8 @@ describe "ConcatFilter" do
|
|
4
4
|
|
5
5
|
let(:input_files) {
|
6
6
|
[
|
7
|
-
MemoryFileWrapper.new("/path/to/input", "javascripts/jquery.js", "UTF-8",
|
8
|
-
MemoryFileWrapper.new("/path/to/input", "javascripts/sproutcore.js", "UTF-8",
|
7
|
+
MemoryFileWrapper.new("/path/to/input", "javascripts/jquery.js", "UTF-8", "jQuery = {};"),
|
8
|
+
MemoryFileWrapper.new("/path/to/input", "javascripts/sproutcore.js", "UTF-8", "SC = {};")
|
9
9
|
]
|
10
10
|
}
|
11
11
|
|
@@ -17,7 +17,7 @@ describe "ConcatFilter" do
|
|
17
17
|
filter.output_root = "/path/to/output"
|
18
18
|
filter.input_files = input_files
|
19
19
|
|
20
|
-
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "application.js", "BINARY"
|
20
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "application.js", "BINARY")]
|
21
21
|
|
22
22
|
tasks = filter.generate_rake_tasks
|
23
23
|
tasks.each(&:invoke)
|
@@ -32,6 +32,6 @@ describe "ConcatFilter" do
|
|
32
32
|
filter.file_wrapper_class = MemoryFileWrapper
|
33
33
|
filter.output_root = "/path/to/output"
|
34
34
|
filter.input_files = input_files
|
35
|
-
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "app.js", "BINARY"
|
35
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "app.js", "BINARY")]
|
36
36
|
end
|
37
37
|
end
|