Permalink
Browse files

Rails 2 and 3 Integration

  • Loading branch information...
1 parent 105c571 commit 2580cd819607e3a4f766e46c006c34e6c62e4b50 Peter Wagenet committed Nov 26, 2011
Showing with 31 additions and 0 deletions.
  1. +7 −0 lib/rake-pipeline.rb
  2. +8 −0 lib/rake-pipeline/rails_plugin.rb
  3. +14 −0 lib/rake-pipeline/railtie.rb
  4. +2 −0 rails/init.rb
View
7 lib/rake-pipeline.rb
@@ -4,6 +4,13 @@
require "rake-pipeline/dsl"
require "rake-pipeline/matcher"
require "rake-pipeline/error"
+
+if defined?(Rails::Railtie)
+ require "rake-pipeline/railtie"
+elsif defined?(Rails)
+ require "rake-pipeline/rails_plugin"
+end
+
require "thread"
# Use the Rake namespace
View
8 lib/rake-pipeline/rails_plugin.rb
@@ -0,0 +1,8 @@
+require 'rake-pipeline/middleware'
+
+Rails.configuration.after_initialize do
+ if defined?(RAKEP_ENABLED) && RAKEP_ENABLED
+ assetfile = defined?(RAKEP_ASSETFILE) ? RAKEP_ASSETFILE : 'Assetfile'
+ Rails.configuration.middleware.use(Rake::Pipeline::Middleware, assetfile)
+ end
+end
View
14 lib/rake-pipeline/railtie.rb
@@ -0,0 +1,14 @@
+module Rake
+ class Pipeline
+ class Railtie < ::Rails::Railtie
+ config.rake_pipeline_enabled = false
+ config.rake_pipeline_assetfile = File.join(RAILS_ROOT, 'Assetfile')
+
+ initializer do |app|
+ if config.rake_pipeline_enabled
+ config.middleware.use(Rake::Pipeline::Middleware, config.rake_pipeline_assetfile)
+ end
+ end
+ end
+ end
+end
View
2 rails/init.rb
@@ -0,0 +1,2 @@
+# For Rails 2
+require 'rake-pipeline'

0 comments on commit 2580cd8

Please sign in to comment.