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-news / lib / generators / neoteric_news / install / install_generator.rb
Size: Mime:
module NeotericNews
  class InstallGenerator < Rails::Generators::Base
    include Rails::Generators::Migration
    source_root File.expand_path("../templates", __FILE__)

    def self.next_migration_number(dirname)
      Time.now.strftime("%Y%m%d%H%M%S")
    end

    def copy_templates
      copy_file "show.html.erb", "app/views/news_posts/show.html.erb"
      copy_file "index.html.erb", "app/views/news_posts/index.html.erb"
      copy_file "_news_post.html.erb", "app/views/news_posts/_news_post.html.erb"
      copy_file "news_posts_controller.rb", "app/controllers/news_posts_controller.rb"
      copy_file "news_post.rb", "app/models/news_post.rb"
      copy_file "neoteric_news.rb", "config/initializers/neoteric_news.rb"
    end

    def configure_routes
      route <<-ROUTES
resources :news_posts, :only => :index, :path => 'news' do
  collection do
    get 'tagged/:tag_name' => 'news_posts#tagged', :as => :tagged
    get ':year(/:month)' => 'news_posts#archive', :as => :archive
  end
end
get 'news/:year/:month/:id' => 'news_posts#show', :as => :news_post
ROUTES
    end

    def generate_taggable
      generate("acts_as_taggable_on:migration")
    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
    end
  end
end