Permalink
Browse files

switch to new rails engine conventions

  • Loading branch information...
1 parent e762aee commit 8c74e93ea77eddb54634379a2c467567d9fce62d @citrus committed Mar 9, 2012
@@ -2,39 +2,12 @@ module SpreeRedirects
module Generators
class InstallGenerator < Rails::Generators::Base
- include Rails::Generators::Migration
-
- def self.count
- @count ||= 0
- (@count += 1) * 3
- end
-
- def self.new_migration_number
- (Time.new.utc + self.count).strftime("%Y%m%d%H%M%S")
- end
-
- def self.next_migration_number(path)
- @time ||= Time.new.utc
- if ActiveRecord::Base.timestamped_migrations
- files = Dir.entries(Rails.root.join("db/migrate"))
- migration = new_migration_number
- while files.join.include?(migration)
- migration = new_migration_number
- end
- migration
- else
- "%.3d" % (current_migration_number(dirname) + 1)
- end
- end
-
- desc "Installs required migrations for spree_essentials"
- source_root File.expand_path("../../templates", __FILE__)
+ desc "Installs required migrations for spree_redirects"
def copy_migrations
- migration_template "db/migrate/create_redirects.rb", "db/migrate/create_redirects.rb"
- migration_template "db/migrate/add_spree_namespace_to_redirects.rb", "db/migrate/add_spree_namespace_to_redirects.rb"
+ rake "spree_redirects:install:migrations"
end
end
end
-end
+end
View
@@ -1,26 +1,8 @@
-require 'spree_core'
-require 'spree_redirects/redirect_middleware'
+require "spree_core"
-module SpreeRedirects
-
- class Engine < Rails::Engine
-
- initializer "redirect middleware" do |app|
- app.middleware.insert_after ::Rack::Lock, ::SpreeRedirects::RedirectMiddleware
- end
-
- config.to_prepare do
- #loads application's model / class decorators
- Dir.glob File.expand_path("../../app/**/*_decorator.rb", __FILE__) do |c|
- Rails.configuration.cache_classes ? require(c) : load(c)
- end
-
- #loads application's deface view overrides
- Dir.glob File.expand_path("../../app/overrides/*.rb", __FILE__) do |c|
- Rails.application.config.cache_classes ? require(c) : load(c)
- end
- end
-
- end
+require "spree_redirects/version"
+require "spree_redirects/engine"
+require "spree_redirects/redirect_middleware"
+module SpreeRedirects
end
@@ -0,0 +1,23 @@
+module SpreeRedirects
+ class Engine < Rails::Engine
+
+ engine_name "spree_redirects"
+
+ initializer "redirect middleware" do |app|
+ app.middleware.insert_after ::Rack::Lock, ::SpreeRedirects::RedirectMiddleware
+ end
+
+ config.to_prepare do
+
+ Dir.glob File.expand_path("../../../app/**/*_decorator.rb", __FILE__) do |c|
+ Rails.configuration.cache_classes ? require(c) : load(c)
+ end
+
+ Dir.glob File.expand_path("../../../app/overrides/**/*.rb", __FILE__) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
+
+ end
+
+ end
+end

0 comments on commit 8c74e93

Please sign in to comment.