Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
neoteric-blog / lib / generators / neoteric_blog / upgrade / upgrade_generator.rb
Size: Mime:
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