Permalink
Browse files

Merge pull request #11 from xiazek/master

allowing multiple --externs options to be passed
  • Loading branch information...
2 parents 70b2ab0 + 7fb8f71 commit 024347738c682d68ca984bf87d5414a16cf7bf7f @jashkenas jashkenas committed May 25, 2011
Showing with 16 additions and 1 deletion.
  1. +7 −1 lib/closure/compiler.rb
  2. +9 −0 test/unit/test_closure_compiler.rb
View
8 lib/closure/compiler.rb
@@ -51,7 +51,13 @@ def compile(io)
# Serialize hash options to the command-line format.
def serialize_options(options)
- options.map {|k, v| ["--#{k}", v.to_s] }.flatten
+ options.map do |k, v|
+ if (v.is_a?(Array))
+ v.map {|v2| ["--#{k}", v2.to_s]}
+ else
+ ["--#{k}", v.to_s]
+ end
+ end.flatten
end
def command
View
9 test/unit/test_closure_compiler.rb
@@ -60,4 +60,13 @@ def test_permissions
assert File.executable?(COMPILER_JAR)
end
+ def test_serialize_options
+ assert_equal ["--externs", "library1.js", "--compilation_level", "ADVANCED_OPTIMIZATIONS"], Closure::Compiler.new.send(:serialize_options, 'externs' => 'library1.js', "compilation_level" => "ADVANCED_OPTIMIZATIONS")
+ end
+
+ def test_serialize_options_for_arrays
+ compiler = Closure::Compiler.new('externs' => ['library1.js', "library2.js"])
+ assert_equal ["--externs", "library1.js", "--externs", "library2.js"], compiler.send(:serialize_options, 'externs' => ['library1.js', "library2.js"])
+ end
+
end

0 comments on commit 0243477

Please sign in to comment.