Repository URL to install this package:
|
Version:
0.4.2 ▾
|
module NeotericBlog
class UpgradeGenerator < Rails::Generators::Base
desc "Upgrades Neoteric Blog and generates the necessary migrations"
include Rails::Generators::Migration
def self.source_root
@_neoteric_blog_upgrade_source_root ||= File.expand_path("../templates", __FILE__)
end
def self.next_migration_number(dirname)
Time.now.strftime("%Y%m%d%H%M%S")
end
def copy_templates
copy_file "error_404.html.erb", "app/views/blog_posts/error_404.html.erb"
end
def create_migrations
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
name = File.basename(filepath)
migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
sleep 1
end
rake("db:migrate db:test:prepare")
end
end
end