Module: Passage::Environment

Defined in:
lib/passage/environment.rb

Instance Method Summary collapse

Instance Method Details

#configure!(opts) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/passage/environment.rb', line 8

def configure!(opts)
  opts[:auth] ||= :pass_through

  set :sessions, true
  set :log, opts[:logger] || Logger.new(STDOUT)

  # load identities
  if(opts[:ids_file])
    ids = Identities.new YAML::load_file(opts[:ids_file] ||  ENV['PSG_IDS_FILE'] )
    set :identities, ids
    log.info "loaded #{ids.count} identities from #{opts[:ids_file]}"
  else
    set :identities, {}
    log.info "no identities loaded (free for all)"
  end

  # load auth
  Dir.glob(File.expand_path("auth/**/*.rb", File.dirname(__FILE__))).each do |f|
    require f
    log.debug "discovered auth: #{File.basename(f)[0..-4]}"
  end
  register constantize(opts[:auth] || ENV['PSG_AUTH'])
  log.info "loaded #{opts[:auth] || ENV['PSG_AUTH']} authentication"

end

#constantize(word) ⇒ Object



34
35
36
# File 'lib/passage/environment.rb', line 34

def constantize(word)
   Passage::Auth::const_get(word.to_s.gsub(/(?:^|_)(.)/) { $1.upcase })
end