benoit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.rspec-turnip +1 -0
- data/.ruby-version +1 -0
- data/Assetfile +44 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +110 -0
- data/Rakefile +9 -0
- data/benoit.gemspec +50 -0
- data/bin/benoit +121 -0
- data/bin/bundle-development +1 -0
- data/bin/bundle-sandbox +1 -0
- data/lib/benoit.rb +36 -0
- data/lib/benoit/cadenza.rb +11 -0
- data/lib/benoit/cadenza/output_filters.rb +21 -0
- data/lib/benoit/cleaner.rb +10 -0
- data/lib/benoit/compiler_error.rb +49 -0
- data/lib/benoit/configuration.rb +24 -0
- data/lib/benoit/current_site.rb +12 -0
- data/lib/benoit/file_wrapper_extensions.rb +13 -0
- data/lib/benoit/filters.rb +15 -0
- data/lib/benoit/filters/base_filter.rb +44 -0
- data/lib/benoit/filters/blacklist_filter.rb +18 -0
- data/lib/benoit/filters/cadenza_filter.rb +75 -0
- data/lib/benoit/filters/content_page_filter.rb +45 -0
- data/lib/benoit/filters/markdown_filter.rb +19 -0
- data/lib/benoit/filters/metadata_cleaner.rb +30 -0
- data/lib/benoit/filters/move_to_root_filter.rb +22 -0
- data/lib/benoit/filters/pagination_filter.rb +23 -0
- data/lib/benoit/filters/pass_thru_filter.rb +22 -0
- data/lib/benoit/filters/sass_filter.rb +74 -0
- data/lib/benoit/filters/set_metadata_filter.rb +15 -0
- data/lib/benoit/logger.rb +69 -0
- data/lib/benoit/page.rb +88 -0
- data/lib/benoit/page_metadata.rb +8 -0
- data/lib/benoit/page_metadata/container.rb +74 -0
- data/lib/benoit/page_metadata/json_converter.rb +28 -0
- data/lib/benoit/page_metadata/parser.rb +38 -0
- data/lib/benoit/page_metadata/store.rb +75 -0
- data/lib/benoit/pipeline.rb +1 -0
- data/lib/benoit/pipeline/dsl_extensions.rb +8 -0
- data/lib/benoit/pipeline/pagination_matcher.rb +53 -0
- data/lib/benoit/pipeline_project.rb +81 -0
- data/lib/benoit/site_context.rb +123 -0
- data/lib/benoit/utils/finds_layouts_for_template.rb +77 -0
- data/lib/benoit/utils/normalizes_path_to_template.rb +43 -0
- data/lib/benoit/utils/paginated_list.rb +102 -0
- data/lib/benoit/version.rb +3 -0
- data/lib/build_notifiers/file_built_notifier.rb +20 -0
- data/lib/build_notifiers/progress_notifier.rb +57 -0
- data/lib/cli.rb +39 -0
- data/spec/.rbenv-gemsets +1 -0
- data/spec/Gemfile +9 -0
- data/spec/Gemfile.lock +57 -0
- data/spec/bin/autospec +16 -0
- data/spec/bin/cucumber +16 -0
- data/spec/bin/htmldiff +16 -0
- data/spec/bin/ldiff +16 -0
- data/spec/bin/rspec +16 -0
- data/spec/features/build_command.feature +46 -0
- data/spec/features/frontmatter_metadata.feature +99 -0
- data/spec/features/javascript_files.feature +35 -0
- data/spec/features/output_filters.feature +20 -0
- data/spec/features/page_layouts.feature +72 -0
- data/spec/features/pagination.feature +58 -0
- data/spec/features/sass_files.feature +30 -0
- data/spec/features/version.feature +5 -0
- data/spec/lib/filters/base_filter_spec.rb +141 -0
- data/spec/lib/filters/markdown_filter_spec.rb +65 -0
- data/spec/lib/filters/sass_filter_spec.rb +73 -0
- data/spec/lib/metadata_json_converter_spec.rb +65 -0
- data/spec/lib/metadata_store_spec.rb +148 -0
- data/spec/lib/page_spec.rb +19 -0
- data/spec/lib/site_context_spec.rb +106 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/steps/output_file_steps.rb +45 -0
- data/spec/steps/run_steps.rb +71 -0
- data/spec/steps/staticly_steps.rb +194 -0
- data/spec/support/aruba/rspec.rb +66 -0
- data/spec/support/files/img.png +0 -0
- data/spec/support/files/input.css.scss +7 -0
- data/spec/support/files/input.scss +7 -0
- data/spec/support/spec_helpers/file_helpers.rb +8 -0
- data/spec/support/spec_helpers/memory_file_wrapper.rb +43 -0
- data/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/spec/turnip_helper.rb +19 -0
- data/vendor/frontmatter/frontmatter.gemspec +24 -0
- data/vendor/frontmatter/lib/frontmatter.rb +92 -0
- data/vendor/frontmatter/lib/frontmatter/version.rb +3 -0
- data/vendor/rake-pipeline/.gitignore +18 -0
- data/vendor/rake-pipeline/.rspec +1 -0
- data/vendor/rake-pipeline/.travis.yml +12 -0
- data/vendor/rake-pipeline/.yardopts +2 -0
- data/vendor/rake-pipeline/GETTING_STARTED.md +268 -0
- data/vendor/rake-pipeline/Gemfile +14 -0
- data/vendor/rake-pipeline/LICENSE +20 -0
- data/vendor/rake-pipeline/README.markdown +11 -0
- data/vendor/rake-pipeline/README.yard +178 -0
- data/vendor/rake-pipeline/Rakefile +21 -0
- data/vendor/rake-pipeline/bin/rakep +4 -0
- data/vendor/rake-pipeline/examples/copying_files.md +12 -0
- data/vendor/rake-pipeline/examples/minifying_files.md +37 -0
- data/vendor/rake-pipeline/examples/modifying_pipelines.md +67 -0
- data/vendor/rake-pipeline/examples/multiple_pipelines.md +77 -0
- data/vendor/rake-pipeline/lib/generators/rake/pipeline/install/install_generator.rb +70 -0
- data/vendor/rake-pipeline/lib/rake-pipeline.rb +509 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/cli.rb +57 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl.rb +9 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/pipeline_dsl.rb +246 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/project_dsl.rb +108 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dynamic_file_task.rb +194 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/error.rb +17 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/file_wrapper.rb +195 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filter.rb +267 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters.rb +4 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/concat_filter.rb +63 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/gsub_filter.rb +56 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/ordering_concat_filter.rb +38 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/pipeline_finalizing_filter.rb +21 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/graph.rb +178 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest.rb +82 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest_entry.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/matcher.rb +141 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/middleware.rb +73 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/precompile.rake +8 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/project.rb +338 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/rails_plugin.rb +10 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/railtie.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/reject_matcher.rb +29 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/server.rb +15 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/sorted_pipeline.rb +19 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/version.rb +6 -0
- data/vendor/rake-pipeline/rails/init.rb +2 -0
- data/vendor/rake-pipeline/rake-pipeline.gemspec +24 -0
- data/vendor/rake-pipeline/spec/cli_spec.rb +73 -0
- data/vendor/rake-pipeline/spec/concat_filter_spec.rb +37 -0
- data/vendor/rake-pipeline/spec/dsl/pipeline_dsl_spec.rb +165 -0
- data/vendor/rake-pipeline/spec/dsl/project_dsl_spec.rb +41 -0
- data/vendor/rake-pipeline/spec/dynamic_file_task_spec.rb +119 -0
- data/vendor/rake-pipeline/spec/encoding_spec.rb +106 -0
- data/vendor/rake-pipeline/spec/file_wrapper_spec.rb +132 -0
- data/vendor/rake-pipeline/spec/filter_spec.rb +367 -0
- data/vendor/rake-pipeline/spec/graph_spec.rb +56 -0
- data/vendor/rake-pipeline/spec/gsub_filter_spec.rb +87 -0
- data/vendor/rake-pipeline/spec/manifest_entry_spec.rb +46 -0
- data/vendor/rake-pipeline/spec/manifest_spec.rb +67 -0
- data/vendor/rake-pipeline/spec/matcher_spec.rb +141 -0
- data/vendor/rake-pipeline/spec/middleware_spec.rb +199 -0
- data/vendor/rake-pipeline/spec/ordering_concat_filter_spec.rb +42 -0
- data/vendor/rake-pipeline/spec/pipeline_spec.rb +232 -0
- data/vendor/rake-pipeline/spec/project_spec.rb +295 -0
- data/vendor/rake-pipeline/spec/rake_acceptance_spec.rb +720 -0
- data/vendor/rake-pipeline/spec/rake_tasks_spec.rb +21 -0
- data/vendor/rake-pipeline/spec/reject_matcher_spec.rb +31 -0
- data/vendor/rake-pipeline/spec/sorted_pipeline_spec.rb +27 -0
- data/vendor/rake-pipeline/spec/spec_helper.rb +38 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/file_utils.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/filters.rb +37 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/input_helpers.rb +23 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_file_wrapper.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/vendor/rake-pipeline/tools/perfs +101 -0
- metadata +497 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
describe "Rake::Pipeline::Graph" do
|
2
|
+
Graph = Rake::Pipeline::Graph
|
3
|
+
Node = Rake::Pipeline::Graph::Node
|
4
|
+
|
5
|
+
before do
|
6
|
+
@graph = Graph.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "has nodes" do
|
10
|
+
@graph.nodes.should == []
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can add nodes" do
|
14
|
+
@graph.add("foo")
|
15
|
+
@graph["foo"].should == Node.new("foo")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can link nodes" do
|
19
|
+
@graph.add("foo")
|
20
|
+
@graph.add("bar")
|
21
|
+
@graph.nodes.should == [Node.new("foo"), Node.new("bar")]
|
22
|
+
@graph.link("foo", "bar")
|
23
|
+
@graph["foo"].children.map(&:name).should == ["bar"]
|
24
|
+
@graph["bar"].parents.map(&:name).should == ["foo"]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can unlink nodes" do
|
28
|
+
@graph.add("foo")
|
29
|
+
@graph.add("bar")
|
30
|
+
@graph.link("foo", "bar")
|
31
|
+
@graph.unlink("foo", "bar")
|
32
|
+
@graph["foo"].children.should == Set[]
|
33
|
+
@graph["bar"].parents.should == Set[]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can remove nodes" do
|
37
|
+
@graph.add("foo")
|
38
|
+
@graph.add("bar")
|
39
|
+
@graph.nodes.should == [Node.new("foo"), Node.new("bar")]
|
40
|
+
@graph.link("foo", "bar")
|
41
|
+
@graph.remove("foo")
|
42
|
+
@graph.nodes.should == [Node.new("bar")]
|
43
|
+
@graph["bar"].children.should == Set[]
|
44
|
+
@graph["bar"].parents.should == Set[]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "can add metadata to nodes" do
|
48
|
+
@graph.add("foo", :meta => 1)
|
49
|
+
@graph.add("bar")
|
50
|
+
@graph["bar"].metadata[:meta] = 2
|
51
|
+
|
52
|
+
@graph["foo"].metadata.should == { :meta => 1 }
|
53
|
+
@graph["bar"].metadata.should == { :meta => 2 }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
describe "GsubFilter" do
|
2
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
3
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
4
|
+
|
5
|
+
let(:input_files) {
|
6
|
+
[
|
7
|
+
MemoryFileWrapper.new("/path/to/input", "ember.js", "UTF-8", [], "Ember.assert"),
|
8
|
+
]
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:rake_application) { Rake::Application.new }
|
12
|
+
|
13
|
+
it "generates output" do
|
14
|
+
filter = Rake::Pipeline::GsubFilter.new "Ember.assert", "foo"
|
15
|
+
filter.rake_application = rake_application
|
16
|
+
|
17
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
18
|
+
filter.manifest = MemoryManifest.new
|
19
|
+
filter.last_manifest = MemoryManifest.new
|
20
|
+
|
21
|
+
filter.output_root = "/path/to/output"
|
22
|
+
filter.input_files = input_files
|
23
|
+
|
24
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8", [])]
|
25
|
+
|
26
|
+
|
27
|
+
tasks = filter.generate_rake_tasks
|
28
|
+
tasks.each(&:invoke)
|
29
|
+
|
30
|
+
file = MemoryFileWrapper.files["/path/to/output/ember.js"]
|
31
|
+
file.body.should == "foo"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "accepts a block to use with gsub" do
|
35
|
+
filter = Rake::Pipeline::GsubFilter.new "Ember.assert" do
|
36
|
+
"foo"
|
37
|
+
end
|
38
|
+
|
39
|
+
filter.rake_application = rake_application
|
40
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
41
|
+
filter.manifest = MemoryManifest.new
|
42
|
+
filter.last_manifest = MemoryManifest.new
|
43
|
+
|
44
|
+
filter.output_root = "/path/to/output"
|
45
|
+
filter.input_files = input_files
|
46
|
+
|
47
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8", [])]
|
48
|
+
|
49
|
+
tasks = filter.generate_rake_tasks
|
50
|
+
tasks.each(&:invoke)
|
51
|
+
|
52
|
+
file = MemoryFileWrapper.files["/path/to/output/ember.js"]
|
53
|
+
file.body.should == "foo"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be able to access global match variables" do
|
57
|
+
filter = Rake::Pipeline::GsubFilter.new /Ember\.(.+)/ do |match, word|
|
58
|
+
word.should == "assert"
|
59
|
+
"Ember.#{word}Strongly"
|
60
|
+
end
|
61
|
+
|
62
|
+
filter.rake_application = rake_application
|
63
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
64
|
+
filter.manifest = MemoryManifest.new
|
65
|
+
filter.last_manifest = MemoryManifest.new
|
66
|
+
|
67
|
+
filter.output_root = "/path/to/output"
|
68
|
+
filter.input_files = input_files
|
69
|
+
|
70
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8", [])]
|
71
|
+
|
72
|
+
tasks = filter.generate_rake_tasks
|
73
|
+
tasks.each(&:invoke)
|
74
|
+
|
75
|
+
file = MemoryFileWrapper.files["/path/to/output/ember.js"]
|
76
|
+
file.body.should == "Ember.assertStrongly"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "use the input name for output" do
|
80
|
+
filter = Rake::Pipeline::GsubFilter.new
|
81
|
+
filter.rake_application = rake_application
|
82
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
83
|
+
filter.output_root = "/path/to/output"
|
84
|
+
filter.input_files = input_files
|
85
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8", [])]
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rake::Pipeline::ManifestEntry do
|
4
|
+
let(:hash) do
|
5
|
+
{
|
6
|
+
"deps" => {
|
7
|
+
"file.h" => 100,
|
8
|
+
"other.h" => 100
|
9
|
+
},
|
10
|
+
"mtime" => 200
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
subject {
|
15
|
+
Rake::Pipeline::ManifestEntry.from_hash(hash)
|
16
|
+
}
|
17
|
+
|
18
|
+
describe "#from_hash" do
|
19
|
+
it "creates a new ManifestEntry from a hash" do
|
20
|
+
subject.should be_kind_of described_class
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should leave mtimes have integers" do
|
24
|
+
subject.mtime.should == 200
|
25
|
+
end
|
26
|
+
|
27
|
+
it "parses each time from the deps value into a Time" do
|
28
|
+
subject.deps.each do |file, mtime|
|
29
|
+
mtime.should == 100
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#as_json" do
|
35
|
+
it "returns a hash representation of the entry for converting to json" do
|
36
|
+
subject.as_json.should == {
|
37
|
+
:deps => {
|
38
|
+
"file.h" => 100,
|
39
|
+
"other.h" => 100
|
40
|
+
},
|
41
|
+
:mtime => 200
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rake::Pipeline::Manifest do
|
4
|
+
before do
|
5
|
+
# ensure all our date/time conversions happen in UTC.
|
6
|
+
ENV['TZ'] = 'UTC'
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:manifest_file) { "#{tmp}/manifest.json" }
|
10
|
+
|
11
|
+
let(:json) { <<-JSON }
|
12
|
+
{
|
13
|
+
"file.h": {
|
14
|
+
"deps": {
|
15
|
+
"other.h": "2000-01-01 00:00:00 +0000"
|
16
|
+
},
|
17
|
+
"mtime":"2000-01-01 00:00:00 +0000"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
JSON
|
21
|
+
|
22
|
+
let(:entries_hash) do
|
23
|
+
{
|
24
|
+
"file.h" => Rake::Pipeline::ManifestEntry.from_hash({
|
25
|
+
"deps" => {
|
26
|
+
"other.h" => "2000-01-01 00:00:00 +0000"
|
27
|
+
},
|
28
|
+
"mtime" => "2000-01-01 00:00:00 +0000"
|
29
|
+
})
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
subject do
|
34
|
+
Rake::Pipeline::Manifest.new(manifest_file)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#write_manifest" do
|
38
|
+
before do
|
39
|
+
subject.entries = entries_hash
|
40
|
+
rm_rf manifest_file
|
41
|
+
end
|
42
|
+
|
43
|
+
it "writes a manifest json file to disk" do
|
44
|
+
subject.write_manifest
|
45
|
+
|
46
|
+
File.exist?(manifest_file).should be_true
|
47
|
+
JSON.parse(File.read(manifest_file)).should == JSON.parse(json)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "writes nothing if it's empty" do
|
51
|
+
subject.entries = {}
|
52
|
+
subject.write_manifest
|
53
|
+
File.exist?(manifest_file).should be_false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#read_manifest" do
|
58
|
+
before do
|
59
|
+
File.open(manifest_file, 'w') { |f| f.puts json }
|
60
|
+
end
|
61
|
+
|
62
|
+
it "reads a manifest json file from disk" do
|
63
|
+
subject.read_manifest
|
64
|
+
subject.entries.should == entries_hash
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
describe "a matcher" do
|
2
|
+
sep = File::SEPARATOR
|
3
|
+
|
4
|
+
let(:project) { Rake::Pipeline::Project.new }
|
5
|
+
|
6
|
+
before do
|
7
|
+
@matcher = Rake::Pipeline::Matcher.new :project => project
|
8
|
+
|
9
|
+
@files = %w(jquery.js sproutcore.js sproutcore.css).map do |file|
|
10
|
+
file_wrapper(file)
|
11
|
+
end
|
12
|
+
|
13
|
+
@matcher.input_files = @files
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_wrapper(file, options={})
|
17
|
+
root = options[:root] || tmp
|
18
|
+
encoding = options[:encoding] || "UTF-8"
|
19
|
+
Rake::Pipeline::FileWrapper.new(root, file, encoding)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "accepts input files" do
|
23
|
+
@matcher.input_files.should == @files
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can access its glob" do
|
27
|
+
@matcher.glob = "*.js"
|
28
|
+
@matcher.glob.should == "*.js"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "knows about its containing pipeline" do
|
32
|
+
pipeline = Rake::Pipeline.new
|
33
|
+
pipeline.add_filter @matcher
|
34
|
+
@matcher.pipeline.should == pipeline
|
35
|
+
end
|
36
|
+
|
37
|
+
it "only processes files matching the matcher" do
|
38
|
+
@matcher.glob = "*.js"
|
39
|
+
@matcher.output_root = "tmp1"
|
40
|
+
|
41
|
+
concat = Rake::Pipeline::ConcatFilter.new
|
42
|
+
concat.output_name_generator = proc { |input| "app.js" }
|
43
|
+
@matcher.add_filter concat
|
44
|
+
|
45
|
+
@matcher.setup
|
46
|
+
|
47
|
+
concat.input_files.should == [
|
48
|
+
file_wrapper("jquery.js", :encoding => "BINARY"),
|
49
|
+
file_wrapper("sproutcore.js", :encoding => "BINARY")
|
50
|
+
]
|
51
|
+
|
52
|
+
@matcher.output_files.should == [
|
53
|
+
file_wrapper("app.js", :root => File.join(tmp, "tmp1")),
|
54
|
+
file_wrapper("sproutcore.css")
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
def should_match_glob(glob, files)
|
59
|
+
@matcher.glob = glob
|
60
|
+
@matcher.output_root = "tmp1"
|
61
|
+
|
62
|
+
concat = Rake::Pipeline::ConcatFilter.new
|
63
|
+
concat.output_name_generator = proc { |input| input }
|
64
|
+
@matcher.add_filter concat
|
65
|
+
|
66
|
+
@matcher.setup
|
67
|
+
|
68
|
+
@matcher.output_files.should == files
|
69
|
+
end
|
70
|
+
|
71
|
+
it "understands */* style globs" do
|
72
|
+
@matcher.input_files << file_wrapper("javascripts/backbone.js")
|
73
|
+
@matcher.input_files << file_wrapper("something/javascripts/backbone.js")
|
74
|
+
|
75
|
+
should_match_glob "*/*.js", [
|
76
|
+
file_wrapper("javascripts/backbone.js", :encoding => "BINARY", :root => File.join(tmp, "tmp1")),
|
77
|
+
file_wrapper("jquery.js"),
|
78
|
+
file_wrapper("sproutcore.js"),
|
79
|
+
file_wrapper("sproutcore.css"),
|
80
|
+
file_wrapper("something/javascripts/backbone.js")
|
81
|
+
]
|
82
|
+
|
83
|
+
should_match_glob "proutcore*.js", [
|
84
|
+
file_wrapper("jquery.js"),
|
85
|
+
file_wrapper("sproutcore.js"),
|
86
|
+
file_wrapper("sproutcore.css"),
|
87
|
+
file_wrapper("javascripts/backbone.js"),
|
88
|
+
file_wrapper("something/javascripts/backbone.js")
|
89
|
+
]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "understands **/* style globs" do
|
93
|
+
@matcher.input_files << file_wrapper("javascripts/backbone.js")
|
94
|
+
|
95
|
+
output_root = File.join(tmp, "tmp1")
|
96
|
+
|
97
|
+
should_match_glob "**/*.js", [
|
98
|
+
file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
|
99
|
+
file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
|
100
|
+
file_wrapper("javascripts/backbone.js", :encoding => "BINARY", :root => output_root),
|
101
|
+
file_wrapper("sproutcore.css")
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "understands {foo,bar}/* style globs" do
|
106
|
+
@matcher.input_files << file_wrapper("javascripts/backbone.js")
|
107
|
+
|
108
|
+
output_root = File.join(tmp, "tmp1")
|
109
|
+
|
110
|
+
should_match_glob "{jquery,sproutcore}.js", [
|
111
|
+
file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
|
112
|
+
file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
|
113
|
+
file_wrapper("sproutcore.css"),
|
114
|
+
file_wrapper("javascripts/backbone.js")
|
115
|
+
]
|
116
|
+
end
|
117
|
+
|
118
|
+
it "accepts Regexp as glob" do
|
119
|
+
regexp = /application\.erb/
|
120
|
+
@matcher.glob = regexp
|
121
|
+
|
122
|
+
@matcher.glob.should == regexp
|
123
|
+
end
|
124
|
+
|
125
|
+
it "underestands regexp globs" do
|
126
|
+
regexp = /^*(?<!\.coffee)\.js$/i
|
127
|
+
|
128
|
+
@matcher.input_files << file_wrapper("application.coffee.js")
|
129
|
+
@matcher.input_files << file_wrapper("application.engine.js")
|
130
|
+
|
131
|
+
output_root = File.join(tmp, "tmp1")
|
132
|
+
|
133
|
+
should_match_glob regexp, [
|
134
|
+
file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
|
135
|
+
file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
|
136
|
+
file_wrapper("application.engine.js", :encoding => "BINARY", :root => output_root),
|
137
|
+
file_wrapper("sproutcore.css"),
|
138
|
+
file_wrapper("application.coffee.js")
|
139
|
+
]
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require "rake-pipeline/middleware"
|
2
|
+
require "rake-pipeline/filters"
|
3
|
+
require "rack/test"
|
4
|
+
|
5
|
+
describe "Rake::Pipeline Middleware" do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
inputs = {
|
9
|
+
"app/javascripts/jquery.js" => "var jQuery = {};\n",
|
10
|
+
|
11
|
+
"app/javascripts/sproutcore.js" => <<-HERE.gsub(/^ {6}/, ''),
|
12
|
+
var SC = {};
|
13
|
+
assert(SC);
|
14
|
+
SC.hi = function() { console.log("hi"); };
|
15
|
+
HERE
|
16
|
+
|
17
|
+
"app/index.html" => "<html>HI</html>",
|
18
|
+
"app/javascripts/index.html" => "<html>JAVASCRIPT</html>",
|
19
|
+
"app/empty_dir" => nil
|
20
|
+
}
|
21
|
+
|
22
|
+
expected_output = <<-HERE.gsub(/^ {4}/, '')
|
23
|
+
var jQuery = {};
|
24
|
+
var SC = {};
|
25
|
+
|
26
|
+
SC.hi = function() { console.log("hi"); };
|
27
|
+
HERE
|
28
|
+
|
29
|
+
assetfile_source = <<-HERE.gsub(/^ {4}/, '')
|
30
|
+
require "#{tmp}/../support/spec_helpers/filters"
|
31
|
+
output "public"
|
32
|
+
|
33
|
+
map "/dynamic-request.js" do
|
34
|
+
[200, { "Content-Type" => "text/plain" }, ["I am dynamic!"]]
|
35
|
+
end
|
36
|
+
|
37
|
+
input "#{tmp}", "app/**/*" do
|
38
|
+
match "*.js" do
|
39
|
+
concat "javascripts/application.js"
|
40
|
+
filter(Rake::Pipeline::SpecHelpers::Filters::StripAssertsFilter) { |input| input }
|
41
|
+
end
|
42
|
+
|
43
|
+
# copy the rest
|
44
|
+
concat { |input| input.sub(%r|^app/|, '') }
|
45
|
+
end
|
46
|
+
HERE
|
47
|
+
|
48
|
+
modified_assetfile_source = <<-HERE.gsub(/^ {4}/, '')
|
49
|
+
require "#{tmp}/../support/spec_helpers/filters"
|
50
|
+
output "public"
|
51
|
+
|
52
|
+
input "#{tmp}", "app/**/*" do
|
53
|
+
match "*.js" do
|
54
|
+
concat { "javascripts/app.js" }
|
55
|
+
filter(Rake::Pipeline::SpecHelpers::Filters::StripAssertsFilter) { |input| input }
|
56
|
+
end
|
57
|
+
|
58
|
+
# copy the rest
|
59
|
+
concat { |input| input.sub(%r|^app/|, '') }
|
60
|
+
end
|
61
|
+
HERE
|
62
|
+
|
63
|
+
app = middleware = nil
|
64
|
+
|
65
|
+
let(:app) { middleware }
|
66
|
+
|
67
|
+
before do
|
68
|
+
assetfile_path = File.join(tmp, "Assetfile")
|
69
|
+
File.open(assetfile_path, "w") { |file| file.write(assetfile_source) }
|
70
|
+
|
71
|
+
project = Rake::Pipeline::Project.new assetfile_path
|
72
|
+
|
73
|
+
app = lambda { |env| [404, {}, ['not found']] }
|
74
|
+
middleware = Rake::Pipeline::Middleware.new(app, project)
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "dynamic requests" do
|
78
|
+
it "returns the value from the given block for paths that have been mapped" do
|
79
|
+
get "/dynamic-request.js"
|
80
|
+
|
81
|
+
last_response.should be_ok
|
82
|
+
last_response.headers["Content-Type"].should == "text/plain"
|
83
|
+
last_response.body.should == "I am dynamic!"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "static requests" do
|
88
|
+
before do
|
89
|
+
inputs.each do |name, string|
|
90
|
+
path = File.join(tmp, name)
|
91
|
+
if string
|
92
|
+
mkdir_p File.dirname(path)
|
93
|
+
File.open(path, "w") { |file| file.write(string) }
|
94
|
+
else
|
95
|
+
mkdir_p path
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
get "/javascripts/application.js"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "returns files relative to the output directory" do
|
103
|
+
last_response.should be_ok
|
104
|
+
|
105
|
+
last_response.body.should == expected_output
|
106
|
+
last_response.headers["Content-Type"].should == "application/javascript"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "updates the output when files change" do
|
110
|
+
age_existing_files
|
111
|
+
|
112
|
+
File.open(File.join(tmp, "app/javascripts/jquery.js"), "w") do |file|
|
113
|
+
file.write "var jQuery = {};\njQuery.trim = function() {};\n"
|
114
|
+
end
|
115
|
+
|
116
|
+
expected = <<-HERE.gsub(/^ {6}/, '')
|
117
|
+
var jQuery = {};
|
118
|
+
jQuery.trim = function() {};
|
119
|
+
var SC = {};
|
120
|
+
|
121
|
+
SC.hi = function() { console.log("hi"); };
|
122
|
+
HERE
|
123
|
+
|
124
|
+
get "/javascripts/application.js"
|
125
|
+
|
126
|
+
last_response.body.should == expected
|
127
|
+
last_response.headers["Content-Type"].should == "application/javascript"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "updates the output when new files are added" do
|
131
|
+
age_existing_files
|
132
|
+
|
133
|
+
File.open(File.join(tmp, "app/javascripts/history.js"), "w") do |file|
|
134
|
+
file.write "var History = {};\n"
|
135
|
+
end
|
136
|
+
|
137
|
+
expected = <<-HERE.gsub(/^ {6}/, '')
|
138
|
+
var History = {};
|
139
|
+
var jQuery = {};
|
140
|
+
var SC = {};
|
141
|
+
|
142
|
+
SC.hi = function() { console.log("hi"); };
|
143
|
+
HERE
|
144
|
+
|
145
|
+
get "/javascripts/application.js"
|
146
|
+
|
147
|
+
last_response.body.should == expected
|
148
|
+
last_response.headers["Content-Type"].should == "application/javascript"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "returns index.html for directories" do
|
152
|
+
get "/"
|
153
|
+
|
154
|
+
last_response.body.should == "<html>HI</html>"
|
155
|
+
last_response.headers["Content-Type"].should == "text/html"
|
156
|
+
|
157
|
+
get "/javascripts"
|
158
|
+
|
159
|
+
last_response.body.should == "<html>JAVASCRIPT</html>"
|
160
|
+
last_response.headers["Content-Type"].should == "text/html"
|
161
|
+
end
|
162
|
+
|
163
|
+
it "ignores directories without index.html" do
|
164
|
+
get "/empty_dir"
|
165
|
+
|
166
|
+
last_response.body.should == "not found"
|
167
|
+
last_response.status.should == 404
|
168
|
+
end
|
169
|
+
|
170
|
+
it "falls back to the app" do
|
171
|
+
get "/zomg.notfound"
|
172
|
+
|
173
|
+
last_response.body.should == "not found"
|
174
|
+
last_response.status.should == 404
|
175
|
+
end
|
176
|
+
|
177
|
+
it "recreates the pipeline when the Assetfile changes" do
|
178
|
+
get "/javascripts/app.js"
|
179
|
+
last_response.body.should == "not found"
|
180
|
+
last_response.status.should == 404
|
181
|
+
|
182
|
+
File.open(File.join(tmp, "Assetfile"), "w") do |file|
|
183
|
+
file.write(modified_assetfile_source)
|
184
|
+
end
|
185
|
+
|
186
|
+
expected = <<-HERE.gsub(/^ {6}/, '')
|
187
|
+
var jQuery = {};
|
188
|
+
var SC = {};
|
189
|
+
|
190
|
+
SC.hi = function() { console.log("hi"); };
|
191
|
+
HERE
|
192
|
+
|
193
|
+
get "/javascripts/app.js"
|
194
|
+
|
195
|
+
last_response.body.should == expected
|
196
|
+
last_response.headers["Content-Type"].should == "application/javascript"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|