Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

16 anos atrás
14 anos atrás
16 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
16 anos atrás
14 anos atrás
14 anos atrás
16 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
14 anos atrás
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 = 'spec/*_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 "Dojo", :location => "dojox/string"
  41. templated_build "YUI3", :location => "yui3/mustache"
  42. templated_build "RequireJS"
  43. templated_build "qooxdoo"
  44. task :minify do
  45. # npm install uglify-js
  46. mmjs = "mustache.min.js"
  47. `echo "/*! Version: 0.4.2 */" > #{mmjs}`
  48. `uglifyjs mustache.js >> #{mmjs}`
  49. puts "Created #{mmjs}"
  50. end