Permalink
Browse files

Switch from Hoe to Bundler for managing dependencies, and tidy up a l…

…ittle.
  • Loading branch information...
1 parent 5896f94 commit 14c39049356d36bd311414b0dd8314ef6ef619a9 @jcoglan committed Jul 19, 2011
Showing with 117 additions and 120 deletions.
  1. +3 −0 .gitignore
  2. +2 −0 Gemfile
  3. +4 −0 History.txt
  4. +0 −19 Manifest.txt
  5. +40 −44 README.txt → README.rdoc
  6. +0 −12 Rakefile
  7. +44 −38 bin/packr
  8. +0 −6 lib/packr.rb
  9. +20 −0 packr.gemspec
  10. +4 −1 test/test_packr.rb
View
@@ -0,0 +1,3 @@
+Gemfile.lock
+*.gem
+.redcar
View
@@ -0,0 +1,2 @@
+source "http://rubygems.org"
+gemspec
View
@@ -1,3 +1,7 @@
+=== 3.1.1 / 2011-07-19
+
+* Remove dependency on Hoe
+
=== 3.1.0 / 2009-02-22
* Project is now a gem, not a Rails plugin
View
@@ -1,19 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-bin/packr
-lib/packr.rb
-lib/string.rb
-lib/packr/map.rb
-lib/packr/collection.rb
-lib/packr/regexp_group.rb
-lib/packr/constants.rb
-lib/packr/encoder.rb
-lib/packr/minifier.rb
-lib/packr/parser.rb
-lib/packr/privates.rb
-lib/packr/shrinker.rb
-lib/packr/words.rb
-lib/packr/base62.rb
-test/test_packr.rb
View
@@ -4,22 +4,24 @@
* http://dean.edwards.name/packer/
* http://base2.googlecode.com
+
== Description
PackR is a Ruby version of Dean Edwards' JavaScript compressor.
+
== Features
* Whitespace and comment removal
* Compression of local variable names
* Compression and obfuscation of 'private' (_underscored) identifiers
* Base-62 encoding
+
== Synopsis
To call from within a Ruby program:
- require 'rubygems'
require 'packr'
code = File.read('my_script.js')
@@ -41,72 +43,66 @@ The full list of available options is:
compressed = Packr.pack(code, :shrink_vars => true,
:protect => %w[$super self])
-To call from the command line (use <tt>packr --help</tt> to see available options):
+To call from the command line (use <tt>packr --help</tt> to see available
+options):
packr my_script.js > my_script.min.js
-
+
+
== Notes
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
-so that your program will work correctly when packed down to a single line.
+expressions. Be sure to include semicolons and braces everywhere they are
+required so that your program will work correctly when packed down to a single
+line.
By far the most efficient way to serve JavaScript over the web is to use PackR
-with the --shrink-vars flag, combined with gzip compression. If you don't have access
-to your server config to set up mod_deflate, you can generate gzip files using
-(on Unix-like systems):
+with the --shrink-vars flag, combined with gzip compression. If you don't have
+access to your server config to set up mod_deflate, you can generate gzip files
+using (on Unix-like systems):
packr -s my-file.js | gzip > my-file.js.gz
-You can then get Apache to serve the files by putting this in your .htaccess file:
+You can then get Apache to serve the files by putting this in your .htaccess
+file:
AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
-If you really cannot serve gzip files, use the --base62 option to further compress
-your code. This mode is at its best when compressing large files with many repeated
-tokens.
+If you really cannot serve gzip files, use the --base62 option to further
+compress your code. This mode is at its best when compressing large files with
+many repeated tokens.
The --private option can be used to stop other programs calling private methods
-in your code by renaming anything beginning with a single underscore. Beware that
-you should not use this if the generated file contains 'private' methods that need
-to be accessible by other files. Also know that all the files that access any
-particular private method must be compressed together so they all get the same
-rewritten name for the private method.
+in your code by renaming anything beginning with a single underscore. Beware
+that you should not use this if the generated file contains 'private' methods
+that need to be accessible by other files. Also know that all the files that
+access any particular private method must be compressed together so they all get
+the same rewritten name for the private method.
-== Requirements
-* Rubygems
-* Oyster (installed automatically)
+== License
-== Installation
+(The MIT License)
- sudo gem install packr -y
+Copyright (c) 2004-2011 Dean Edwards, James Coglan
-== License
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the 'Software'), to deal in
+the Software without restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
-(The MIT License)
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
-Copyright (c) 2004-2009 Dean Edwards, James Coglan
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,12 +0,0 @@
-# -*- ruby -*-
-
-require 'rubygems'
-require 'hoe'
-require './lib/packr.rb'
-
-Hoe.new('packr', Packr::VERSION) do |p|
- p.developer('James Coglan', 'jcoglan@googlemail.com')
- p.extra_deps = %w(oyster)
-end
-
-# vim: syntax=Ruby
View
@@ -1,6 +1,8 @@
+#!/usr/bin/env ruby
+
require 'rubygems'
require 'oyster'
-require 'packr'
+require File.expand_path('../../lib/packr', __FILE__)
spec = Oyster.spec do
name "packr -- JavaScript code compressor based on Dean Edwards' Packer"
@@ -11,13 +13,14 @@ spec = Oyster.spec do
EOS
description <<-EOS
- PackR is a program for compressing JavaScript programs. It can remove whitespace
- and comments, compress local variable names, compress/obfuscate private identifiers,
- and encode the program in base-62.
+ PackR is a program for compressing JavaScript programs. It can remove
+ whitespace and comments, compress local variable names, compress/obfuscate
+ private identifiers, and encode the program in base-62.
- When invoked from the command line, it concatenates all the code in INPUT_FILES (or
- from standard input) and compresses the code using the given options, printing the
- result to standard output. You can pipe this output into another file to save it.
+ When invoked from the command line, it concatenates all the code in
+ INPUT_FILES (or from standard input) and compresses the code using the given
+ options, printing the result to standard output. You can pipe this output into
+ another file to save it.
EOS
flag :'shrink-vars', :default => true,
@@ -34,58 +37,61 @@ spec = Oyster.spec do
notes <<-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
- so that your program will work correctly when packed down to a single line.
+ expressions. Be sure to include semicolons and braces everywhere they are
+ required so that your program will work correctly when packed down to a single
+ line.
By far the most efficient way to serve JavaScript over the web is to use PackR
- with the --shrink-vars flag, combined with gzip compression. If you don't have access
- to your server config to set up mod_deflate, you can generate gzip files using
- (on Unix-like systems):
+ with the --shrink-vars flag, combined with gzip compression. If you don't have
+ access to your server config to set up mod_deflate, you can generate gzip
+ files using (on Unix-like systems):
packr -s my-file.js | gzip > my-file.js.gz
- You can then get Apache to serve the files by putting this in your .htaccess file:
+ You can then get Apache to serve the files by putting this in your .htaccess
+ file:
AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
- If you really cannot serve gzip files, use the --base62 option to further compress
- your code. This mode is at its best when compressing large files with many repeated
- tokens.
+ If you really cannot serve gzip files, use the --base62 option to further
+ compress your code. This mode is at its best when compressing large files with
+ many repeated tokens.
- The --private option can be used to stop other programs calling private methods
- in your code by renaming anything beginning with a single underscore. Beware that
- you should not use this if the generated file contains 'private' methods that need
- to be accessible by other files. Also know that all the files that access any
- particular private method must be compressed together so they all get the same
- rewritten name for the private method.
+ The --private option can be used to stop other programs calling private
+ methods in your code by renaming anything beginning with a single underscore.
+ Beware that you should not use this if the generated file contains 'private'
+ methods that need to be accessible by other files. Also know that all the
+ files that access any particular private method must be compressed together so
+ they all get the same rewritten name for the private method.
EOS
author <<-EOS
Original JavaScript version by Dean Edwards, Ruby port by James Coglan <jcoglan@googlemail.com>
EOS
copyright <<-EOS
- Copyright (c) 2004-2008 Dean Edwards, James Coglan. This program is free software,
- distributed under the MIT license.
+ Copyright (c) 2004-2011 Dean Edwards, James Coglan. This program is free
+ software, distributed under the MIT license.
EOS
end
-begin; opts = spec.parse
-rescue Oyster::HelpRendered; exit
+begin
+ opts = spec.parse
+
+ inputs = opts[:unclaimed]
+ code = inputs.empty? ?
+ $stdin.read :
+ inputs.map { |f| File.read(f) }.join("\n")
+
+ $stdout.puts Packr.pack(code,
+ :shrink_vars => !!opts[:'shrink-vars'],
+ :protect => opts[:protect],
+ :private => !!opts[:private],
+ :base62 => !!opts[:base62])
+
+rescue Oyster::HelpRendered
end
-
-inputs = opts[:unclaimed]
-code = inputs.empty? ?
- $stdin.read :
- inputs.map { |f| File.read(f) }.join("\n")
-
-$stdout.puts Packr.pack(code,
- :shrink_vars => !!opts[:'shrink-vars'],
- :protect => opts[:protect],
- :private => !!opts[:private],
- :base62 => !!opts[:base62])
-
View
@@ -1,7 +1,3 @@
-# PackR -- a Ruby port of Packer by Dean Edwards
-# Packer version 3.1 copyright 2004-2009, Dean Edwards
-# http://www.opensource.org/licenses/mit-license
-
[ '/string',
'/packr/map',
'/packr/collection',
@@ -20,8 +16,6 @@
class Packr
- VERSION = '3.1.0'
-
DATA = Parser.new.
put("STRING1", IGNORE).
put('STRING2', IGNORE).
View
@@ -0,0 +1,20 @@
+Gem::Specification.new do |s|
+ s.name = "packr"
+ s.version = "3.1.1"
+ s.summary = "Ruby version of Dean Edwards' JavaScript compressor"
+ s.author = "James Coglan"
+ s.email = "jcoglan@gmail.com"
+ s.homepage = "http://github.com/jcoglan/packr"
+
+ s.extra_rdoc_files = %w[README.rdoc]
+ s.rdoc_options = %w[--main README.rdoc]
+
+ s.files = %w[History.txt README.rdoc] + Dir.glob("{bin,lib,test}/**/*")
+
+ s.executables = Dir.glob("bin/**").map { |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.add_dependency "oyster", ">= 0.9.5"
+
+ s.add_development_dependency "test-unit"
+end
View
@@ -1,6 +1,9 @@
+require 'rubygems'
+require 'bundler/setup'
require 'test/unit'
require 'fileutils'
-require 'packr'
+
+require File.expand_path('../../lib/packr', __FILE__)
class PackrTest < Test::Unit::TestCase

0 comments on commit 14c3904

Please sign in to comment.