Skip to content

Instantly share code, notes, and snippets.

@enriquez
Created April 13, 2009 02:38
Show Gist options
  • Save enriquez/94226 to your computer and use it in GitHub Desktop.
Save enriquez/94226 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'packr'
class Packr
def self.compress_to_file(filename, options = {})
defaults = {
:target_file => filename.gsub(/\.js$/, '.min.js'),
:shrink_vars => true
}
options = defaults.merge options
code = File.read(filename)
compressed = Packr.pack(code, options)
File.open(options[:target_file], 'wb') { |f| f.write(compressed) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment