controller_filter_logging 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module AbstractController::Callbacks::ClassMethods
|
|
7
7
|
alias_method_chain :before_filter, :logging
|
8
8
|
|
9
9
|
def skip_before_filter_with_logging(filter_name, *args)
|
10
|
-
skip_before_filter_without_logging(
|
10
|
+
skip_before_filter_without_logging(filter_name_to_logging_filter_name(filter_name).to_sym, *args)
|
11
11
|
end
|
12
12
|
alias_method_chain :skip_before_filter, :logging
|
13
13
|
|
@@ -29,7 +29,7 @@ module AbstractController::Callbacks::ClassMethods
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def create_logging_filter(filter_name)
|
32
|
-
name =
|
32
|
+
name = filter_name_to_logging_filter_name(filter_name)
|
33
33
|
define_method(name) do
|
34
34
|
Rails.logger.debug("Entering before_filter: #{filter_name}")
|
35
35
|
start_time = Time.now
|
@@ -45,4 +45,9 @@ module AbstractController::Callbacks::ClassMethods
|
|
45
45
|
name.to_sym
|
46
46
|
end
|
47
47
|
|
48
|
+
protected
|
49
|
+
def filter_name_to_logging_filter_name(filter_name)
|
50
|
+
"#{filter_name.to_s.gsub(%r{[?!]}, '')}_with_logging"
|
51
|
+
end
|
52
|
+
|
48
53
|
end
|
@@ -25,7 +25,7 @@ describe 'controller_filter_logging' do
|
|
25
25
|
result = 12345
|
26
26
|
|
27
27
|
Rails.logger.expects(:debug).with("Entering before_filter: test")
|
28
|
-
Rails.logger.expects(:debug).with(" result: #{result}")
|
28
|
+
Rails.logger.expects(:debug).with(" result (0.00001): #{result}")
|
29
29
|
|
30
30
|
controller = Class.new(ActionController::Base) do
|
31
31
|
attr_reader :called
|
@@ -44,5 +44,28 @@ describe 'controller_filter_logging' do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
describe "#skip_before_filter_with_logging" do
|
49
|
+
it "should skip a filter with a ! in it" do
|
50
|
+
controller = Class.new(ActionController::Base) do
|
51
|
+
attr_accessor :called
|
52
|
+
def test_filter!
|
53
|
+
@called = true
|
54
|
+
end
|
55
|
+
|
56
|
+
before_filter :test_filter!
|
57
|
+
|
58
|
+
end.new
|
59
|
+
|
60
|
+
controller.run_callbacks(:process_action)
|
61
|
+
controller.called.should == true
|
62
|
+
|
63
|
+
controller.called = nil
|
64
|
+
controller.class_eval { skip_before_filter :test_filter! }
|
65
|
+
|
66
|
+
controller.run_callbacks(:process_action)
|
67
|
+
controller.called.should == nil
|
68
|
+
end
|
69
|
+
end
|
47
70
|
end
|
48
71
|
|
metadata
CHANGED
@@ -1,34 +1,23 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: controller_filter_logging
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 7
|
10
|
-
version: 0.0.7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jon Moses
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-06-24 00:00:00 -04:00
|
19
|
-
default_executable:
|
12
|
+
date: 2011-12-01 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
14
|
description: Gem to log execution and results of before_filter's for Rails 3
|
23
|
-
email:
|
15
|
+
email:
|
24
16
|
- jon@burningbush.us
|
25
17
|
executables: []
|
26
|
-
|
27
18
|
extensions: []
|
28
|
-
|
29
19
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
20
|
+
files:
|
32
21
|
- .gitignore
|
33
22
|
- Gemfile
|
34
23
|
- README
|
@@ -39,40 +28,30 @@ files:
|
|
39
28
|
- lib/controller_filter_logging/version.rb
|
40
29
|
- spec/lib/controller_filter_logging_spec.rb
|
41
30
|
- spec/spec_helper.rb
|
42
|
-
|
43
|
-
homepage: ""
|
31
|
+
homepage: ''
|
44
32
|
licenses: []
|
45
|
-
|
46
33
|
post_install_message:
|
47
34
|
rdoc_options: []
|
48
|
-
|
49
|
-
require_paths:
|
35
|
+
require_paths:
|
50
36
|
- lib
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
38
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
- 0
|
59
|
-
version: "0"
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
44
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
segments:
|
67
|
-
- 0
|
68
|
-
version: "0"
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
69
49
|
requirements: []
|
70
|
-
|
71
50
|
rubyforge_project: controller_filter_logging
|
72
|
-
rubygems_version: 1.
|
51
|
+
rubygems_version: 1.8.10
|
73
52
|
signing_key:
|
74
53
|
specification_version: 3
|
75
54
|
summary: Bring back controller filter logging to rails 3
|
76
|
-
test_files:
|
55
|
+
test_files:
|
77
56
|
- spec/lib/controller_filter_logging_spec.rb
|
78
57
|
- spec/spec_helper.rb
|