Permalink
Browse files

Merge pull request #35 from renz45/master

Add requireAll support to minispade filter
  • Loading branch information...
2 parents 7272670 + 9b91cba commit e14e78ae70d0d25b1668c5273e80cd05a4ee52e6 @wycats committed Sep 6, 2012
Showing with 13 additions and 0 deletions.
  1. +1 −0 lib/rake-pipeline-web-filters/minispade_filter.rb
  2. +12 −0 spec/minispade_filter_spec.rb
@@ -45,6 +45,7 @@ def generate_output(inputs, output)
inputs.each do |input|
code = input.read
code.gsub!(%r{^\s*require\s*\(\s*}, 'minispade.require(') if @rewrite_requires
+ code.gsub!(%r{^\s*requireAll\s*\(\s*}, 'minispade.requireAll(') if @rewrite_requires
code = %["use strict";\n] + code if @use_strict
module_id = @module_id_generator.call(input)
@@ -64,4 +64,16 @@ def make_filter(input_file, *args)
output_file.body.should ==
"minispade.register('/path/to/input/foo.js', function() {minispade.require('octopus');\n});"
end
+
+ it "rewrites requireAll if asked" do
+ filter = make_filter(input_file("requireAll('octopus');"), :rewrite_requires => true)
+ output_file.body.should ==
+ "minispade.register('/path/to/input/foo.js', function() {minispade.requireAll('octopus');\n});"
+ end
+
+ it "rewrites requireAll if asked even spaces wrap tokens in the require statement" do
+ filter = make_filter(input_file("requireAll ( 'octopus');"), :rewrite_requires => true)
+ output_file.body.should ==
+ "minispade.register('/path/to/input/foo.js', function() {minispade.requireAll('octopus');\n});"
+ end
end

0 comments on commit e14e78a

Please sign in to comment.