Sha256: bb7166d3e743291652476f45a62a6bed25b5102ab89feada8698ad88d5dfc1f3

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 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
          helper Dailycred::Helpers
        end
      end
    end


  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dailycred-0.1.5 lib/dailycred/engine.rb
dailycred-0.1.461 lib/dailycred/engine.rb
dailycred-0.1.46 lib/dailycred/engine.rb
dailycred-0.1.45 lib/dailycred/engine.rb
dailycred-0.1.44 lib/dailycred/engine.rb
dailycred-0.1.43 lib/dailycred/engine.rb