2

私はルビーの人間ではなく、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を実行すると、最初は正常に動作しますが、2回目は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プロジェクトで使用されているため、当時、これが問題であることに誰も気づいていなかったと思います。この問題はマスターブランチで修正されていることがわかりますが、新しいgemバージョンはまだリリースされていません。

それまでの間、次のコードをAssetfileに(入力と出力の前に)追加できます。これにより、フィルターが実行される前にtmpディレクトリが削除されます。これは、入力が変更されたかどうかに関係なく、入力が毎回フィルタリングされることを意味するため、一時的な修正にすぎませんが、危険な日時解析の必要性を否定します。

require 'fileutils'
FileUtils.rm_rf 'tmp'

注意してくださいrm_rf!tmpディレクトリだけを指していることを確認してください。

Re:ファイルを並べ替えます。問題の詳細はわかりませんが、この例が役立つ場合があります。

于 2012-11-09T17:27:56.927 に答える