2

我不是一个 ruby​​ 人,我正在使用 Ember.js 开发一个项目,我正在使用 Rake 管道来编译我的脚本。

# AssetFile
$: << 'lib'

require 'rake-pipeline-web-filters'    

output BUILD
input SRC_DIR do
  match '**/*.handlebars' do
    handlebars :precompile => true
    concat 'templates.js'
  end

  match '**/*.coffee' do
    coffee_script
  end
end

output JS_DIR
input BUILD_DIR do
  match '*.js' do
    concat 'app.js'
  end
end

当我第一次在控制台上执行 rakep 时工作正常,但第二次出现const_missing错误

c:/Ruby193/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing': uninitialized constant Rake::Pipeline::ManifestEntry::DateTime (NameError)
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest_entry.rb:9:in `from_hash'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:24:in `block in read_manifest'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:23:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:23:in `read_manifest'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:225:in `last_manifest'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:219:in `create_file_task'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:197:in `block (2 levels) in generate_rake_tasks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:196:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:196:in `block in generate_rake_tasks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `map'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `generate_rake_tasks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:410:in `block in generate_rake_tasks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:407:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:407:in `generate_rake_tasks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:333:in `setup'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:308:in `block in invoke'
        from <internal:prelude>:10:in `synchronize'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:305:in `invoke'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:111:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:111:in `block in invoke'
        from <internal:prelude>:10:in `synchronize'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:110:in `invoke'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/cli.rb:19:in `build'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/bin/rakep:4:in `<top (required)>'
        from c:/Ruby193/bin/rakep:23:in `load'
        from c:/Ruby193/bin/rakep:23:in `<main>'

当我手动删除文件或让时间过去时,rakep 命令工作正常

注意:我也无法对要连接的文件进行排序

4

1 回答 1

3

我刚刚遇到了同样的问题。我正在使用 rake-pipeline 来缩小静态站点的样式表。

这里发生的是 rake-pipeline 正在尝试使用DateTime该类解析日期时间,但由于您不是在处理 Ruby 项目,因此该类不可用。我猜是因为 rake-pipeline 主要用于 Ruby 项目,所以当时没有人注意到这是一个问题。我可以看到这个问题已经在 master 分支上修复了,但是新的 gem 版本还没有发布。

同时,您可以将以下代码添加到您的 Assetfile(在您的输入和输出之前),这将在您的过滤器运行之前删除 tmp 目录。这只是一个临时修复,因为这意味着您的输入每次都会被过滤,无论它们是否已更改,但它确实不需要任何狡猾的日期时间解析。

require 'fileutils'
FileUtils.rm_rf 'tmp'

小心rm_rf!确保它指向您的 tmp 目录,而不是别的。

回复:对你的文件进行排序,我不知道你的问题的细节,但你可能会发现这个例子很有帮助。

于 2012-11-09T17:27:56.927 回答