oink 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |s|
8
8
  s.name = "oink"
9
- s.version = "0.9.2"
9
+ s.version = "0.9.3"
10
10
  s.author = "Noah Davis"
11
11
  s.email = "noahd1" + "@" + "yahoo.com"
12
12
  s.homepage = "http://github.com/noahd1/oink"
@@ -28,9 +28,10 @@ module Oink
28
28
  end
29
29
 
30
30
  def log_routing(env)
31
- if env.has_key?('action_dispatch.request.parameters')
32
- controller = env['action_dispatch.request.parameters']['controller']
33
- action = env['action_dispatch.request.parameters']['action']
31
+ routing_info = rails3_routing_info(env) || rails2_routing_info(env)
32
+ if routing_info
33
+ controller = routing_info['controller']
34
+ action = routing_info['action']
34
35
  @logger.info("Oink Action: #{controller}##{action}")
35
36
  end
36
37
  end
@@ -53,6 +54,14 @@ module Oink
53
54
 
54
55
  private
55
56
 
57
+ def rails3_routing_info(env)
58
+ env['action_dispatch.request.parameters']
59
+ end
60
+
61
+ def rails2_routing_info(env)
62
+ env['action_controller.request.path_parameters']
63
+ end
64
+
56
65
  def reset_objects_instantiated
57
66
  ActiveRecord::Base.reset_instance_type_count
58
67
  end
@@ -26,7 +26,7 @@ module Oink
26
26
  @pids[pid][:buffer] << line
27
27
  end
28
28
 
29
- if line =~ /Oink Action: ((\w+)#(\w+))/
29
+ if line =~ /Oink Action: (([\w\/]+)#(\w+))/
30
30
 
31
31
  @pids[pid][:action] = $1
32
32
  unless @pids[pid][:request_finished]
@@ -25,7 +25,7 @@ module Oink
25
25
  @pids[pid][:buffer] << line
26
26
  end
27
27
 
28
- if line =~ /Oink Action: ((\w+)#(\w+))/
28
+ if line =~ /Oink Action: (([\w\/]+)#(\w+))/
29
29
 
30
30
  unless @pids[pid][:request_finished]
31
31
  @pids[pid][:last_memory_reading] = -1
@@ -42,10 +42,20 @@ describe Oink::Middleware do
42
42
  log_output.string.should include("Oink Log Entry Complete")
43
43
  end
44
44
 
45
- it "logs the action and controller" do
45
+ it "logs the action and controller in rails 3.x" do
46
46
  get "/no_pigs", {}, {'action_dispatch.request.parameters' => {'controller' => 'oinkoink', 'action' => 'piggie'}}
47
47
  log_output.string.should include("Oink Action: oinkoink#piggie")
48
48
  end
49
+
50
+ it "logs the action and controller in rails 2.3.x" do
51
+ get "/no_pigs", {}, {'action_controller.request.path_parameters' => {'controller' => 'oinkoink', 'action' => 'piggie'}}
52
+ log_output.string.should include("Oink Action: oinkoink#piggie")
53
+ end
54
+
55
+ it "logs the action and controller within a module" do
56
+ get "/no_pigs", {}, {'action_dispatch.request.parameters' => {'controller' => 'oinkoink/admin', 'action' => 'piggie'}}
57
+ log_output.string.should include("Oink Action: oinkoink/admin#piggie")
58
+ end
49
59
  end
50
60
 
51
61
  it "reports 0 totals" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oink
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Noah Davis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-05 00:00:00 -04:00
18
+ date: 2011-07-08 00:00:00 -04:00
19
19
  default_executable: oink
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency