Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

allowing multiple --externs options to be passed #11

Merged
merged 1 commit into from

2 participants

@xiazek

As initializer takes hash, it was not possible to pass multiple attributes of the same kind.
I made it possible to pass an array of --extern (or other attributes). See comments of commit on Github.

@xiazek

Google closure allows to add multiple --externs options like below
"--externs library1.js --externs library2.js"

Till now constructor was receiving options as a hash which was not allowing to pass multiple attributes of the same kind ({:externs => "library1", :externs => "library2"}).

I made a changes allowing to pass an array of such attributes. For example:
{:externs => ["library1.js", "library2.js"]
which produces :

"--externs library1.js --externs library2.js"

as options

@jashkenas jashkenas merged commit 0243477 into from
@jashkenas
Owner

Looks good -- thanks.

@xiazek

at your services ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2011
  1. @xiazek
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.