<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -29,6 +29,9 @@ spec = Oyster.spec do
   flag    :base62,          :default =&gt; false,
   :desc =&gt; 'Encode the program using base 62'
   
+  array   :protect,         :default =&gt; [],
+  :desc =&gt; 'List of variable names to protect from compression when using --shrink-vars'
+  
   notes &lt;&lt;-EOS
   This program is not a JavaScript parser, and rewrites your files using regular
   expressions. Be sure to include semicolons and braces everywhere they are required
@@ -80,6 +83,9 @@ code = inputs.empty? ?
     $stdin.read :
     inputs.map { |f| File.read(f) }.join(&quot;\n&quot;)
 
-$stdout.puts Packr.pack(code, :shrink_vars =&gt; !!opts[:'shrink-vars'],
-    :private =&gt; !!opts[:private], :base62 =&gt; !!opts[:base62])
+$stdout.puts Packr.pack(code,
+  :shrink_vars =&gt; !!opts[:'shrink-vars'],
+  :protect     =&gt; opts[:protect],
+  :private     =&gt; !!opts[:private],
+  :base62      =&gt; !!opts[:base62])
 </diff>
      <filename>bin/packr</filename>
    </modified>
    <modified>
      <diff>@@ -13,8 +13,6 @@ class Packr
   
   VERSION = '3.1.0'
   
-  PROTECTED_NAMES = %w($super)
-  
   class &lt;&lt; self
     def protect_vars(*args)
       @packr ||= self.new
@@ -137,12 +135,6 @@ class Packr
     @clean = @data.union(self.class.build(CLEAN))
     @whitespace = @data.union(self.class.build(WHITESPACE))
     @whitespace.remove_at(2) # conditional comments
-    @protected_names = PROTECTED_NAMES.dup
-  end
-  
-  def protect_vars(*args)
-    args = args.map { |arg| arg.to_s.strip }.select { |arg| arg =~ /^[a-z\_\$][a-z0-9\_\$]*$/i }
-    @protected_names = (@protected_names + args).uniq
   end
   
   def minify(script)
@@ -157,7 +149,7 @@ class Packr
   
   def pack(script, options = {})
     script = minify(script)
-    script = shrink_variables(script, options[:base62]) if options[:shrink_vars]
+    script = shrink_variables(script, options[:base62], options[:protect]) if options[:shrink_vars]
     script = encode_private_variables(script) if options[:private]
     script = base62_encode(script, options[:shrink_vars]) if options[:base62]
     @strings = nil
@@ -228,8 +220,10 @@ private
     script.gsub(/([\\'])/) { |match| &quot;\\#{$1}&quot; }.gsub(/[\r\n]+/, &quot;\\n&quot;)
   end
   
-  def shrink_variables(script, base62 = nil)
+  def shrink_variables(script, base62 = nil, protected_names = [])
     script = encode(script)
+    protected_names ||= []
+    protected_names = protected_names.map { |s| s.to_s }
     
     # identify blocks, particularly identify function blocks (which define scope)
     __block       = /((catch|do|if|while|with|function)\b[^~{};]*(\(\s*[^{};]*\s*\))\s*)?(\{[^{}]*\})/
@@ -278,7 +272,7 @@ private
           ids = [args, vars].join(&quot;,&quot;).scan(__identifier)
           processed = {}
           ids.each do |id|
-            if !processed[id] and !@protected_names.include?(id)
+            if !processed[id] and !protected_names.include?(id)
               processed[id] = true
               id = id.rescape
               # encode variable names</diff>
      <filename>lib/packr.rb</filename>
    </modified>
    <modified>
      <diff>@@ -77,14 +77,14 @@ class PackrTest &lt; Test::Unit::TestCase
   end
   
   def test_protected_names
-    expected = /var func\=function\([a-z],[a-z],\$super,[a-z]\)\{return \$super\([a-z]\+[a-z]\)\}/
+    expected = 'var func=function(a,d,c,b){return c(a+b)}'
     actual = Packr.pack('var func = function(foo, bar, $super, baz) { return $super( foo + baz ); }', :shrink_vars =&gt; true)
-    assert_match expected, actual
-    packr = Packr.new
-    packr.protect_vars(*(%w(other) + [:method, :names] + ['some random stuff', 24]))
-    expected = /var func\=function\([a-z],other,\$super,[a-z],names\)\{return \$super\(\)\(other\.apply\(names,[a-z]\)\)\}/
-    actual = packr.pack('var func = function(foo, other, $super, bar, names) { return $super()(other.apply(names, foo)); }', :shrink_vars =&gt; true)
-    assert_match expected, actual
+    assert_equal expected, actual
+    expected = 'var func=function(a,other,b,c,names){return b()(other.apply(names,a))}'
+    actual = Packr.pack('var func = function(foo, other, $super, bar, names) { return $super()(other.apply(names, foo)); }', :shrink_vars =&gt; true, :protect =&gt; (%w(other) + [:method, :names] + ['some random stuff', 24]))
+    assert_equal expected, actual
+    expected = 'function(a,$super){}'
+    assert_equal expected, Packr.pack('function(name, $super) { /* something */ }', :shrink_vars =&gt; true, :protect =&gt; %w($super))
   end
   
   def test_dollar_prefix</diff>
      <filename>test/test_packr.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>be41e9434c2e471df56a9de623b622e6dea6b7b5</id>
    </parent>
  </parents>
  <author>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </author>
  <url>http://github.com/jcoglan/packr/commit/157891d05dd546ab4fa470a369ad1854730b14e1</url>
  <id>157891d05dd546ab4fa470a369ad1854730b14e1</id>
  <committed-date>2008-07-17T05:09:06-07:00</committed-date>
  <authored-date>2008-07-17T05:09:06-07:00</authored-date>
  <message>Refactoring variable protection. Names are passed as an option to every pack() call rather than being a property of the Packr instance. This feature is also available on the command line now.</message>
  <tree>57caf1d58b68846effa65424a398736b2155fdc3</tree>
  <committer>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </committer>
</commit>
