Sha256: c5ca35793969c9b8dd77e861adb471d95790682f364f594df08689e9694e56e7

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'    
module LolitaMenu
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path("../templates", __FILE__)
      desc "Copy assets and create migrations. "

      def self.next_migration_number(dirname)
       if ActiveRecord::Base.timestamped_migrations
         Time.now.utc.strftime("%Y%m%d%H%M%S")
       else
         "%.3d" % (current_migration_number(dirname) + 1)
       end
     end

      def copy_assets
        generate("lolita_menu:assets")
      end

      def create_menu_migrations
        begin
          migration_template "migrations/create_menus.rb", "db/migrate/create_lolita_menus.rb" 
          migration_template "migrations/create_menu_items.rb", "db/migrate/create_lolita_menu_items.rb"
        rescue Exception => e
          puts e
        end
      end

      def copy_initializer
        template "lolita-menu-urls.rb", "config/lolita-menu-urls.rb"
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lolita-menu-0.0.15 lib/generators/lolita_menu/install_generator.rb
lolita-menu-0.0.14 lib/generators/lolita_menu/install_generator.rb
lolita-menu-0.0.13 lib/generators/lolita_menu/install_generator.rb
lolita-menu-0.0.12 lib/generators/lolita_menu/install_generator.rb