rack-pack 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +78 -49
- data/lib/rack/pack/version.rb +1 -1
- data/rack-pack.gemspec +13 -13
- metadata +62 -72
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
Rack::Pack
|
2
|
+
==========
|
2
3
|
|
3
4
|
Rack::Pack is a piece of Rack Middleware that packages and optionally compresses assets such as javascripts and stylesheets into single files. In a development environment, assets will be packaged on each request if there have been changes to the source files. In a production environment, assets will only be packaged one time, and only if there have been changes.
|
4
5
|
|
@@ -6,84 +7,112 @@ Rack::Pack is a piece of Rack Middleware that packages and optionally compresses
|
|
6
7
|
|
7
8
|
I've tried a dozen different asset packaging solutions including AssetPackager, BundleFu, Jammit, Sprockets, etc...none of which were quite what I wanted. I didn't need any helpers, controllers, embedded images, rake tasks, or Yaml config files. I just wanted something to take my assets and package them into one file, and you're looking at it.
|
8
9
|
|
9
|
-
|
10
|
+
Installation
|
11
|
+
------------
|
10
12
|
|
11
|
-
|
13
|
+
``` bash
|
14
|
+
$ gem install rack-pack
|
15
|
+
```
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
require 'rack-pack'
|
16
|
-
use Rack::Pack
|
17
|
+
Basic Usage
|
18
|
+
-----------
|
17
19
|
|
18
|
-
|
20
|
+
``` ruby
|
21
|
+
require 'rack-pack'
|
22
|
+
use Rack::Pack
|
23
|
+
```
|
19
24
|
|
20
|
-
|
21
|
-
gem 'rack-pack'
|
25
|
+
or in Rails:
|
22
26
|
|
23
|
-
|
24
|
-
|
27
|
+
``` ruby
|
28
|
+
# Gemfile
|
29
|
+
gem 'rack-pack'
|
30
|
+
|
31
|
+
# config/application.rb
|
32
|
+
config.middleware.use Rack::Pack
|
33
|
+
```
|
25
34
|
|
26
|
-
|
35
|
+
Packages
|
36
|
+
--------
|
27
37
|
|
28
38
|
Two files will be packaged out of the box: `javascripts/application.js` & `stylesheets/application.css`. Rack::Pack will look in `vendor/javascripts`, `app/javascripts`, & `./javascripts` for any .js files and `vendor/stylesheets`, `app/stylesheets`, & `./stylesheets` for any .css files. These files will be packaged in the order they're found.
|
29
39
|
|
30
40
|
To create your own packages, pass in the name of the output file and the source files as options:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
|
42
|
+
``` ruby
|
43
|
+
use Rack::Pack, 'js/main.js' => [
|
44
|
+
'vendor/javascripts/jquery.js',
|
45
|
+
'vendor/javascripts/swfobject.js,
|
46
|
+
'app/javascripts/misc.js',
|
47
|
+
'app/javascripts/main.js'
|
48
|
+
]
|
49
|
+
# Creates a 'public/js/main.js' file
|
50
|
+
```
|
39
51
|
|
40
52
|
Notice how the output file is relative to the public dir. By default this is just `'public'`, but this can be changed using the `:public_dir` option:
|
41
|
-
|
42
|
-
|
43
|
-
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
use Rack::Pack, :public_dir => 'html', 'js/main.js' => %w(js/plugins.js js/main.js)
|
56
|
+
# Creates a 'html/js/main.js' file
|
57
|
+
```
|
44
58
|
|
45
59
|
You can also pass a glob string for the source files. This string will be used to search for new files on each request. The downside is the source files will be concatenated in the order they're found.
|
46
|
-
|
47
|
-
|
60
|
+
|
61
|
+
``` ruby
|
62
|
+
use Rack::Pack, 'assets/scripts.js' => 'app/js/**/*.js'
|
63
|
+
```
|
48
64
|
|
49
65
|
In fact, this is how the default packages are declared:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
66
|
+
|
67
|
+
``` ruby
|
68
|
+
use Rack::Pack,
|
69
|
+
'javascripts/application.js' => '{vendor,app,.}/javascripts/*.js',
|
70
|
+
'stylesheets/application.css' => '{vendor,app,.}/stylesheets/*.css'
|
71
|
+
```
|
54
72
|
|
55
73
|
Beautiful, isn't it? I don't think you can get simpler than that. No Yaml config files or rake tasks. You'll set it up once then forget about it completely. Well unless you have to add a new source file and you were explicity setting your source files for a package, but whatever.
|
56
74
|
|
57
|
-
|
75
|
+
Compression
|
76
|
+
-----------
|
58
77
|
|
59
78
|
What good would an asset packager be without compression? Rack::Pack determines which javascript compressor you want to use based on which one has been required.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
79
|
+
|
80
|
+
``` ruby
|
81
|
+
require 'packr'
|
82
|
+
use Rack::Pack
|
83
|
+
# would use Packr
|
84
|
+
```
|
64
85
|
|
65
86
|
or in Rails:
|
66
|
-
|
67
|
-
# Gemfile
|
68
|
-
gem 'jsmin'
|
69
87
|
|
70
|
-
|
71
|
-
|
72
|
-
|
88
|
+
``` ruby
|
89
|
+
# Gemfile
|
90
|
+
gem 'jsmin'
|
73
91
|
|
74
|
-
|
92
|
+
# config/application.rb
|
93
|
+
config.middleware.use Rack::Pack
|
94
|
+
# would use JSMin
|
95
|
+
```
|
75
96
|
|
76
|
-
|
77
|
-
|
97
|
+
To pass options to the javascript compressor just use the `:js_compressor` option:
|
98
|
+
|
99
|
+
``` ruby
|
100
|
+
require 'packr'
|
101
|
+
use Rack::Pack, :js_compression => { :shrink_vars => true }
|
102
|
+
```
|
78
103
|
|
79
104
|
By default, packages are only compressed in a production environment. If for some reason you want them to always be compressed, pass the `:always_compress` option:
|
105
|
+
|
106
|
+
``` ruby
|
107
|
+
use Rack::Pack, :always_compress => true
|
108
|
+
```
|
80
109
|
|
81
|
-
|
82
|
-
|
83
|
-
## Heroku and other read-only filesystems
|
110
|
+
Heroku and other read-only filesystems
|
111
|
+
--------------------------------------
|
84
112
|
|
85
113
|
Because Rack::Pack relies on writing the packaged files, it won't package anything on Heroku. But, you could just check in your packaged files and push them to Heroku. I'll look into other options for future versions.
|
86
114
|
|
87
|
-
|
115
|
+
Copyright
|
116
|
+
---------
|
88
117
|
|
89
|
-
Copyright (c)
|
118
|
+
Copyright (c) 2011 [Peter Browne](http://petebrowne.com). See LICENSE for details.
|
data/lib/rack/pack/version.rb
CHANGED
data/rack-pack.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'rack-pack'
|
7
7
|
s.version = Rack::Pack::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = 'Pete Browne'
|
10
|
-
s.email = 'me@petebrowne.com'
|
9
|
+
s.authors = ['Pete Browne']
|
10
|
+
s.email = ['me@petebrowne.com']
|
11
11
|
s.homepage = 'http://github.com/petebrowne/rack-pack'
|
12
12
|
s.summary = 'Rack Middleware for packaging assets such as javascripts and stylesheets.'
|
13
13
|
s.description = 'Rack::Pack is a piece of Rack Middleware that packages and optionally compresses assets such as javascripts and stylesheets into single files. In a development environment, assets will be packaged on each request if there have been changes to the source files. In a production environment, assets will only be packaged one time, and only if there have been changes.'
|
@@ -15,17 +15,17 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.required_rubygems_version = '>= 1.3.6'
|
16
16
|
s.rubyforge_project = 'rack-pack'
|
17
17
|
|
18
|
-
s.add_dependency 'rack', '~> 1.2
|
19
|
-
s.add_development_dependency 'rspec', '~> 2.6
|
20
|
-
s.add_development_dependency 'activesupport', '~> 3.0
|
21
|
-
s.add_development_dependency 'i18n', '~> 0.5
|
22
|
-
s.add_development_dependency 'test-construct', '~> 1.2
|
23
|
-
s.add_development_dependency 'jsmin', '~> 1.0
|
24
|
-
s.add_development_dependency 'packr', '~> 3.1
|
25
|
-
s.add_development_dependency 'yui-compressor', '~> 0.9
|
26
|
-
s.add_development_dependency 'closure-compiler', '~> 0.3
|
27
|
-
s.add_development_dependency 'uglifier', '~> 0.5
|
28
|
-
s.add_development_dependency 'rainpress', '~> 1.0
|
18
|
+
s.add_dependency 'rack', '~> 1.2'
|
19
|
+
s.add_development_dependency 'rspec', '~> 2.6'
|
20
|
+
s.add_development_dependency 'activesupport', '~> 3.0'
|
21
|
+
s.add_development_dependency 'i18n', '~> 0.5'
|
22
|
+
s.add_development_dependency 'test-construct', '~> 1.2'
|
23
|
+
s.add_development_dependency 'jsmin', '~> 1.0'
|
24
|
+
s.add_development_dependency 'packr', '~> 3.1'
|
25
|
+
s.add_development_dependency 'yui-compressor', '~> 0.9'
|
26
|
+
s.add_development_dependency 'closure-compiler', '~> 0.3'
|
27
|
+
s.add_development_dependency 'uglifier', '~> 0.5'
|
28
|
+
s.add_development_dependency 'rainpress', '~> 1.0'
|
29
29
|
|
30
30
|
s.files = `git ls-files`.split("\n")
|
31
31
|
s.executables = `git ls-files`.split("\n").map{ |f| f =~ /^bin\/(.*)/ ? $1 : nil }.compact
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pete Browne
|
@@ -15,186 +15,176 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
22
|
none: false
|
24
23
|
requirements:
|
25
24
|
- - ~>
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
26
|
+
hash: 11
|
28
27
|
segments:
|
29
28
|
- 1
|
30
29
|
- 2
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
version: "1.2"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rack
|
34
33
|
prerelease: false
|
35
34
|
type: :runtime
|
36
35
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
38
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
37
|
none: false
|
40
38
|
requirements:
|
41
39
|
- - ~>
|
42
40
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
41
|
+
hash: 15
|
44
42
|
segments:
|
45
43
|
- 2
|
46
44
|
- 6
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
version: "2.6"
|
46
|
+
version_requirements: *id002
|
47
|
+
name: rspec
|
50
48
|
prerelease: false
|
51
49
|
type: :development
|
52
50
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
54
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
52
|
none: false
|
56
53
|
requirements:
|
57
54
|
- - ~>
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
56
|
+
hash: 7
|
60
57
|
segments:
|
61
58
|
- 3
|
62
59
|
- 0
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
version: "3.0"
|
61
|
+
version_requirements: *id003
|
62
|
+
name: activesupport
|
66
63
|
prerelease: false
|
67
64
|
type: :development
|
68
65
|
- !ruby/object:Gem::Dependency
|
69
|
-
|
70
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
67
|
none: false
|
72
68
|
requirements:
|
73
69
|
- - ~>
|
74
70
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
71
|
+
hash: 1
|
76
72
|
segments:
|
77
73
|
- 0
|
78
74
|
- 5
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
version: "0.5"
|
76
|
+
version_requirements: *id004
|
77
|
+
name: i18n
|
82
78
|
prerelease: false
|
83
79
|
type: :development
|
84
80
|
- !ruby/object:Gem::Dependency
|
85
|
-
|
86
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
82
|
none: false
|
88
83
|
requirements:
|
89
84
|
- - ~>
|
90
85
|
- !ruby/object:Gem::Version
|
91
|
-
hash:
|
86
|
+
hash: 11
|
92
87
|
segments:
|
93
88
|
- 1
|
94
89
|
- 2
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
version: "1.2"
|
91
|
+
version_requirements: *id005
|
92
|
+
name: test-construct
|
98
93
|
prerelease: false
|
99
94
|
type: :development
|
100
95
|
- !ruby/object:Gem::Dependency
|
101
|
-
|
102
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
97
|
none: false
|
104
98
|
requirements:
|
105
99
|
- - ~>
|
106
100
|
- !ruby/object:Gem::Version
|
107
|
-
hash:
|
101
|
+
hash: 15
|
108
102
|
segments:
|
109
103
|
- 1
|
110
104
|
- 0
|
111
|
-
|
112
|
-
|
113
|
-
|
105
|
+
version: "1.0"
|
106
|
+
version_requirements: *id006
|
107
|
+
name: jsmin
|
114
108
|
prerelease: false
|
115
109
|
type: :development
|
116
110
|
- !ruby/object:Gem::Dependency
|
117
|
-
|
118
|
-
version_requirements: &id007 !ruby/object:Gem::Requirement
|
111
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
112
|
none: false
|
120
113
|
requirements:
|
121
114
|
- - ~>
|
122
115
|
- !ruby/object:Gem::Version
|
123
|
-
hash:
|
116
|
+
hash: 5
|
124
117
|
segments:
|
125
118
|
- 3
|
126
119
|
- 1
|
127
|
-
|
128
|
-
|
129
|
-
|
120
|
+
version: "3.1"
|
121
|
+
version_requirements: *id007
|
122
|
+
name: packr
|
130
123
|
prerelease: false
|
131
124
|
type: :development
|
132
125
|
- !ruby/object:Gem::Dependency
|
133
|
-
|
134
|
-
version_requirements: &id008 !ruby/object:Gem::Requirement
|
126
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
135
127
|
none: false
|
136
128
|
requirements:
|
137
129
|
- - ~>
|
138
130
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
131
|
+
hash: 25
|
140
132
|
segments:
|
141
133
|
- 0
|
142
134
|
- 9
|
143
|
-
|
144
|
-
|
145
|
-
|
135
|
+
version: "0.9"
|
136
|
+
version_requirements: *id008
|
137
|
+
name: yui-compressor
|
146
138
|
prerelease: false
|
147
139
|
type: :development
|
148
140
|
- !ruby/object:Gem::Dependency
|
149
|
-
|
150
|
-
version_requirements: &id009 !ruby/object:Gem::Requirement
|
141
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
151
142
|
none: false
|
152
143
|
requirements:
|
153
144
|
- - ~>
|
154
145
|
- !ruby/object:Gem::Version
|
155
|
-
hash:
|
146
|
+
hash: 13
|
156
147
|
segments:
|
157
148
|
- 0
|
158
149
|
- 3
|
159
|
-
|
160
|
-
|
161
|
-
|
150
|
+
version: "0.3"
|
151
|
+
version_requirements: *id009
|
152
|
+
name: closure-compiler
|
162
153
|
prerelease: false
|
163
154
|
type: :development
|
164
155
|
- !ruby/object:Gem::Dependency
|
165
|
-
|
166
|
-
version_requirements: &id010 !ruby/object:Gem::Requirement
|
156
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
167
157
|
none: false
|
168
158
|
requirements:
|
169
159
|
- - ~>
|
170
160
|
- !ruby/object:Gem::Version
|
171
|
-
hash:
|
161
|
+
hash: 1
|
172
162
|
segments:
|
173
163
|
- 0
|
174
164
|
- 5
|
175
|
-
|
176
|
-
|
177
|
-
|
165
|
+
version: "0.5"
|
166
|
+
version_requirements: *id010
|
167
|
+
name: uglifier
|
178
168
|
prerelease: false
|
179
169
|
type: :development
|
180
170
|
- !ruby/object:Gem::Dependency
|
181
|
-
|
182
|
-
version_requirements: &id011 !ruby/object:Gem::Requirement
|
171
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
183
172
|
none: false
|
184
173
|
requirements:
|
185
174
|
- - ~>
|
186
175
|
- !ruby/object:Gem::Version
|
187
|
-
hash:
|
176
|
+
hash: 15
|
188
177
|
segments:
|
189
178
|
- 1
|
190
179
|
- 0
|
191
|
-
|
192
|
-
|
193
|
-
|
180
|
+
version: "1.0"
|
181
|
+
version_requirements: *id011
|
182
|
+
name: rainpress
|
194
183
|
prerelease: false
|
195
184
|
type: :development
|
196
185
|
description: Rack::Pack is a piece of Rack Middleware that packages and optionally compresses assets such as javascripts and stylesheets into single files. In a development environment, assets will be packaged on each request if there have been changes to the source files. In a production environment, assets will only be packaged one time, and only if there have been changes.
|
197
|
-
email:
|
186
|
+
email:
|
187
|
+
- me@petebrowne.com
|
198
188
|
executables: []
|
199
189
|
|
200
190
|
extensions: []
|
@@ -251,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
241
|
requirements: []
|
252
242
|
|
253
243
|
rubyforge_project: rack-pack
|
254
|
-
rubygems_version: 1.
|
244
|
+
rubygems_version: 1.8.5
|
255
245
|
signing_key:
|
256
246
|
specification_version: 3
|
257
247
|
summary: Rack Middleware for packaging assets such as javascripts and stylesheets.
|