~caneypuggies/reformedchurcheslocator/couchapp-backbone

« back to all changes in this revision

Viewing changes to _attachments/js/vendor/mustache/Rakefile

  • Committer: Tim Black
  • Date: 2013-09-16 22:50:16 UTC
  • Revision ID: tim@alwaysreformed.com-20130916225016-zk8jiba25z33ew7h
Versioned Bower vendor directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'rake'
 
2
require 'rake/clean'
 
3
 
 
4
task :default => :test
 
5
 
 
6
ROOT = File.expand_path('..', __FILE__)
 
7
MUSTACHE_JS = File.read(File.join(ROOT, 'mustache.js'))
 
8
 
 
9
def mustache_version
 
10
  match = MUSTACHE_JS.match(/exports\.version = "([^"]+)";/)
 
11
  match[1]
 
12
end
 
13
 
 
14
def minified_file
 
15
  ENV['FILE'] || 'mustache.min.js'
 
16
end
 
17
 
 
18
desc "Run all tests, requires vows (see http://vowsjs.org)"
 
19
task :test do
 
20
  sh "vows --spec"
 
21
end
 
22
 
 
23
desc "Minify to #{minified_file}, requires UglifyJS (see http://marijnhaverbeke.nl/uglifyjs)"
 
24
task :minify do
 
25
  sh "uglifyjs mustache.js > #{minified_file}"
 
26
end
 
27
 
 
28
desc "Run JSHint, requires jshint (see http://www.jshint.com)"
 
29
task :lint do
 
30
  sh "jshint mustache.js"
 
31
end
 
32
 
 
33
# Creates a task that uses the various template wrappers to make a wrapped
 
34
# output file. There is some extra complexity because Dojo and YUI use
 
35
# different final locations.
 
36
def templated_build(name, opts={})
 
37
  short = name.downcase
 
38
  source = File.join("wrappers", short)
 
39
  dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
 
40
  target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
 
41
 
 
42
  CLEAN.include(opts[:location] ? opts[:location] : target_js)
 
43
 
 
44
  desc "Package for #{name}"
 
45
  task short.to_sym => dependencies do
 
46
    puts "Packaging for #{name}"
 
47
 
 
48
    mkdir_p opts[:location] if opts[:location]
 
49
 
 
50
    files = [
 
51
      "#{source}/mustache.js.pre",
 
52
      'mustache.js',
 
53
      "#{source}/mustache.js.post"
 
54
    ]
 
55
 
 
56
    open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
 
57
      files.each {|file| f << File.read(file) }
 
58
    end
 
59
 
 
60
    puts "Done, see #{opts[:location] || '.'}/#{target_js}"
 
61
  end
 
62
end
 
63
 
 
64
templated_build "jQuery"
 
65
templated_build "MooTools"
 
66
templated_build "Dojo", :location => "dojox/string"
 
67
templated_build "YUI3", :location => "yui3/mustache"
 
68
templated_build "qooxdoo"