Sha256: 921ff0ba349779fa090c238adb8a34ccb539bd68bcae08cd0968277315d16a3b

Contents?: true

Size: 991 Bytes

Versions: 7

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

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

module Noticent
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path('templates', __dir__)
      desc 'Generate Noticent required files'
      def self.next_migration_number(path)
        next_migration_number = current_migration_number(path) + 1
        ActiveRecord::Migration.next_migration_number(next_migration_number)
      end

      def copy_migrations
        migration_template 'create_opt_ins.rb',
                           'db/migrate/create_opt_ins.rb'

        puts 'DB migration generated. Run rake db:migrate next'
      end

      def copy_initializer 
        template 'noticent_initializer.rb', 'config/initializers/noticent.rb'

        puts 'Install Complete!'
      end

      def copy_model
        template 'opt_in.rb', 'app/models/opt_in.rb'
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
noticent-0.0.6 lib/generators/noticent/noticent.rb
noticent-0.0.5 lib/generators/noticent/noticent.rb
noticent-0.0.4 lib/generators/noticent/noticent.rb
noticent-0.0.3 lib/generators/noticent/noticent.rb
noticent-0.0.2 lib/generators/noticent/noticent.rb
noticent-0.0.1 lib/generators/noticent/noticent.rb
noticent-0.0.1.pre.pre lib/generators/noticent/noticent.rb