packr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ require 'test/unit'
2
+ require 'packr'
3
+
4
+ class PackrTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ dir = File.dirname(__FILE__) + '/assets'
8
+ @data = {
9
+ :default => [{
10
+ :source => File.read("#{dir}/src/controls.js"),
11
+ :packed => File.read("#{dir}/packed/controls.js")
12
+ }],
13
+ :shrink_vars => [{
14
+ :source => File.read("#{dir}/src/dragdrop.js"),
15
+ :packed => File.read("#{dir}/packed/dragdrop.js")
16
+ },
17
+ { :source => File.read("#{dir}/src/prototype.js"),
18
+ :packed => File.read("#{dir}/packed/prototype_shrunk.js")
19
+ }],
20
+ :base62 => [{
21
+ :source => File.read("#{dir}/src/effects.js"),
22
+ :packed => File.read("#{dir}/packed/effects.js")
23
+ }],
24
+ :base62_shrink_vars => [{
25
+ :source => File.read("#{dir}/src/prototype.js"),
26
+ :packed => File.read("#{dir}/packed/prototype.js")
27
+ }]
28
+ }
29
+ end
30
+
31
+ def test_basic_packing
32
+ assert_equal @data[:default][0][:packed], Packr.pack(@data[:default][0][:source])
33
+ end
34
+
35
+ def test_shrink_vars_packing
36
+ assert_equal @data[:shrink_vars][0][:packed], Packr.pack(@data[:shrink_vars][0][:source], :shrink_vars => true)
37
+ assert_equal @data[:shrink_vars][1][:packed], Packr.pack(@data[:shrink_vars][1][:source], :shrink_vars => true)
38
+ end
39
+
40
+ def test_base62_packing
41
+ expected = @data[:base62][0][:packed]
42
+ actual = Packr.pack(@data[:base62][0][:source], :base62 => true)
43
+ assert_equal expected.size, actual.size
44
+ expected_words = expected.scan(/'[\w\|]+'/)[-2].gsub(/^'(.*?)'$/, '\1').split("|").sort
45
+ actual_words = actual.scan(/'[\w\|]+'/)[-2].gsub(/^'(.*?)'$/, '\1').split("|").sort
46
+ assert expected_words.eql?(actual_words)
47
+ end
48
+
49
+ def test_base62_and_shrink_vars_packing
50
+ expected = @data[:base62_shrink_vars][0][:packed]
51
+ actual = Packr.pack(@data[:base62_shrink_vars][0][:source], :base62 => true, :shrink_vars => true)
52
+ assert_equal expected.size, actual.size
53
+ expected_words = expected.scan(/'[\w\|]+'/)[-2].gsub(/^'(.*?)'$/, '\1').split("|").sort
54
+ actual_words = actual.scan(/'[\w\|]+'/)[-2].gsub(/^'(.*?)'$/, '\1').split("|").sort
55
+ assert expected_words.eql?(actual_words)
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: packr
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-12-04 00:00:00 +00:00
8
+ summary: A Ruby port of Dean Edwards' JavaScript compressor
9
+ require_paths:
10
+ - lib
11
+ email: james@jcoglan.com
12
+ homepage: http://blog.jcoglan.com/packr/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: lib/packr.rb
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - James Coglan
31
+ files:
32
+ - lib/packr
33
+ - lib/packr.rb
34
+ - lib/string.rb
35
+ - lib/packr/regexp_group.rb
36
+ - lib/packr/words.rb
37
+ - README
38
+ test_files:
39
+ - test/assets
40
+ - test/packr_test.rb
41
+ - test/assets/packed
42
+ - test/assets/src
43
+ - test/assets/packed/controls.js
44
+ - test/assets/packed/dragdrop.js
45
+ - test/assets/packed/effects.js
46
+ - test/assets/packed/prototype.js
47
+ - test/assets/packed/prototype_shrunk.js
48
+ - test/assets/src/controls.js
49
+ - test/assets/src/dragdrop.js
50
+ - test/assets/src/effects.js
51
+ - test/assets/src/prototype.js
52
+ rdoc_options:
53
+ - --main
54
+ - README
55
+ - --line-numbers
56
+ - --inline-source
57
+ extra_rdoc_files:
58
+ - README
59
+ executables: []
60
+
61
+ extensions: []
62
+
63
+ requirements: []
64
+
65
+ dependencies: []
66
+