zassets 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +390 -39
  3. data/lib/zassets/config.rb +18 -5
  4. data/lib/zassets/version.rb +1 -1
  5. metadata +62 -136
  6. data/.gitignore +0 -3
  7. data/Gemfile +0 -5
  8. data/Guardfile +0 -12
  9. data/LICENSE +0 -23
  10. data/Rakefile +0 -7
  11. data/features/builder/build.feature +0 -14
  12. data/features/builder/manifest.feature +0 -13
  13. data/features/cli/default_action.feature +0 -5
  14. data/features/cli/usage.feature +0 -8
  15. data/features/cli/version.feature +0 -5
  16. data/features/config/file.feature +0 -10
  17. data/features/config/paths.feature +0 -11
  18. data/features/engines/coffee.feature +0 -16
  19. data/features/engines/sass.feature +0 -28
  20. data/features/server/handler.feature +0 -13
  21. data/features/server/interrupt.feature +0 -6
  22. data/features/server/logging.feature +0 -7
  23. data/features/server/public_file.feature +0 -18
  24. data/features/server/static_files.feature +0 -15
  25. data/features/step_definitions/builder_steps.rb +0 -41
  26. data/features/step_definitions/config_steps.rb +0 -8
  27. data/features/step_definitions/manifest_steps.rb +0 -7
  28. data/features/step_definitions/server_steps.rb +0 -49
  29. data/features/support/env.rb +0 -3
  30. data/features/support/env_aruba.rb +0 -16
  31. data/features/support/env_cucumber-doc_string.rb +0 -23
  32. data/features/support/env_server.rb +0 -91
  33. data/spec/fixtures/assets/app.js +0 -1
  34. data/spec/fixtures/config/zassets.yaml +0 -1
  35. data/spec/fixtures/public/hello.txt +0 -1
  36. data/spec/fixtures/public/index.html +0 -1
  37. data/spec/spec_helper.rb +0 -3
  38. data/spec/support/fixtures_helpers.rb +0 -13
  39. data/spec/zassets-plugins-dummy.rb +0 -17
  40. data/spec/zassets/builder_spec.rb +0 -52
  41. data/spec/zassets/cli_spec.rb +0 -158
  42. data/spec/zassets/config_spec.rb +0 -139
  43. data/spec/zassets/memory_file_spec.rb +0 -46
  44. data/spec/zassets/server_spec.rb +0 -116
  45. data/spec/zassets/sprockets_env_spec.rb +0 -44
  46. data/zassets.gemspec +0 -30
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9421970023ad39c50fb8a99f629d785bbc533c9c
4
+ data.tar.gz: f1cace0edd78cb8ff5c69015bed2e77420a4ebba
5
+ SHA512:
6
+ metadata.gz: bf2e2633ca8c88072fe75a947567e0d74629dd795b188926d989d1bed74164840b2bef59787f47090c17b39c7a39bb41aa777ba4fc07b28646693ef226276861
7
+ data.tar.gz: bfb190309287aaad0625320b700ef422cb1282d463d69bff0392b32d68e3f663ec1f5b94c2381fc16a431c930809e28c403d690ac0cd4c51089bc101bbe03969
data/README.md CHANGED
@@ -1,59 +1,410 @@
1
- z'assets - standalone asset pipeline
1
+ z'assets - Assets server and builder
2
2
  ====================================
3
3
 
