lib/wurfl-lite-middleware.rb in wurfl-lite-middleware-1.0.6 vs lib/wurfl-lite-middleware.rb in wurfl-lite-middleware-1.0.7

- old
+ new

@@ -1,12 +1,18 @@ require 'wurfl-lite-middleware/version' require 'wurfl-lite' class WURFL class Middleware - def initialize( app ) + def initialize( app, options = {} ) @app = app - @wurfl = ENV.has_key?( 'WURFL_XML' ) ? WURFL.new( ENV[ 'WURFL_XML' ].split(',') ) : WURFL.new + + # Try to get the location from either parameters or environment + location = options.delete(:wurfl_xml) || ENV['WURFL_XML'] + @wurfl = location.nil? ? WURFL.new : WURFL.new( location ) + + # Configure the object + @wurfl.match_threshold = options[:match_threshold] if options[:match_threshold] end def call( env ) env['WURFL'] = @wurfl[ env[ 'HTTP_USER_AGENT' ] ] @app.call( env ) end