Sha256: 528b41c76063c8002a8e5acfe896d9b272f5ecbfe5be30cde851e489d908b5ed

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

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

    def create_device_migration_file
        migration_template 'devices_migration.rb.erb', 'db/migrate/devise_onesignal_migration.rb', migration_version: migration_version
    end
    def create_device_model
        template 'device_model.rb', 'app/models/device.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

14 entries across 14 versions & 1 rubygems

Version Path
devise-onesignal-4.0.1 lib/generators/devise_onesignal_generator.rb
devise-onesignal-4.0.0 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.2.0 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.5 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.4 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.3 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.2 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.1 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.1.0 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.0.2 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.0.1 lib/generators/devise_onesignal_generator.rb
devise-onesignal-3.0.0 lib/generators/devise_onesignal_generator.rb
devise-onesignal-2.0.1 lib/generators/devise_onesignal_generator.rb
devise-onesignal-2.0.0 lib/generators/devise_onesignal_generator.rb