rackamole 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rackamole.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Rackamole
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.2.9'
4
+ VERSION = '0.3.0'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
  # :startdoc:
@@ -82,7 +82,7 @@ module Rack
82
82
  def call( env )
83
83
  # Bail if application is not moleable
84
84
  return @app.call( env ) unless moleable?
85
-
85
+
86
86
  @stash = env['mole.stash'] if env['mole.stash']
87
87
  @stash = Rackamole::Stash::Collector.new( options[:app_name], options[:environment], options[:expiration] ) unless stash
88
88
 
@@ -158,7 +158,7 @@ module Rack
158
158
  # send info to configured store
159
159
  options[:store].mole( attrs )
160
160
 
161
- # Check for dups. If we've logged this req before don't log it again...
161
+ # Check for dups. If we've reported this req before don't report it again...
162
162
  unless duplicated?( env, attrs )
163
163
  # send email alert ?
164
164
  if alertable?( :email, attrs[:type] )
@@ -289,11 +289,15 @@ module Rack
289
289
  # Gather up browser and client machine info
290
290
  agent_info = Rackamole::Utils::AgentDetect.parse( user_agent )
291
291
  %w(browser machine).each { |type| mole?(type.to_sym, info, agent_info[type.to_sym] ) }
292
-
292
+
293
293
  # Dump request params
294
294
  unless request.params.empty?
295
295
  info[:params] = filter_params( request.params, options[:param_excludes] || [] )
296
296
  end
297
+ if route
298
+ info[:params] ||= {}
299
+ info[:params].merge!( filter_params( params_from_route( route ), options[:param_excludes] || [] ) )
300
+ end
297
301
 
298
302
  # Dump session var
299
303
  if session and !session.empty?
@@ -312,6 +316,17 @@ module Rack
312
316
  info
313
317
  end
314
318
 
319
+ # Parse out rails request params if in rails env
320
+ def params_from_route( route )
321
+ params = {}
322
+ except = [:controller, :action]
323
+ route.each_pair do |k,v|
324
+ next if except.include?( k )
325
+ params[k] = v
326
+ end
327
+ params
328
+ end
329
+
315
330
  # check exclusion to see if the information should be moled
316
331
  def mole?( key, stash, value )
317
332
  # puts "Checking #{key} -- #{options[:mole_excludes].inspect}"
@@ -283,6 +283,20 @@ describe Rack::Mole do
283
283
  res[:controller].should == 'fred'
284
284
  res[:action].should == 'blee'
285
285
  end
286
+
287
+ it "should extract request parameters correctly" do
288
+ rack = Rack::Mole.new( nil, :app_name => "test app" )
289
+ res = rack.send( :params_from_route, {:controller => "blee", :action => "fred", :bobo => "hello" } )
290
+ res.should_not be_nil
291
+ res.should have(1).item
292
+ res.should == { :bobo => "hello" }
293
+ end
294
+
295
+ it "should not pick up params if none are specified" do
296
+ rack = Rack::Mole.new( nil, :app_name => "test app" )
297
+ res = rack.send( :params_from_route, {:controller => "blee", :action => "fred" } )
298
+ res.should be_empty
299
+ end
286
300
  end
287
301
 
288
302
  # ---------------------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackamole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-31 00:00:00 -07:00
12
+ date: 2010-02-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency