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 年之前
14 年之前
16 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
16 年之前
14 年之前
14 年之前
16 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. require 'rake'
  2. require 'rake/clean'
  3. task :default => :spec
  4. desc "Run all specs"
  5. task :spec do
  6. require 'rspec/core/rake_task'
  7. RSpec::Core::RakeTask.new(:spec) do |t|
  8. #t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
  9. t.pattern = 'test/*_spec.rb'
  10. end
  11. end
  12. def version
  13. File.read("mustache.js").match('version: "([^\"]+)",$')[1]
  14. end
  15. # Creates a rule that uses the .tmpl.{pre,post} stuff to make a final,
  16. # wrapped, output file. There is some extra complexity because Dojo and YUI3
  17. # use different template files and final locations.
  18. def templated_build(name, opts={})
  19. short = name.downcase
  20. source = File.join("wrappers", short)
  21. dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
  22. target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
  23. CLEAN.include(opts[:location] ? opts[:location] : target_js)
  24. desc "Package for #{name}"
  25. task short.to_sym => dependencies do
  26. puts "Packaging for #{name}"
  27. mkdir_p opts[:location] if opts[:location]
  28. sh "cat #{source}/#{target_js}.tpl.pre mustache.js \
  29. #{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}"
  30. # extra
  31. if opts[:extra]
  32. sh "sed -e 's/{{version}}/#{version}/' #{source}/#{opts[:extra]} \
  33. > #{opts[:location]}/#{opts[:extra]}"
  34. end
  35. puts "Done, see #{opts[:location] || '.'}/#{target_js}"
  36. end
  37. end
  38. templated_build "CommonJS", :location => "lib", :extra => "package.json"
  39. templated_build "jQuery"
  40. templated_build "qooxdoo"
  41. templated_build "Dojo", :location => "dojox/string"
  42. templated_build "YUI3", :location => "yui3/mustache"
  43. templated_build "requirejs"