You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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