Sha256: 12a460de828172e56c848bbda9d9765d113582d3e07c89ff4014087f71bcbcba

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

require 'rails'
module Dailycred

  class Engine < Rails::Engine

    initializer 'dailycred.setup', :after=>"dailycred" do |app|
      conf = Rails.configuration# alias for configuration
      if conf.respond_to? 'DAILYCRED_CLIENT_ID'
        id = conf.DAILYCRED_CLIENT_ID
        secret = conf.DAILYCRED_SECRET_KEY

        # setup omniauth options, can be overridden. ex:
        # Rails.application.DAILYCRED_OPTIONS = {
        #   :client_options => {
        #     :site => 'https://www.dailycred.com',
        #     :authorize_url => '/connect',
        #     :token_url => '/oauth/access_token'
        #   }
        # }
        if conf.respond_to? 'DAILYCRED_OPTIONS'
          opts = conf.DAILYCRED_OPTIONS
          opts[:client_options] ||= {}
          opts[:client_options][:ssl] = {}
        else
          opts = {:client_options => {:ssl => {}}}
        end

        if File.exists?('/etc/ssl/certs')
          opts[:client_options][:ssl][:ca_path] = '/etc/ssl/certs'
        end
        if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
          opts[:client_options][:ssl][:ca_file] = '/opt/local/share/curl/curl-ca-bundle.crt'
        end

        conf.DAILYCRED_OPTIONS = opts

        Rails.application.config.middleware.use OmniAuth::Builder do
          provider :dailycred, id, secret, opts
        end

        Rails.application.config.middleware.use "Dailycred::Middleware", id

        ActiveSupport.on_load(:action_controller) do
          include Dailycred::Helpers
        end
      end
    end


  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dailycred-0.1.42 lib/dailycred/engine.rb
dailycred-0.1.41 lib/dailycred/engine.rb
dailycred-0.1.4 lib/dailycred/engine.rb
dailycred-0.1.36 lib/dailycred/engine.rb