4
- z'assets is a tool based on [Sprockets][] for serving and building
5
- web assets. When serving over HTTP (intended for a development
6
- environment), transpilation through various preprocessors will happen on
7
- the fly. For production environment all specified assets are built as
8
- files in a directory tree similar to their sources, except filenames
9
- will include a hash to help caching.
4
+ zassets is both a server and a simple build tool for static web
5
+ sites. Assets are piped through various preprocessors or templating
6
+ engines (ERB, CoffeeScript, Sass…). A simple declarative dependency
7
+ management is also available, based on keywords you can include in
8
+ source files.
9
+
10
+ It is best suited for the development of single page applications:
11
+ either using the built-in HTTP daemon as a development environment, or
12
+ building your application as static files in a common directory, ready
13
+ to be rsynced to a production server.
14
+
15
+ Most of those behaviors will be very similar to Ruby on Rails "asset
16
+ pipeline", Sprockets, which is used internally.
17
+
18
+
19
+ Getting started
20
+ ---------------
21
+
22
+ ### Installation (need ruby and rubygems)
23
+
24
+ $ gem install zassets
25
+
26
+
27
+ ### Application template following zassets conventions
28
+
29
+ Create a basic application:
30
+
31
+ ``` sh
32
+ $ mkdir ~/tmp/my_app
33
+ $ cd ~/tmp/my_app # your app root directory
34
+ $ mkdir app # `app' is part of the load path
35
+ $ cat << 'EOH' > app/hello.coffee
36
+ console.log 'hello from my app!'
37
+ EOH
38
+ ```
39
+
40
+ `app` directory is the default load path, but this behavior is
41
+ configurable. Any asset in the load path might be submitted to
42
+ appropriate processors then served or built.
43
+
44
+
45
+ ### Serving your application
46
+
47
+ ``` sh
48
+ $ zassets serve
49
+ Puma 2.6.0 starting... # Rack handler is configurable
50
+ * Min threads: 0, max threads: 16
51
+ * Environment: development
52
+ * Listening on tcp://::1:9292
53
+ ```
54
+
55
+ Observe that CoffeeScript source is transpiled to JavaScript:
56
+
57
+ ``` sh
58
+ $ curl http://localhost:9292/assets/hello.js | head -n 2
59
+ (function() {
60
+ console.log('hello from my app!');
61
+ ```
62
+
63
+
64
+ ### Building and packaging your application
65
+
66
+ You need to specify the files you want to be built in a config file:
67
+
68
+ ``` sh
69
+ $ mkdir config
70
+ $ cat << 'EOH' > config/zassets.yaml
71
+ build: hello.js
72
+ EOH
73
+ $ zassets
74
+ $ ls -1 public/assets
75
+ hello-3297995eead5225d053fb06facd15d3a.js
76
+ hello-3297995eead5225d053fb06facd15d3a.js.gz
77
+ manifest.json
78
+ $ head -n 2 public/assets/hello-3297995eead5225d053fb06facd15d3a.js
79
+ (function() {
80
+ console.log('hello from my app!');
81
+ ```
82
+
83
+ `zassets` command is equivalent to `zassets build`, it will build
84
+ all files listed in the `build:` configuration key into
85
+ `public/assets` directory. A manifest in JSON format will also be
86
+ written in `public/assets/manifest.json` file.
87
+
88
+
89
+ ### Command line usage
90
+
91
+ ```
92
+ Usage: zassets [options] [build|serve]
93
+ -v, --verbose Enable verbose mode
94
+ -c, --config FILE Load default options from FILE
95
+ -o, --host HOST Listen on HOST (default: ::1)
96
+ -p, --port PORT Listen on PORT (default: 9292)
97
+ -s, --server SERVER Use SERVER as Rack handler
98
+ -h, --help Show this message
99
+ -V, --version Show version
100
+ ```
101
+
102
+
103
+ Internals overview
104
+ ------------------
105
+
106
+ Internally, zassets uses [Sprockets][] which provides most of the
107
+ current features, along with [Rack][]. zassets server will mount both
108
+ the Rack application provided by Sprockets and its own Rack
109
+ application, used for logging, error reporting and serving static
110
+ files.
111
+
112
+ Sprockets is again used when building assets, including
113
+ "fingerprinting" the built assets (inserting a computed hash in the
114
+ file name), which can be relied on to improve some HTTP caching
115
+ behaviors.
10
116
 
11
117
  [Sprockets]: https://github.com/sstephenson/sprockets
118
+ [Rack]: http://rack.github.io/
119
+
120
+
121
+ Configuration
122
+ -------------
123
+
124
+ Some options are available from the command line, but most can only
125
+ be modified by the use of a configuration file. By default zassets
126
+ will try to read a file named `config/zassets.yaml`.
127
+
128
+ An additional specific configuration file can be specified with the
129
+ `-c` argument, it will be loaded after an eventual
130
+ `config/zassets.yaml` file.
131
+
132
+
133
+ ### Extensive configuration file example with comments
134
+
135
+ For accurate and up to date details, read `lib/zassets/config.rb`
136
+ source file.
137
+
138
+ ``` yaml
139
+ # Enable verbose mode.
140
+ verbose: true
141
+
142
+ # List of plugins to load on startup.
143
+ plugins:
144
+ - haml_coffee
145
+
146
+ # Bind server socket to localhost and listen on port 8000.
147
+ host: localhost
148
+ port: 8000
149
+
150
+ # Change rack handler (HTTP server) to unicorn (default is puma).
151
+ server: unicorn
152
+
153
+ # List of directories where assets will be searched for (load
154
+ # path).
155
+ paths:
156
+ - app
157
+ - vendor
158
+
159
+ # Path to a file served when no resource is found (catch all).
160
+ public_file: index.html
161
+
162
+ # URI path where sprockets rack application is mounted at.
163
+ base_url: /assets
164
+
165
+ # Path used as root directory when serving static files.
166
+ public_path: public
167
+
168
+ # Path used as output directory when building assets.
169
+ build_path: public/assets
170
+
171
+ # List of file paths specifying which files are part of the build.
172
+ build:
173
+ - app.js
174
+ - styles/main.css
175
+ ```
176
+
177
+
178
+ Engines
179
+ -------
180
+
181
+ "Engines" are preprocessors, transpilers, template languages… Some
182
+ are provided by Sprockets, and its ecosystem can provide a lot more.
183
+ zassets core will focus on CoffeeScript and Sass, but other engines
184
+ are available as plugins:
185
+
186
+ * [Haml Coffee][]
187
+ * [Emblem.js][]
188
+ * [Handlebars][]
189
+ * [LESS][] (Sprockets LESS engine will handle @import rules by querying
190
+ assets "logical path", not relative path as it would be the case
191
+ in classic LESS stylesheets, the plugin implement some
192
+ workarounds). See:
193
+ https://github.com/sstephenson/sprockets/pull/323
194
+
195
+
196
+ More details in Sprockets README:
197
+ https://github.com/sstephenson/sprockets#using-engines
198
+
199
+ [Haml Coffee]: https://rubygems.org/gems/zassets-plugins-haml_coffee
200
+ [Emblem.js]: https://rubygems.org/gems/zassets-plugins-emblem
201
+ [Handlebars]: https://rubygems.org/gems/zassets-plugins-handlebars
202
+ [LESS]: https://rubygems.org/gems/zassets-plugins-less
203
+
204
+
205
+ JavaScript templating
206
+ ---------------------
207
+
208
+ FIXME: JST
209
+
210
+
211
+ More details in Sprockets README:
212
+ https://github.com/sstephenson/sprockets#javascript-templating-with-ejs-and-eco
213
+
214
+
215
+ Dependency management
216
+ ---------------------
217
+
218
+ Sprockets includes a "directive processor", allowing you to require
219
+ and manage your dependencies by placing special comments interpreted
220
+ by Sprockets as keywords.
221
+
222
+ CoffeeScript example:
223
+
224
+ ``` coffeescript
225
+ #= require jquery/jquery-1.9.1
226
+ #= require hamlcoffee
227
+ #= require underscore/underscore-1.4.4
228
+ #= require backbone/backbone-1.0.0
229
+
230
+ #= require_tree ./lib
231
+ #= require_tree ./templates
232
+ #= require_tree ./models
233
+ #= require_tree ./collections
234
+ #= require_tree ./views
235
+ #= require_self
236
+ ```
237
+
238
+
239
+ Javascript example:
240
+
241
+ ``` javascript
242
+ //= require jquery/jquery-1.9.1
243
+ ```
244
+
245
+
246
+ More details in Sprockets README:
247
+ https://github.com/sstephenson/sprockets#managing-and-bundling-dependencies
248
+
249
+
250
+ Manifest
251
+ --------
252
+
253
+ FIXME
254
+
255
+ ``` sh
256
+ $ ruby -rjson -e \
257
+ 'puts JSON.pretty_generate(JSON.parse($stdin.read))' \
258
+ < public/assets/manifest.json
259
+ {
260
+ "files": {
261
+ "hello-3297995eead5225d053fb06facd15d3a.js": {
262
+ "logical_path": "hello.js",
263
+ "mtime": "2013-11-28T23:11:04+00:00",
264
+ "size": 67,
265
+ "digest": "3297995eead5225d053fb06facd15d3a"
266
+ }
267
+ },
268
+ "assets": {
269
+ "hello.js": "hello-3297995eead5225d053fb06facd15d3a.js"
270
+ }
271
+ }
272
+ ```
273
+
274
+
275
+ Plugins
276
+ -------
277
+
278
+ FIXME
279
+
280
+
281
+ TODO
282
+ ----
283
+
284
+ * Implement testing API, both for cucumber and rspec. Should provide a
285
+ file to require for each framework, bringing instance methods,
286
+ cucumber steps and easy access to test fixtures.
287
+ possible use/inspiration:
288
+ https://github.com/smartlogic/http_spec
289
+
290
+ * Must warn/fail when a file listed in `build:` option is not built.
291
+
292
+ * Implement compression for some assets kind when appropriate (JS,
293
+ CSS).
294
+ https://github.com/jcoglan/packr (compress javascript)
295
+
296
+ * Add support for Haml templates.
297
+
298
+ * Implement helpers like `asset_path` or similar things from rails so
299
+ that we could include dynamic assets path via ERB or Haml template.
300
+ https://github.com/maccman/stylo/blob/master/app.rb#L23-40
301
+
302
+ * Help manage vendored files (installing, updating)
303
+ https://github.com/grosser/vendorer
304
+
305
+ * Check if we can optimize build process by porting code from:
306
+ https://github.com/ndbroadbent/turbo-sprockets-rails3
307
+ or with:
308
+ `sprocket_env.cache = Sprockets::Cache::FileStore.new '/tmp'`
309
+
310
+ * Consider implementing some support for JavaScript "modules"
311
+ packagers.
312
+ https://github.com/sstephenson/sprockets/issues/298
313
+ https://github.com/maccman/sprockets-commonjs
314
+
315
+ * Add a README section about integration in a non-ruby server runtime.
316
+
317
+
318
+ Similar/related code
319
+ --------------------
320
+
321
+ * https://github.com/sstephenson/sprockets
322
+ Sprockets: Rack-based asset packaging
323
+
324
+ * http://rack.github.io/
325
+ Rack: a Ruby Webserver Interface
326
+
327
+ * Sprockets contrib guide:
328
+ https://github.com/radar/guides/blob/56da5701c470442c3ab96a0005023117eae58777/sprockets.md
329
+
330
+ ### With features for static sites
331
+
332
+ * http://stasis.me/  
333
+ Stasis is a dynamic framework for static sites.
334
+
335
+ * http://mimosa.io/  
336
+ Loaded with what you need to start coding right away. Transpilers,
337
+ Pre-Processors, Micro-templates, RequireJS, Bower, Testing and more.
338
+
339
+ * http://brunch.io/  
340
+ Brunch is an assembler for HTML5 applications. It's agnostic to
341
+ frameworks, libraries, programming, stylesheet & templating
342
+ languages and backend technology.
343
+
344
+ * https://github.com/joliss/broccoli  
345
+ A fast, reliable asset pipeline, supporting constant-time rebuilds
346
+ and compact build definitions. Comparable to the Rails asset
347
+ pipeline in scope, though it runs on Node and is backend-agnostic.
348
+
349
+ ### Sprockets related
350
+
351
+ * https://github.com/petebrowne/machined  
352
+ A static site generator and Rack server built using Sprockets 2.0
353
+
354
+ * https://github.com/maccman/catapult  
355
+ Simple gem that gives pure JavaScript/CoffeeScript projects a basic
356
+ structure, and manages any necessary compilation and concatenation.
12
357
 
13
- Integration should be doable in any web application written in any
14
- language, provided that you can parse JSON.
358
+ ### Rack related
15
359
 
16
- Currently the following asset kinds are handled:
360
+ * https://github.com/jlong/serve  
361
+ Serve is a small Rack-based web server that makes it easy to serve
362
+ HTML, ERB, Haml, or a variety of template languages from any
363
+ directory.
17
364
 
18
- * JavaScript
19
- * CoffeeScript
20
- * CSS
21
- * LESS (with a modified version of tilt original less engine)
22
- * Static files
365
+ * https://github.com/Sutto/barista (transpile CoffeeScript)
23
366
 
367
+ ### Rake related
24
368
 
25
- Usage
26
- -----
369
+ * https://github.com/mcollina/rake-minify  
370
+ Rake Minify is an extremely simple solution for minifying javascript
371
+ and coffeescript files using a rake task.
27
372
 
28
- Create a `config/zassets.yaml` file in your application root
29
- directory:
373
+ ### Rails related
30
374
 
31
- base_url: '/assets'
32
- paths:
33
- - 'assets/styles'
34
- - 'assets/scripts'
35
- public_path: 'public'
36
- build_path: 'public/assets'
37
- build:
38
- - 'main.css'
375
+ * http://documentcloud.github.io/jammit/  
376
+ Jammit is an industrial strength asset packaging library for Rails,
377
+ providing both the CSS and JavaScript concatenation and compression
378
+ that you'd expect, as well as YUI Compressor, Closure Compiler, and
379
+ UglifyJS compatibility, ahead-of-time gzipping, built-in JavaScript
380
+ template support, and optional Data-URI / MHTML image and font
381
+ embedding.
39
382
 
40
- Then you can launch development HTTP server with the following
41
- command:
383
+ * https://github.com/d-i/half-pipe (ruby gem, uses nodejs/grunt)  
384
+ Gem to replace the Rails asset pipeline with a Grunt.js-based
385
+ workflow, providing dependencies via Bower.
42
386
 
43
- zassets serve
387
+ ### Sinatra related
44
388
 
45
- And build your assets:
389
+ * https://github.com/rstacruz/sinatra-assetpack  
390
+ The most convenient way to manage your assets in Sinatra.
46
391
 
47
- zassets build
392
+ ### Building and/or packaging
48
393
 
49
- You can override some config options using command line arguments,
50
- the complete list is printed on the standard output on
51
- `zassets --help`.
394
+ * http://winton.github.io/smart_asset/  
395
+ Smart asset packaging for Rails, Sinatra, and Stasis
52
396
 
397
+ * https://github.com/cjohansen/juicer  
398
+ Juicer is a command line tool that helps you ship frontend code for
399
+ production.
53
400
 
54
- Installation
55
- ------------
401
+ * https://github.com/jcoglan/jake  
402
+ Jake is a command-line line tool for building JavaScript packages
403
+ from source code. It’s basically a thin wrapper around Packr that
404
+ lets you easily configure builds for multiple packages with
405
+ different compression settings, using a simple YAML config file.
56
406
 
57
- Assuming you have a working rubygems installation:
407
+ ### Miscellaneous
58
408
 
59
- gem install zassets
409
+ * http://harpjs.com/  
410
+ The static web server with built-in preprocessing.