Sha256: 017abddeabf3e629f5fc7d50a2265cf8eadc608106a64f3835b9f77c9a84b10c

Contents?: true

Size: 1007 Bytes

Versions: 5

Compression:

Stored size: 1007 Bytes

Contents

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

class DeviseOneSignalGenerator < Rails::Generators::Base

    include Rails::Generators::Migration

    source_root File.join File.dirname(__FILE__), 'templates'
    desc 'Install devise-onesignal'

    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_migration_file
        migration_template 'migration.rb.erb', 'db/migrate/devise_one_signal_migration.rb', migration_version: migration_version
    end

    def create_initializer
        template 'initializer.rb', 'config/initializers/devise-onesignal.rb'
    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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise-onesignal-1.2.1 lib/generators/devise_one_signal_generator.rb
devise-onesignal-1.1.1 lib/generators/devise_one_signal_generator.rb
devise-onesignal-1.1.0 lib/generators/devise_one_signal_generator.rb
devise-onesignal-1.0.1 lib/generators/devise_one_signal_generator.rb
devise-onesignal-1.0.0 lib/generators/devise_one_signal_generator.rb