sundawg-sinatra-assetpack-fork 0.0.12.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +2 -0
  3. data/HISTORY.md +131 -0
  4. data/README.md +656 -0
  5. data/Rakefile +31 -0
  6. data/docsrc/style.css +32 -0
  7. data/examples/basic/.gitignore +1 -0
  8. data/examples/basic/Rakefile +7 -0
  9. data/examples/basic/app/css/test.sass +11 -0
  10. data/examples/basic/app/images/icon.png +0 -0
  11. data/examples/basic/app/js/app.js +4 -0
  12. data/examples/basic/app/js/vendor/jquery.js +2 -0
  13. data/examples/basic/app/js/vendor/jquery.plugin.js +2 -0
  14. data/examples/basic/app/js/vendor/underscore.js +2 -0
  15. data/examples/basic/app.rb +39 -0
  16. data/examples/basic/views/index.erb +26 -0
  17. data/examples/classic/app.rb +24 -0
  18. data/examples/classic/css/screen.scss +1 -0
  19. data/examples/compass/.gitignore +1 -0
  20. data/examples/compass/Rakefile +7 -0
  21. data/examples/compass/app/css/main.scss +64 -0
  22. data/examples/compass/app/images/icon/mail.png +0 -0
  23. data/examples/compass/app/images/icon/refresh.png +0 -0
  24. data/examples/compass/app/images/icon-scfd8d7d404.png +0 -0
  25. data/examples/compass/app/images/junk/mail.png +0 -0
  26. data/examples/compass/app/images/junk/refresh.png +0 -0
  27. data/examples/compass/app/js/app.js +3 -0
  28. data/examples/compass/app/js/vendor/jquery.js +2 -0
  29. data/examples/compass/app/js/vendor/jquery.plugin.js +2 -0
  30. data/examples/compass/app/js/vendor/underscore.js +2 -0
  31. data/examples/compass/app.rb +45 -0
  32. data/examples/compass/config.ru +3 -0
  33. data/examples/compass/views/index.erb +15 -0
  34. data/lib/sinatra/assetpack/buster_helpers.rb +36 -0
  35. data/lib/sinatra/assetpack/class_methods.rb +82 -0
  36. data/lib/sinatra/assetpack/compressor.rb +54 -0
  37. data/lib/sinatra/assetpack/configurator.rb +21 -0
  38. data/lib/sinatra/assetpack/css.rb +36 -0
  39. data/lib/sinatra/assetpack/engine.rb +20 -0
  40. data/lib/sinatra/assetpack/engines/closure.rb +19 -0
  41. data/lib/sinatra/assetpack/engines/jsmin.rb +10 -0
  42. data/lib/sinatra/assetpack/engines/sass.rb +11 -0
  43. data/lib/sinatra/assetpack/engines/simple.rb +11 -0
  44. data/lib/sinatra/assetpack/engines/sqwish.rb +21 -0
  45. data/lib/sinatra/assetpack/engines/uglify.rb +12 -0
  46. data/lib/sinatra/assetpack/engines/yui.rb +22 -0
  47. data/lib/sinatra/assetpack/hasharray.rb +66 -0
  48. data/lib/sinatra/assetpack/helpers.rb +62 -0
  49. data/lib/sinatra/assetpack/html_helpers.rb +17 -0
  50. data/lib/sinatra/assetpack/image.rb +59 -0
  51. data/lib/sinatra/assetpack/options.rb +329 -0
  52. data/lib/sinatra/assetpack/package.rb +126 -0
  53. data/lib/sinatra/assetpack/rake.rb +29 -0
  54. data/lib/sinatra/assetpack/version.rb +7 -0
  55. data/lib/sinatra/assetpack.rb +61 -0
  56. data/sinatra-assetpack.gemspec +26 -0
  57. data/test/app/.gitignore +1 -0
  58. data/test/app/Rakefile +7 -0
  59. data/test/app/app/css/behavior.htc +1 -0
  60. data/test/app/app/css/js2c.css +494 -0
  61. data/test/app/app/css/screen.sass +9 -0
  62. data/test/app/app/css/sqwishable.css +7 -0
  63. data/test/app/app/css/style.css +3 -0
  64. data/test/app/app/css/stylus.styl +3 -0
  65. data/test/app/app/css_stylus/stylus.styl +3 -0
  66. data/test/app/app/images/background.jpg +1 -0
  67. data/test/app/app/images/email.png +0 -0
  68. data/test/app/app/js/_ignoreme.js +1 -0
  69. data/test/app/app/js/hello.2.js +1 -0
  70. data/test/app/app/js/hello.js +1 -0
  71. data/test/app/app/js/helloe.js +1 -0
  72. data/test/app/app/js/hi.coffee +2 -0
  73. data/test/app/app/js/ugly.js +7 -0
  74. data/test/app/app/js/yoe.coffee +2 -0
  75. data/test/app/app/js_glob/a/b/c1/hello.js +1 -0
  76. data/test/app/app/js_glob/a/b/c2/hi.js +1 -0
  77. data/test/app/app/js_glob/a/b/c2/hola.js +1 -0
  78. data/test/app/app/views/index.haml +1 -0
  79. data/test/app/app.rb +67 -0
  80. data/test/arity_test.rb +26 -0
  81. data/test/build_test.rb +31 -0
  82. data/test/cache_test.rb +9 -0
  83. data/test/combined_test.rb +8 -0
  84. data/test/compressed_test.rb +30 -0
  85. data/test/glob_test.rb +42 -0
  86. data/test/helpers_test.rb +30 -0
  87. data/test/ignore_test.rb +30 -0
  88. data/test/img_test.rb +31 -0
  89. data/test/local_file_test.rb +21 -0
  90. data/test/mime_type_test.rb +33 -0
  91. data/test/non_existent_test.rb +45 -0
  92. data/test/options_test.rb +21 -0
  93. data/test/order_test.rb +20 -0
  94. data/test/preproc_test.rb +28 -0
  95. data/test/redundant_test.rb +11 -0
  96. data/test/simplecss_test.rb +16 -0
  97. data/test/sqwish_test.rb +31 -0
  98. data/test/stylus_test.rb +23 -0
  99. data/test/template_cache_test.rb +29 -0
  100. data/test/test_helper.rb +46 -0
  101. data/test/tilt_test.rb +11 -0
  102. data/test/uglifier_test.rb +23 -0
  103. data/test/unit_test.rb +106 -0
  104. data/test/yui_test.rb +22 -0
  105. metadata +341 -0
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class UglifyTest < UnitTest
4
+ class App < UnitTest::App
5
+ register Sinatra::AssetPack
6
+
7
+ assets do
8
+ js_compression :uglify, :mangle => true
9
+ js :main, '/main.js', [
10
+ '/js/ugly.js'
11
+ ]
12
+ end
13
+ end
14
+
15
+ def app
16
+ App
17
+ end
18
+
19
+ test "build" do
20
+ get '/main.js'
21
+ assert !body.include?("noodle")
22
+ end
23
+ end
data/test/unit_test.rb ADDED
@@ -0,0 +1,106 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class AppTest < UnitTest
4
+ test '/js/hello.js (plain js)' do
5
+ get '/js/hello.js'
6
+ assert body == '$(function() { alert("Hello"); });'
7
+ end
8
+
9
+ test '/js/hi.js (coffeescript)' do
10
+ get '/js/hi.js'
11
+ assert body.include? 'yo'
12
+ assert body.include? 'x = function'
13
+ end
14
+
15
+ test '/js/hi.css (404)' do
16
+ get '/js/hi.css'
17
+ assert last_response.status == 404
18
+ end
19
+
20
+ test '/js/hello.2834987.js (with cache buster)' do
21
+ get '/js/hello.283947.js'
22
+ assert body == '$(function() { alert("Hello"); });'
23
+ end
24
+
25
+ test '/js/hello.2.2834987.js (with cache buster)' do
26
+ get '/js/hello.2.283947.js'
27
+ assert body == '$(function() { alert("Hello.2"); });'
28
+ end
29
+
30
+ test '/js/hi.2834987.js (coffeescript with cache buster)' do
31
+ get '/js/hi.283947.js'
32
+ assert last_response.status == 200
33
+ assert body.include? 'yo'
34
+ assert body.include? 'x = function'
35
+ end
36
+
37
+ test 'wrong extension for static file' do
38
+ get '/js/hello.css'
39
+ assert last_response.status == 404
40
+ end
41
+
42
+ test 'matches only from the site root' do
43
+ get '/not-the-root/js/hello.js'
44
+ assert last_response.status == 404
45
+ end
46
+
47
+ test 'wrong extension for dynamic coffeescript file' do
48
+ get '/js/hi.css'
49
+ assert last_response.status == 404
50
+ end
51
+
52
+ test 'static css' do
53
+ get '/css/style.css'
54
+ assert body.include?('div { color: red; }')
55
+ end
56
+
57
+ test 'sass' do
58
+ get '/css/screen.css'
59
+ assert body =~ /background.*rgba.*255.*0.3/m
60
+ end
61
+
62
+ test "match" do
63
+ files = app.assets.files
64
+ assert files['/css/screen.css'] =~ /app\/css\/screen.sass/
65
+ assert files['/js/hi.js'] =~ /app\/js\/hi.coffee/
66
+ end
67
+
68
+ test "helpers" do
69
+ get '/index.html'
70
+ assert body =~ /<script src='\/js\/hello.[0-9]+.js'><\/script>/
71
+ assert body =~ /<script src='\/js\/hi.[0-9]+.js'><\/script>/
72
+ end
73
+
74
+ test "helpers in production (compressed html thingie)" do
75
+ app.expects(:production?).returns(true)
76
+ get '/index.html'
77
+ assert body =~ /<script src='\/js\/app.[0-9]+.js'><\/script>/
78
+ end
79
+
80
+ test "compressed js" do
81
+ get '/js/app.js'
82
+ assert body.include? 'function(){alert("Hello");'
83
+ assert_includes body, "var x;x=function(){"
84
+ end
85
+
86
+ test "compressed js with cache bust" do
87
+ get '/js/app.38987.js'
88
+ assert body.include? 'function(){alert("Hello");'
89
+ assert_includes body, "var x;x=function(){"
90
+ end
91
+
92
+ test "compressed css" do
93
+ get '/css/application.css'
94
+ assert_includes body, "rgba(0,0,255,0.3)"
95
+ end
96
+
97
+ test "compressed css with cache bust" do
98
+ get '/css/application.388783.css'
99
+ assert_includes body, "rgba(0,0,255,0.3)"
100
+ end
101
+
102
+ test "helpers css" do
103
+ get '/helpers/css'
104
+ assert body =~ %r{link rel='stylesheet' href='/css/screen.[0-9]+.css' media='screen'}
105
+ end
106
+ end
data/test/yui_test.rb ADDED
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class YuiTest < UnitTest
4
+ setup do
5
+ app.set :reload_templates, true
6
+ app.assets.js_compression = :yui
7
+ app.assets.css_compression = :yui
8
+ end
9
+
10
+ teardown do
11
+ app.assets.js_compression = :jsmin
12
+ app.assets.css_compression = :simple
13
+ end
14
+
15
+ test "build" do
16
+ require 'yui/compressor'
17
+ YUI::JavaScriptCompressor.any_instance.expects(:compress).returns "LOL"
18
+
19
+ get '/js/app.js'
20
+ assert body == "LOL"
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,341 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sundawg-sinatra-assetpack-fork
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.12.pre1
5
+ prerelease: 7
6
+ platform: ruby
7
+ authors:
8
+ - Rico Sta. Cruz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tilt
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: sinatra
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jsmin
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yui-compressor
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sass
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: haml
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: coffee-script
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: contest
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: mocha
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: stylus
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: uglifier
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ description: Package your assets for Sinatra.
207
+ email:
208
+ - rico@sinefunc.com
209
+ executables: []
210
+ extensions: []
211
+ extra_rdoc_files: []
212
+ files:
213
+ - .gitignore
214
+ - Gemfile
215
+ - HISTORY.md
216
+ - README.md
217
+ - Rakefile
218
+ - docsrc/style.css
219
+ - examples/basic/.gitignore
220
+ - examples/basic/Rakefile
221
+ - examples/basic/app.rb
222
+ - examples/basic/app/css/test.sass
223
+ - examples/basic/app/images/icon.png
224
+ - examples/basic/app/js/app.js
225
+ - examples/basic/app/js/vendor/jquery.js
226
+ - examples/basic/app/js/vendor/jquery.plugin.js
227
+ - examples/basic/app/js/vendor/underscore.js
228
+ - examples/basic/views/index.erb
229
+ - examples/classic/app.rb
230
+ - examples/classic/css/screen.scss
231
+ - examples/compass/.gitignore
232
+ - examples/compass/Rakefile
233
+ - examples/compass/app.rb
234
+ - examples/compass/app/css/main.scss
235
+ - examples/compass/app/images/icon-scfd8d7d404.png
236
+ - examples/compass/app/images/icon/mail.png
237
+ - examples/compass/app/images/icon/refresh.png
238
+ - examples/compass/app/images/junk/mail.png
239
+ - examples/compass/app/images/junk/refresh.png
240
+ - examples/compass/app/js/app.js
241
+ - examples/compass/app/js/vendor/jquery.js
242
+ - examples/compass/app/js/vendor/jquery.plugin.js
243
+ - examples/compass/app/js/vendor/underscore.js
244
+ - examples/compass/config.ru
245
+ - examples/compass/views/index.erb
246
+ - lib/sinatra/assetpack.rb
247
+ - lib/sinatra/assetpack/buster_helpers.rb
248
+ - lib/sinatra/assetpack/class_methods.rb
249
+ - lib/sinatra/assetpack/compressor.rb
250
+ - lib/sinatra/assetpack/configurator.rb
251
+ - lib/sinatra/assetpack/css.rb
252
+ - lib/sinatra/assetpack/engine.rb
253
+ - lib/sinatra/assetpack/engines/closure.rb
254
+ - lib/sinatra/assetpack/engines/jsmin.rb
255
+ - lib/sinatra/assetpack/engines/sass.rb
256
+ - lib/sinatra/assetpack/engines/simple.rb
257
+ - lib/sinatra/assetpack/engines/sqwish.rb
258
+ - lib/sinatra/assetpack/engines/uglify.rb
259
+ - lib/sinatra/assetpack/engines/yui.rb
260
+ - lib/sinatra/assetpack/hasharray.rb
261
+ - lib/sinatra/assetpack/helpers.rb
262
+ - lib/sinatra/assetpack/html_helpers.rb
263
+ - lib/sinatra/assetpack/image.rb
264
+ - lib/sinatra/assetpack/options.rb
265
+ - lib/sinatra/assetpack/package.rb
266
+ - lib/sinatra/assetpack/rake.rb
267
+ - lib/sinatra/assetpack/version.rb
268
+ - sinatra-assetpack.gemspec
269
+ - test/app/.gitignore
270
+ - test/app/Rakefile
271
+ - test/app/app.rb
272
+ - test/app/app/css/behavior.htc
273
+ - test/app/app/css/js2c.css
274
+ - test/app/app/css/screen.sass
275
+ - test/app/app/css/sqwishable.css
276
+ - test/app/app/css/style.css
277
+ - test/app/app/css/stylus.styl
278
+ - test/app/app/css_stylus/stylus.styl
279
+ - test/app/app/images/background.jpg
280
+ - test/app/app/images/email.png
281
+ - test/app/app/js/_ignoreme.js
282
+ - test/app/app/js/hello.2.js
283
+ - test/app/app/js/hello.js
284
+ - test/app/app/js/helloe.js
285
+ - test/app/app/js/hi.coffee
286
+ - test/app/app/js/ugly.js
287
+ - test/app/app/js/yoe.coffee
288
+ - test/app/app/js_glob/a/b/c1/hello.js
289
+ - test/app/app/js_glob/a/b/c2/hi.js
290
+ - test/app/app/js_glob/a/b/c2/hola.js
291
+ - test/app/app/views/index.haml
292
+ - test/arity_test.rb
293
+ - test/build_test.rb
294
+ - test/cache_test.rb
295
+ - test/combined_test.rb
296
+ - test/compressed_test.rb
297
+ - test/glob_test.rb
298
+ - test/helpers_test.rb
299
+ - test/ignore_test.rb
300
+ - test/img_test.rb
301
+ - test/local_file_test.rb
302
+ - test/mime_type_test.rb
303
+ - test/non_existent_test.rb
304
+ - test/options_test.rb
305
+ - test/order_test.rb
306
+ - test/preproc_test.rb
307
+ - test/redundant_test.rb
308
+ - test/simplecss_test.rb
309
+ - test/sqwish_test.rb
310
+ - test/stylus_test.rb
311
+ - test/template_cache_test.rb
312
+ - test/test_helper.rb
313
+ - test/tilt_test.rb
314
+ - test/uglifier_test.rb
315
+ - test/unit_test.rb
316
+ - test/yui_test.rb
317
+ homepage: http://github.com/rstacruz/sinatra-assetpack
318
+ licenses: []
319
+ post_install_message:
320
+ rdoc_options: []
321
+ require_paths:
322
+ - lib
323
+ required_ruby_version: !ruby/object:Gem::Requirement
324
+ none: false
325
+ requirements:
326
+ - - ! '>='
327
+ - !ruby/object:Gem::Version
328
+ version: '0'
329
+ required_rubygems_version: !ruby/object:Gem::Requirement
330
+ none: false
331
+ requirements:
332
+ - - ! '>'
333
+ - !ruby/object:Gem::Version
334
+ version: 1.3.1
335
+ requirements: []
336
+ rubyforge_project:
337
+ rubygems_version: 1.8.24
338
+ signing_key:
339
+ specification_version: 3
340
+ summary: Asset packager for Sinatra.
341
+ test_files: []