ruby – 设置rake-pipeline以与Google App Engine一起使用

前端之家收集整理的这篇文章主要介绍了ruby – 设置rake-pipeline以与Google App Engine一起使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以这就是我正在尝试做的事情.我正在构建一个ember.js应用程序,在GAE上运行 java后端.

我正在使用把手,但我希望它们分成单独的文件,而不是全部粘贴到index.html中.

通过ember.js irc,我和minispade一起打开了rake-pipeline

随着web filters自定义handlebars filter,我开始构建资产文件.我不知道Ruby,或者gem文件等.

因此,我试图找出能够动态编译我的coffeescript / handlebars文件的最佳方法,minispade它们,但在开发模式下保持各个文件可访问,以便我可以调试它们.令人困难的是,rake管道运行在与GAE不同的端口上.所以我不确定如何处理这个问题.在开发期间,我是否将GAE中的索引文件指向9292端口(rakep)中的单个文件,但是在生产模式下是否指向完全连接的版本?我不确定.

所以我试图在这里做到这一点:https://gist.github.com/1495740只有一个由’build’标志触发的部分.甚至不确定这是否有效.

我知道这里有很多混乱.道歉,就像我说的那样,我甚至不熟悉Ruby的做事方式.

解决方法

Rake :: Pipeline.build是评估Assetfile的方法.您可以想象整个Assetfile都包含在Rake :: Pipeline.build {}块中;你不应该在Assetfile中写一个.

文档中的一些过滤器是假设的,大多数文档都是在有任何过滤器之前编写的.不过最近添加了CoffeeScript编译器.

至于你的主要问题,我不确定用当前的rakep实现做一个干净的方法.但是,Assetfile只是Ruby,所以可以将一些应该起作用的东西放在一起.这是我写你的方式:

  1. require "json"
  2. require "rake-pipeline-web-filters"
  3. require "rake-pipeline-web-filters/helpers"
  4.  
  5. class HandlebarsFilter < Rake::Pipeline::Filter
  6. def initialize(&block)
  7. block ||= proc { |input| input.sub(/\.handlebars$/,'.js') }
  8. super(&block)
  9. end
  10.  
  11. def generate_output(inputs,output)
  12. inputs.each do |input|
  13. output.write "return Ember.Handlebars.compile(#{input.read.to_json})"
  14. end
  15. end
  16. end
  17.  
  18. # process all js,css and html files in app/assets
  19. input "assets"
  20.  
  21. # processed files should be outputted to public
  22. output "public"
  23.  
  24. # process all coffee files
  25. match "**/*.coffee" do
  26. # compile all CoffeeScript files. the output file
  27. # for the compilation should be the input name
  28. # with the .coffee extension replaced with .js
  29. coffee_script
  30.  
  31. # The coffee_script helper is exactly equivalent to:
  32. # filter Rake::Pipeline::Web::Filters::CoffeeScriptCompiler
  33. end
  34.  
  35. match "**/*.js" do
  36. minispade
  37. if ENV['RAKEP_ENV'] == "production"
  38. concat "application.js"
  39. else
  40. concat
  41. end
  42. end
  43.  
  44. match "**/*.handlebars" do
  45. filter HandlebarsFilter
  46. minispade
  47. concat "templates.js"
  48. end

if ENV [‘RAKEP_ENV’]位读取环境变量以决定是否将JS连接到单个文件.

所以现在你可以为连接版本运行RAKEP_ENV =“production”rakep构建,或者只为开发构建运行rakep构建.

猜你在找的Ruby相关文章