Sha256: 9272ab557f72946d660d621bcb9c837c06ece5f1b72b3249f5d2a964e460ff1e

Contents?: true

Size: 1.55 KB

Versions: 19

Compression:

Stored size: 1.55 KB

Contents

require 'rails/generators/active_record'

module ActiveRecord
  module Generators
    class OauthProviderGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path('../oauth_provider_templates', __FILE__)

      # Implement the required interface for Rails::Generators::Migration.
      def self.next_migration_number(dirname) #:nodoc:
        next_migration_number = current_migration_number(dirname) + 1
        if ActiveRecord::Base.timestamped_migrations
          [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
        else
          "%.3d" % next_migration_number
        end
      end

      def check_class_collisions
        class_collisions '', %w(ClientApplication OauthNonce RequestToken AccessToken OauthToken)
      end

      def copy_models
        template 'client_application.rb', File.join('app/models', 'client_application.rb')
        template 'oauth_token.rb',        File.join('app/models', 'oauth_token.rb')
        template 'request_token.rb',      File.join('app/models', 'request_token.rb')
        template 'access_token.rb',       File.join('app/models', 'access_token.rb')
        template 'oauth2_token.rb',       File.join('app/models', 'oauth2_token.rb')
        template 'oauth2_verifier.rb',    File.join('app/models', 'oauth2_verifier.rb')
        template 'oauth_nonce.rb',        File.join('app/models', 'oauth_nonce.rb')
      end

      def copy_migration
        migration_template 'migration.rb', 'db/migrate/create_oauth_tables'
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
houston-oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_generator.rb
panjiva-oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.5.0 lib/generators/active_record/oauth_provider_generator.rb
oauth-provider-0.5.0rc1 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.rc2 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.rc1 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre7 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre6 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre5 lib/generators/active_record/oauth_provider_generator.rb
insrc-oauth-plugin-0.4.0.pre6 lib/generators/active_record/oauth_provider_generator.rb
insrc-oauth-plugin-0.4.0.pre5 lib/generators/active_record/oauth_provider_generator.rb
le1t0-oauth-plugin-0.4.0.pre4.001 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre4 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre3 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre2 lib/generators/active_record/oauth_provider_generator.rb
oauth-plugin-0.4.0.pre1 lib/generators/active_record/oauth_provider_generator.rb