Sha256: 168609b21041406bb955eb4a4ddb5e395e9a985fe9b773b1dd41a611638ae966

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'omniauth'
require 'omniauth/strategies/openstax'
require 'lev'
require 'roar/decorator'
require 'roar/representer/json'

ActiveSupport::Inflector.inflections do |inflect|
  inflect.acronym 'OpenStax'
end

module OpenStax
  module Accounts
    class Engine < ::Rails::Engine
      isolate_namespace OpenStax::Accounts
      
      initializer "openstax_accounts.factories",
        :after => "factory_girl.set_factory_paths" do
        FactoryGirl.definition_file_paths << File.join(root, 'spec', 'factories') if defined?(FactoryGirl)
      end

      config.generators do |g|
        g.test_framework :rspec, :view_specs => false, :fixture => false
        g.fixture_replacement :factory_girl, :dir => 'spec/factories'
        g.assets false
        g.helper false
      end

      SETUP_PROC = lambda do |env|
        env['omniauth.strategy'].options[:client_options][:site] = OpenStax::Accounts.configuration.openstax_accounts_url
      end

      # Doesn't work to put this omniauth code in an engine initializer, instead:
      # https://gist.github.com/pablomarti/5243118
      middleware.use ::OmniAuth::Builder do
        provider :openstax, 
                 OpenStax::Accounts.configuration.openstax_application_id,
                 OpenStax::Accounts.configuration.openstax_application_secret,
                 :setup => SETUP_PROC
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_accounts-0.3.0 lib/openstax/accounts/engine.rb
openstax_accounts-0.3 lib/openstax/accounts/engine.rb