public
Description: Blender is like ant or make for the front-end. It aggregates and compresses CSS and/or JavaScript assets for a site into efficient, production-ready files.
Homepage: http://front-end-architect.lighthouseapp.com/projects/11475-blender/overview
Clone URL: git://github.com/front-end/front-end-blender.git
cgriego (author)
Tue Nov 25 15:27:55 -0800 2008
commit  7adc86ce9794a2e1cb15a83d0e467dc0ba203fd7
tree    2e24c1d5e2bbb2ecc5dae71564940aa3ef9b0aaf
parent  b20270b2a6ab391d45c1f25a29d471667db3c28c
100755 52 lines (42 sloc) 2.95 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
 
# Copyright (c) 2008 Blake Elshire, Chris Griego
#
# Blender is freely distributable under the terms of an MIT-style license.
# For details, see http://www.opensource.org/licenses/mit-license.php
 
$:.unshift File.join(File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__), *%w[.. lib])
require 'optparse'
require 'front_end_architect/blender'
 
options = {}
 
def section(opts, title)
  opts.separator ''
  opts.separator title + ':'
end
 
opts = OptionParser.new do |opts|
  version = "Front-End Blender v#{FrontEndArchitect::Blender::VERSION}"
  
  opts.on('-g', '--generate', String, "Generate a stub Blendfile") { options[:generate] = true }
  opts.on('-f FILE', '--file FILE', String, "Use specified Blendfile") {|f| options[:blendfile] = f }
  opts.on('-r ROOT', '--root ROOT', String, "Specify the path to the web root directory") {|r| options[:root] = r }
  opts.on('-t TYPE', '--type TYPE', [:css, :js], "Select file type to blend (css, js)") {|t| options[:file_type] = t }
  opts.on('-m [MINIFIER]', '--min [MINIFIER]', [:yui, :none], "Select minifier to use (yui, none)") {|m| options[:min] = m.nil? ? :none : m.to_sym }
  opts.on('-c [BUSTER]', '--cache-buster [BUSTER]', String, "Add cache busters to URLs in CSS") {|b| options[:cache_buster] = b.nil? ? :mtime : b }
  opts.on( '--force', String, "Don't allow output files to be skipped") { options[:force] = true }
  opts.on( '--yui=YUIOPTS', String, "Pass arguments to YUI Compressor") {|o| options[:yuiopts] = o }
  section opts, 'Experimental'
  opts.on('-d', '--data', String, "Convert url(file.ext) to url(data:) in CSS") { options[:data] = true }
  opts.on('-z', '--gzip', String, "Additionally generate gzipped output files") { options[:gzip] = true }
  section opts, 'Meta'
  opts.on('-h', '--help', "Show this message") { puts opts; exit 0 }
  opts.on('-V', '--version', "Show the version number") { puts version; exit 0 }
  
  opts.parse!(ARGV) rescue return false
end
 
begin
  blender = FrontEndArchitect::Blender.new(options)
  
  if (options[:generate])
    blender.generate
  else
    blender.blend
  end
rescue Exception => e
  puts e
  exit 1
end