weld 0.0.1.dev.20100404 → 0.0.1.dev.20100408

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,27 @@
2
2
  # This is a simple (but complete) example of a Weld config file.
3
3
  #
4
4
  ---
5
+
6
+ # Weld can automatically push files to a CDN. Currently, Amazon S3 support is
7
+ # built in.
8
+ cdn:
9
+ type: s3
10
+ options:
11
+ access_key_id: 'abc'
12
+ secret_access_key: '123'
13
+
14
+ bucket: my-amazon-s3-bucket
15
+
16
+ gzip: true
17
+
18
+ prefix:
19
+ css: css/
20
+ js: js/
21
+
22
+ url_base: 'http://my-amazon-s3-bucket.s3.amazonaws.com/'
23
+
24
+ # Weld has built in support for YUI Compressor (CSS and JS) and Google Closure
25
+ # Compiler (JS only), although you'll need to provide your own jars.
5
26
  compressors:
6
27
  css:
7
28
  name: yui
@@ -13,10 +34,28 @@ compressors:
13
34
  options:
14
35
  jar: /usr/local/bin/yuicompressor.jar
15
36
 
37
+ # js:
38
+ # name: closure
39
+ # options:
40
+ # jar: /usr/local/bin/compiler.jar
41
+
42
+ # List of local paths that should be searched (in order) for CSS and JS files
43
+ # referenced by components.
16
44
  sourcePaths:
17
45
  - ../public/js
18
46
  - ../public/css
19
47
 
48
+ # A component is just a group of CSS and/or JS files, which may exist either on
49
+ # the local filesystem or at a remote URL. Components can require other
50
+ # components, which allows you to create a modular dependency hierarchy.
51
+ #
52
+ # During development, the Weld Sinatra app can be used (and easily mixed into
53
+ # your own Rack apps) to serve concatenated components in real-time, either
54
+ # compressed or uncompressed, for fast and easy development and debugging.
55
+ #
56
+ # When you're ready to do a production release, the Weld command-line tool will
57
+ # concatenate, compress, and optionally push one or more components to a CDN in
58
+ # a single step.
20
59
  components:
21
60
  yui-3.1.0:
22
61
  js:
@@ -1,7 +1,8 @@
1
1
  require 'open3'
2
2
 
3
3
  class Weld::Compressor
4
- autoload :Yui, 'weld/compressor/yui'
4
+ autoload :Closure, 'weld/compressor/closure'
5
+ autoload :Yui, 'weld/compressor/yui'
5
6
 
6
7
  attr_reader :options, :type
7
8
 
@@ -0,0 +1,25 @@
1
+ class Weld::Compressor::Closure < Weld::Compressor
2
+ def initialize(type, options = {})
3
+ super(type, options)
4
+
5
+ @args = options['args'] || []
6
+
7
+ raise Weld::CompressorError, "Closure Compiler currently only supports JavaScript" unless @type == :js
8
+ raise Weld::CompressorError, "Closure Compiler jar file not specified" unless @options['jar']
9
+ raise Weld::CompressorError, "Closure Compiler jar file not found: #{@options['jar']}" unless File.exist?(@options['jar'])
10
+ end
11
+
12
+ def compress(input)
13
+ args = @args.empty? ? '' : " #{@args.join(' ')}"
14
+
15
+ Open3.popen3("java -jar '#{@options['jar']}'#{args}") do |stdin, stdout, stderr|
16
+ stdin.write(input)
17
+ stdin.close
18
+
19
+ stdout.read
20
+ # TODO: read stderr
21
+ # FIXME: Closure Compiler hangs for some reason and doesn't seem to close
22
+ # the output stream when using --compilation_level ADVANCED_OPTIMIZATIONS.
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
1
  class Weld
2
2
  APP_NAME = 'Weld'
3
- APP_VERSION = '0.0.1.dev.20100404'
3
+ APP_VERSION = '0.0.1.dev.20100408'
4
4
  APP_AUTHOR = 'Ryan Grove'
5
5
  APP_EMAIL = 'ryan@wonko.com'
6
6
  APP_URL = 'http://wonko.com/'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.dev.20100404
4
+ version: 0.0.1.dev.20100408
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-04 00:00:00 -07:00
12
+ date: 2010-04-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -60,6 +60,7 @@ files:
60
60
  - lib/weld/cdn.rb
61
61
  - lib/weld/cli.rb
62
62
  - lib/weld/component.rb
63
+ - lib/weld/compressor/closure.rb
63
64
  - lib/weld/compressor/yui.rb
64
65
  - lib/weld/compressor.rb
65
66
  - lib/weld/server.rb