Skip to content

Instantly share code, notes, and snippets.

@henrypoydar
Created June 4, 2009 22:10
Show Gist options
  • Save henrypoydar/123881 to your computer and use it in GitHub Desktop.
Save henrypoydar/123881 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
#
# Simple deploy recipe to wrap up the moving parts
# of couchapp pushing based on .couchapprc settings,
# sprockets concatenation, jsmin compression and
# cssmin compression
#
require 'rubygems'
require 'sprockets'
require 'jsmin'
require 'cssmin'
#TODO - accept deploy environment arg, pass on to CouchApp
secretary = Sprockets::Secretary.new(
:asset_root => "_attachments",
:load_path => "lib/javascripts",
:source_files => [
"lib/javascripts/jquery-*.js",
"lib/javascripts/jquery.*.js",
lambda { Dir.glob('lib/javascripts/*[!application|controller]*.js') }.call, # Sprockets not cooperating ...
"lib/json_data/*.js",
"lib/javascripts/controller.js",
"lib/javascripts/application.js"
].flatten
)
puts ""
puts "Concatenating javascripts ..."
concatenation = secretary.concatenation
concatenation.save_to("_attachments/javascripts/concat.js")
secretary.install_assets
puts "Minifying javascripts ..."
File.open("_attachments/javascripts/build.js", 'w') { |file| file.write(JSMin.minify(concatenation.to_s)) }
puts "Minifying stylesheets ..."
Dir.glob("_attachments/stylesheets/*.css").each do |css|
f = ""
File.open(css, 'r') {|file| f << CSSMin.minify(file)}
File.open("_attachments/stylesheets/cache/#{File.basename(css)}", 'w') {|file| file.write(f)}
puts "Minified #{css}"
end
"Pushing up to CouchDB ..."
system "couchapp push"
puts "Deploy complete"
puts ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment