Sha256: 22475944423be0f21cb43ed714b8fcb363ee4ac5b6b589675508fb4d397981b4

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'rails/generators/migration'

module Apicasso
  module Generators
    # Class used to install Apicasso engine into a project
    class InstallGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)
      desc 'Add the required migrations to run APIcasso'

      # Method generates the next migration number
      # @param path [String] the path to migration directory
      # @returns [String] the next migration number
      def self.next_migration_number(path)
        if @prev_migration_nr
          @prev_migration_nr += 1
        else
          @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
        end
        @prev_migration_nr.to_s
      end

      # Create a migration to setup database tables used by the
      # engine to implement authentication, authorization and auditability
      def copy_migrations
        migration_template 'create_apicasso_tables.rb',
                           'db/migrate/create_apicasso_tables.rb'
      end

      # Create an initializer with CORS configuration to Apicasso
      def copy_initializer
        copy_file 'apicasso.rb', 'config/initializers/apicasso.rb'
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
apicasso-0.7.3 lib/generators/apicasso/install/install_generator.rb
apicasso-0.7.2 lib/generators/apicasso/install/install_generator.rb
apicasso-0.7.1 lib/generators/apicasso/install/install_generator.rb
apicasso-0.7.0 lib/generators/apicasso/install/install_generator.rb
apicasso-0.6.8 lib/generators/apicasso/install/install_generator.rb
apicasso-0.6.7 lib/generators/apicasso/install/install_generator.rb
apicasso-0.6.6 lib/generators/apicasso/install/install_generator.rb