Sha256: b47a7ab1156b2d5e187798cbeb44de3072088e6ef67812f4a03077808e716f00

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'generators/happy_seed/happy_seed_generator'

module HappySeed
  module Generators
    class GoogleoauthGenerator < HappySeedGenerator
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)

      def install_facebook
        require_omniauth

        gem 'omniauth-google-oauth2'
        gem 'google-api-client', require: "google/api_client"

        Bundler.with_clean_env do
          run "bundle install > /dev/null"
        end

        directory 'docs'
        directory 'app'

        add_omniauth :google_oauth2, 'email,profile,offline", prompt: "consent', 'GoogleAppsClient', "google_oauth2"
        insert_into_file "app/models/identity.rb", "\n    identity.refreshtoken = auth.credentials.refresh_token", after: "identity.accesstoken = auth.credentials.token"
        migration_template("add_refresh_token_to_identity.rb", "db/migrate/add_refresh_token_to_identity.rb" )
      end

      protected
        def self.next_migration_number(dir)
          Time.now.utc.strftime("%Y%m%d%H%M%S")
        end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
happy_seed-0.0.15 lib/generators/happy_seed/googleoauth/googleoauth_generator.rb
happy_seed-0.0.14 lib/generators/happy_seed/googleoauth/googleoauth_generator.rb