Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 16 ans
il y a 14 ans
il y a 16 ans
il y a 14 ans
il y a 14 ans
il y a 14 ans
il y a 16 ans
il y a 14 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. require 'rake'
  2. require 'rake/clean'
  3. task :default => :test
  4. def minified_file
  5. ENV['FILE'] || 'mustache.min.js'
  6. end
  7. task :install_mocha do
  8. sh "npm install -g mocha" if `which mocha`.empty?
  9. end
  10. task :install_uglify do
  11. sh "npm install -g uglify-js" if `which uglifyjs`.empty?
  12. end
  13. task :install_jshint do
  14. sh "npm install -g jshint" if `which jshint`.empty?
  15. end
  16. desc "Run all tests"
  17. task :test => :install_mocha do
  18. sh "mocha test"
  19. end
  20. desc "Make a compressed build in #{minified_file}"
  21. task :minify => :install_uglify do
  22. sh "uglifyjs mustache.js > #{minified_file}"
  23. end
  24. desc "Run JSHint"
  25. task :hint => :install_jshint do
  26. sh "jshint mustache.js"
  27. end
  28. # Creates a task that uses the various template wrappers to make a wrapped
  29. # output file. There is some extra complexity because Dojo and YUI use
  30. # different final locations.
  31. def templated_build(name, final_location=nil)
  32. short = name.downcase
  33. source = File.join("wrappers", short)
  34. dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
  35. target_js = final_location.nil? ? "#{short}.mustache.js" : "mustache.js"
  36. desc "Package for #{name}"
  37. task short.to_sym => dependencies do
  38. puts "Packaging for #{name}"
  39. mkdir_p final_location unless final_location.nil?
  40. sources = [ "#{source}/mustache.js.pre", 'mustache.js', "#{source}/mustache.js.post" ]
  41. relative_name = "#{final_location || '.'}/#{target_js}"
  42. open(relative_name, 'w') do |f|
  43. sources.each {|source| f << File.read(source) }
  44. end
  45. puts "Done, see #{relative_name}"
  46. end
  47. CLEAN.include(final_location.nil? ? target_js : final_location)
  48. end
  49. templated_build "jQuery"
  50. templated_build "MooTools"
  51. templated_build "Dojo", "dojox/string"
  52. templated_build "YUI3", "yui3/mustache"
  53. templated_build "qooxdoo"