Sha256: 55a98857b8f200994a8694cd15315f7d90383dfaf1ec3e9643293deca6ab7366

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'

module NotificationRenderer

    class InstallGenerator < Rails::Generators::Base

        include Rails::Generators::Migration

        source_root File.join File.dirname(__FILE__), '../templates/install'
        desc 'Install NotificationRenderer'

        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 create_initializer
            template 'initializer.rb', 'config/initializers/notification-renderer.rb'
        end

        def create_notifications_migration_file
            migration_template 'notifications_migration.rb.erb', 'db/migrate/notification_renderer_migration.rb', migration_version: migration_version
        end

        def create_templates
            system 'rails g notification_renderer:type -t notification'
        end

        def show_readme
            readme 'README.md'
        end

        private

        def migration_version
            if Rails.version >= '5.0.0'
                "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
            end
        end

    end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
notification-renderer-1.2.5 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.2.4 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.2.3 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.2.2 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.2.1 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.2.0 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.1.2 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.1.1 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.1.0 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0.beta11 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0.beta10 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0.beta9 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0.beta8 lib/generators/notification_renderer/install_generator.rb
notification-renderer-1.0.0.beta7 lib/generators/notification_renderer/install_generator.rb