rack-sprocketize 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,83 +1,109 @@
1
- # Rack::Sprocketize
1
+ Rack::Sprocketize
2
+ =================
2
3
 
3
4
  Rack::Sprocketize is a piece of Rack Middleware which uses [Sprockets](http://getsprockets.org/) to concatenate javascript files and then optionally compresses them. In a development environment, the files will be sprocketized on each request if there have been changes to the source files. In a production environment, the files will only be sprocketized one time, and only if there have been changes. Also, in a production environment, the files will be compressed by whichever javascript compressor is available.
4
5
 
5
- ## Installation
6
+ Installation
7
+ ------------
6
8
 
7
- gem install rack-sprocketize
9
+ ``` bash
10
+ $ gem install rack-sprocketize
11
+ ```
8
12
 
9
- ## Basic Usage
13
+ Basic Usage
14
+ -----------
10
15
 
11
16
  In a Rack based app, use Rack::Sprocketize just like any other middleware, passing options if necessary.
12
17
 
13
- require 'rack-sprocketize'
14
- use Rack::Sprocketize, :always_compress => true
18
+ ``` ruby
19
+ require 'rack-sprocketize'
20
+ use Rack::Sprocketize, :always_compress => true
21
+ ```
15
22
 
16
23
  In a Rails 3 app, Rack::Sprocketize is automatically included in the middleware stack, so all you need to worry about is configuration.
24
+
25
+ ``` ruby
26
+ # Gemfile
27
+ gem 'rack-sprocketize'
28
+
29
+ # config/application.rb
30
+ config.sprocketize.always_compress = true
31
+ ```
17
32
 
18
- # Gemfile
19
- gem 'rack-sprocketize'
20
-
21
- # config/application.rb
22
- config.sprocketize.always_compress = true
23
-
24
- ### Sprocketizing
33
+ Sprocketizing
34
+ -------------
25
35
 
26
36
  Rack::Sprocketize takes each file in the given `:source_path` (`'app/javascripts'` by default) and uses Sprockets to include any other required files. Then it outputs the results in the `:output_path` (`'public/javascripts` by default). Also, files that begin with `'_'` will not be sprocketized and will essentially be treated like partials.
27
37
 
28
38
  So, given the following files in an app:
29
39
 
30
- # app/javascripts/main.js
31
- //= require "_partial"
32
-
33
- # app/javascripts/_partial.js
34
- var hello = 'world';
35
-
36
- # app/javascripts/plugin.js
37
- var plugin = 'blah';
40
+ ``` ruby
41
+ # app/javascripts/main.js
42
+ //= require "_partial"
43
+
44
+ # app/javascripts/_partial.js
45
+ var hello = 'world';
46
+
47
+ # app/javascripts/plugin.js
48
+ var plugin = 'blah';
49
+ ```
38
50
 
39
51
  Rack::Sprocketize will sprocketize them into `:output_path` like this:
40
52
 
41
- # public/javascripts/main.js
42
- var hello = 'world';
43
-
44
- # public/javascripts/plugin.js
45
- var plugin = 'blah';
53
+ ``` ruby
54
+ # public/javascripts/main.js
55
+ var hello = 'world';
56
+
57
+ # public/javascripts/plugin.js
58
+ var plugin = 'blah';
59
+ ```
46
60
 
47
61
  Notice how the files weren't all concatenated into one file. You use Sprockets' `//= require` syntax to control how the files will be concatenated.
48
62
 
49
63
  Both the `:source_path` and `:output_path` can be customized when setting up Rack::Sprocketize:
50
64
 
51
- use Rack::Sprocketize, :source_path => 'js', :output_path => 'public/js'
65
+ ``` ruby
66
+ use Rack::Sprocketize, :source_path => 'js', :output_path => 'public/js'
67
+ ```
52
68
 
53
- ### Compression
69
+ Compression
70
+ -----------
54
71
 
55
72
  Rack::Sprocketize determines which javascript compressor you want to use based on which one has been required.
56
73
 
57
- require 'packr'
58
- use Rack::Sprocketize
59
- # would use Packr
74
+ ``` ruby
75
+ require 'packr'
76
+ use Rack::Sprocketize
77
+ # would use Packr
78
+ ```
60
79
 
61
80
  or in Rails:
62
81
 
63
- # Gemfile
64
- gem 'jsmin'
65
-
66
- # config/application.rb
67
- config.middleware.use Rack::Sprocketize
68
- # would use JSMin
82
+ ``` ruby
83
+ # Gemfile
84
+ gem 'jsmin'
85
+
86
+ # config/application.rb
87
+ config.middleware.use Rack::Sprocketize
88
+ # would use JSMin
89
+ ```
69
90
 
70
91
  To pass options to the javascript compressor just use the `:compression_options` option:
71
92
 
72
- require 'packr'
73
- use Rack::Sprocketize, :compression_options => { :shrink_vars => true }
93
+ ``` ruby
94
+ require 'packr'
95
+ use Rack::Sprocketize, :compression_options => { :shrink_vars => true }
96
+ ```
74
97
 
75
98
  By default, the files are only compressed in a production environment. If for some reason you want them to always be compressed, pass the `:always_compress` option:
76
99
 
77
- use Rack::Sprocketize, :always_compress => true
100
+ ``` ruby
101
+ use Rack::Sprocketize, :always_compress => true
102
+ ```
78
103
 
79
104
  Any files suffixed with `'.min'` or `'-min'` will not be compressed. For example, `'app/javascripts/jquery.min.js'` would not be re-compressed when it is sprocketized.
80
105
 
81
- ## Copyright
106
+ Copyright
107
+ ---------
82
108
 
83
109
  Copyright (c) 2011 [Peter Browne](http://petebrowne.com). See LICENSE for details.
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Sprocketize
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
@@ -6,23 +6,24 @@ Gem::Specification.new do |s|
6
6
  s.name = 'rack-sprocketize'
7
7
  s.version = Rack::Sprocketize::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = %w(Pete Browne)
10
- s.email = %w(me@petebrowne.com)
9
+ s.authors = ['Pete Browne']
10
+ s.email = ['me@petebrowne.com']
11
11
  s.homepage = 'http://github.com/petebrowne/rack-sprocketize'
12
12
  s.summary = %(Rack::Sprocketize is a piece of Rack Middleware which uses Sprockets to concatenate javascript files and then optionally compresses them.)
13
13
  s.description = %(Rack::Sprocketize is a piece of Rack Middleware which uses Sprockets to concatenate javascript files and then optionally compresses them. In a development environment, the files will be sprocketized on each request if there have been changes to the source files. In a production environment, the files will only be sprocketized one time, and only if there have been changes. Also, in a production environment, the files will be compressed by whichever javascript compressor is available.)
14
14
 
15
15
  s.rubyforge_project = 'rack-sprocketize'
16
16
 
17
- s.add_dependency 'rack', '~> 1.2.1'
18
- s.add_dependency 'sprockets', '~> 1.0.2'
19
- s.add_dependency 'valuable', '~> 0.8.5'
20
- s.add_development_dependency 'rspec', '~> 2.5.0'
21
- s.add_development_dependency 'test-construct', '~> 1.2.0'
22
- s.add_development_dependency 'jsmin', '~> 1.0.1'
23
- s.add_development_dependency 'packr', '~> 3.1.0'
24
- s.add_development_dependency 'yui-compressor', '~> 0.9.4'
25
- s.add_development_dependency 'closure-compiler', '~> 1.0.0'
17
+ s.add_dependency 'rack', '~> 1.2'
18
+ s.add_dependency 'sprockets', '~> 1.0'
19
+ s.add_dependency 'valuable', '~> 0.8'
20
+ s.add_development_dependency 'rake', '>= 0.8.7'
21
+ s.add_development_dependency 'rspec', '~> 2.6'
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', '~> 1.0'
26
27
 
27
28
  s.files = `git ls-files`.split("\n")
28
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,23 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-sprocketize
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 13
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
- - Pete
14
- - Browne
13
+ - Pete Browne
15
14
  autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-03-17 00:00:00 -05:00
20
- default_executable:
18
+ date: 2011-08-30 00:00:00 Z
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
23
21
  name: rack
@@ -27,12 +25,11 @@ dependencies:
27
25
  requirements:
28
26
  - - ~>
29
27
  - !ruby/object:Gem::Version
30
- hash: 29
28
+ hash: 11
31
29
  segments:
32
30
  - 1
33
31
  - 2
34
- - 1
35
- version: 1.2.1
32
+ version: "1.2"
36
33
  type: :runtime
37
34
  version_requirements: *id001
38
35
  - !ruby/object:Gem::Dependency
@@ -43,12 +40,11 @@ dependencies:
43
40
  requirements:
44
41
  - - ~>
45
42
  - !ruby/object:Gem::Version
46
- hash: 19
43
+ hash: 15
47
44
  segments:
48
45
  - 1
49
46
  - 0
50
- - 2
51
- version: 1.0.2
47
+ version: "1.0"
52
48
  type: :runtime
53
49
  version_requirements: *id002
54
50
  - !ruby/object:Gem::Dependency
@@ -59,110 +55,119 @@ dependencies:
59
55
  requirements:
60
56
  - - ~>
61
57
  - !ruby/object:Gem::Version
62
- hash: 53
58
+ hash: 27
63
59
  segments:
64
60
  - 0
65
61
  - 8
66
- - 5
67
- version: 0.8.5
62
+ version: "0.8"
68
63
  type: :runtime
69
64
  version_requirements: *id003
70
65
  - !ruby/object:Gem::Dependency
71
- name: rspec
66
+ name: rake
72
67
  prerelease: false
73
68
  requirement: &id004 !ruby/object:Gem::Requirement
74
69
  none: false
75
70
  requirements:
76
- - - ~>
71
+ - - ">="
77
72
  - !ruby/object:Gem::Version
78
- hash: 27
73
+ hash: 49
79
74
  segments:
80
- - 2
81
- - 5
82
75
  - 0
83
- version: 2.5.0
76
+ - 8
77
+ - 7
78
+ version: 0.8.7
84
79
  type: :development
85
80
  version_requirements: *id004
86
81
  - !ruby/object:Gem::Dependency
87
- name: test-construct
82
+ name: rspec
88
83
  prerelease: false
89
84
  requirement: &id005 !ruby/object:Gem::Requirement
90
85
  none: false
91
86
  requirements:
92
87
  - - ~>
93
88
  - !ruby/object:Gem::Version
94
- hash: 31
89
+ hash: 15
95
90
  segments:
96
- - 1
97
91
  - 2
98
- - 0
99
- version: 1.2.0
92
+ - 6
93
+ version: "2.6"
100
94
  type: :development
101
95
  version_requirements: *id005
102
96
  - !ruby/object:Gem::Dependency
103
- name: jsmin
97
+ name: test-construct
104
98
  prerelease: false
105
99
  requirement: &id006 !ruby/object:Gem::Requirement
106
100
  none: false
107
101
  requirements:
108
102
  - - ~>
109
103
  - !ruby/object:Gem::Version
110
- hash: 21
104
+ hash: 11
111
105
  segments:
112
106
  - 1
113
- - 0
114
- - 1
115
- version: 1.0.1
107
+ - 2
108
+ version: "1.2"
116
109
  type: :development
117
110
  version_requirements: *id006
118
111
  - !ruby/object:Gem::Dependency
119
- name: packr
112
+ name: jsmin
120
113
  prerelease: false
121
114
  requirement: &id007 !ruby/object:Gem::Requirement
122
115
  none: false
123
116
  requirements:
124
117
  - - ~>
125
118
  - !ruby/object:Gem::Version
126
- hash: 3
119
+ hash: 15
127
120
  segments:
128
- - 3
129
121
  - 1
130
122
  - 0
131
- version: 3.1.0
123
+ version: "1.0"
132
124
  type: :development
133
125
  version_requirements: *id007
134
126
  - !ruby/object:Gem::Dependency
135
- name: yui-compressor
127
+ name: packr
136
128
  prerelease: false
137
129
  requirement: &id008 !ruby/object:Gem::Requirement
138
130
  none: false
139
131
  requirements:
140
132
  - - ~>
141
133
  - !ruby/object:Gem::Version
142
- hash: 51
134
+ hash: 5
135
+ segments:
136
+ - 3
137
+ - 1
138
+ version: "3.1"
139
+ type: :development
140
+ version_requirements: *id008
141
+ - !ruby/object:Gem::Dependency
142
+ name: yui-compressor
143
+ prerelease: false
144
+ requirement: &id009 !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ hash: 25
143
150
  segments:
144
151
  - 0
145
152
  - 9
146
- - 4
147
- version: 0.9.4
153
+ version: "0.9"
148
154
  type: :development
149
- version_requirements: *id008
155
+ version_requirements: *id009
150
156
  - !ruby/object:Gem::Dependency
151
157
  name: closure-compiler
152
158
  prerelease: false
153
- requirement: &id009 !ruby/object:Gem::Requirement
159
+ requirement: &id010 !ruby/object:Gem::Requirement
154
160
  none: false
155
161
  requirements:
156
162
  - - ~>
157
163
  - !ruby/object:Gem::Version
158
- hash: 23
164
+ hash: 15
159
165
  segments:
160
166
  - 1
161
167
  - 0
162
- - 0
163
- version: 1.0.0
168
+ version: "1.0"
164
169
  type: :development
165
- version_requirements: *id009
170
+ version_requirements: *id010
166
171
  description: Rack::Sprocketize is a piece of Rack Middleware which uses Sprockets to concatenate javascript files and then optionally compresses them. In a development environment, the files will be sprocketized on each request if there have been changes to the source files. In a production environment, the files will only be sprocketized one time, and only if there have been changes. Also, in a production environment, the files will be compressed by whichever javascript compressor is available.
167
172
  email:
168
173
  - me@petebrowne.com
@@ -187,7 +192,6 @@ files:
187
192
  - rack-sprocketize.gemspec
188
193
  - spec/rack/sprocketize_spec.rb
189
194
  - spec/spec_helper.rb
190
- has_rdoc: true
191
195
  homepage: http://github.com/petebrowne/rack-sprocketize
192
196
  licenses: []
193
197
 
@@ -217,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
221
  requirements: []
218
222
 
219
223
  rubyforge_project: rack-sprocketize
220
- rubygems_version: 1.3.7
224
+ rubygems_version: 1.8.5
221
225
  signing_key:
222
226
  specification_version: 3
223
227
  summary: Rack::Sprocketize is a piece of Rack Middleware which uses Sprockets to concatenate javascript files and then optionally compresses them.