trace-util-adv 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO.txt +18 -2
- data/VERSION +1 -1
- data/lib/appenders/appender.rb +1 -1
- data/lib/appenders/base_appender.rb +18 -20
- data/lib/appenders/include.rb +2 -2
- data/lib/appenders/types/html_appender.rb +1 -1
- data/lib/appenders/types/logger_appender.rb +1 -1
- data/lib/appenders/types/xml_appender.rb +1 -1
- data/lib/extensions/hash_extensions.rb +41 -19
- data/lib/extensions/hash_rule_extensions.rb +4 -0
- data/lib/extensions/symbol_extensions.rb +7 -5
- data/lib/filters/composite/composite_class_filter.rb +1 -0
- data/lib/filters/composite/composite_module_filter.rb +1 -0
- data/lib/filters/executor/filter_exec.rb +6 -2
- data/lib/filters/filter.rb +12 -17
- data/lib/filters/filter_factory.rb +1 -1
- data/lib/filters/filter_mappings.rb +4 -2
- data/lib/filters/include.rb +4 -8
- data/lib/filters/list/list_instance_var_filter.rb +1 -0
- data/lib/filters/name_filter.rb +13 -0
- data/lib/filters/simple/argument_filter.rb +2 -1
- data/lib/filters/simple/class_filter.rb +1 -1
- data/lib/filters/simple/instance_var_filter.rb +9 -6
- data/lib/filters/simple/method_filter.rb +1 -0
- data/lib/filters/simple/module_filter.rb +6 -3
- data/lib/rules/rule_match.rb +5 -4
- data/lib/targets/file_target.rb +11 -0
- data/lib/templates/base_template.rb +11 -12
- data/lib/templates/html_template.rb +35 -36
- data/lib/templates/string_template.rb +0 -1
- data/lib/templates/template_mappings.rb +4 -4
- data/lib/templates/xml_template.rb +0 -1
- data/lib/trace-util-adv.rb +36 -20
- data/lib/trace_calls/trace_ext.rb +4 -17
- data/test/action_handler/include.rb +4 -0
- data/test/action_handler/test_action_handler.rb +1 -2
- data/test/action_handler/test_create_action_handler.rb +6 -9
- data/test/appenders/include.rb +4 -0
- data/test/appenders/test_appender_templates.rb +57 -0
- data/test/appenders/test_create_appender.rb +9 -10
- data/test/extensions/include.rb +4 -0
- data/test/extensions/test_filters_creation.rb +4 -28
- data/test/extensions/test_hash_extensions.rb +44 -47
- data/test/extensions/test_hash_filter_extensions.rb +46 -29
- data/test/extensions/test_set_context.rb +9 -11
- data/test/extensions/test_string_extensions.rb +1 -3
- data/test/extensions/test_symbol_extensions.rb +2 -4
- data/test/filters/chain/test_filters_chain.rb +1 -51
- data/test/filters/composite/test_composite_class_filter.rb +1 -3
- data/test/filters/composite/test_composite_module_filter.rb +1 -3
- data/test/filters/composite/test_composite_var_filter.rb +8 -11
- data/test/filters/executor/test_filter_exec.rb +1 -3
- data/test/filters/include.rb +8 -0
- data/test/filters/msg_context/test_custom_filters.rb +13 -14
- data/test/filters/simple/test_base_filter.rb +8 -6
- data/test/filters/simple/test_class_filter.rb +1 -3
- data/test/filters/simple/test_instancevar_filter.rb +5 -9
- data/test/filters/simple/test_method_filter.rb +4 -9
- data/test/filters/simple/test_module_filter.rb +13 -10
- data/test/samples/sample_composite_filters.rb +15 -12
- data/test/targets/test_create_targets.rb +21 -0
- data/test/templates/include.rb +4 -0
- data/test/templates/test_create_templates.rb +23 -0
- data/test/templates/test_exec_templates.rb +6 -0
- data/test/trace_calls/include.rb +4 -0
- data/test/trace_calls/test_configure_.rb +17 -14
- data/test/trace_calls/tracing/test_html_tracing.rb +2 -3
- data/test/trace_calls/tracing/test_logger_tracing.rb +5 -4
- data/test/trace_calls/tracing/test_stream_tracing.rb +2 -3
- data/test/trace_calls/tracing/test_teamplate_log_tracing.rb +2 -3
- data/test/trace_calls/tracing/test_xml_tracing.rb +2 -3
- data/trace-util-adv.gemspec +14 -6
- metadata +13 -5
- data/test/appenders/test_appender_tracers.rb +0 -56
- data/test/tracers/test_create_tracers.rb +0 -46
- data/test/tracers/test_exec_tracers.rb +0 -11
@@ -1,7 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'filters/base_filters'
|
3
|
-
require 'rules/hash_rule_extensions'
|
4
|
-
require "test/unit"
|
1
|
+
require "include"
|
5
2
|
|
6
3
|
class Person
|
7
4
|
attr_accessor :name
|
@@ -56,38 +53,39 @@ class TestHashExtensions < Test::Unit::TestCase
|
|
56
53
|
expected = {
|
57
54
|
:vars => [{:a => 12, :b => "B"}]
|
58
55
|
}
|
59
|
-
|
56
|
+
|
60
57
|
assert_equal expected, context, "resulting @context not as expected"
|
61
58
|
end
|
62
|
-
|
59
|
+
|
63
60
|
def test_set_context_args
|
64
61
|
context = {:args => [{:a => 12, :b => "B"}]}.context
|
65
62
|
puts "context set:" + context.inspect
|
66
63
|
expected = {
|
67
64
|
:args => [{:a => 12, :b => "B"}]
|
68
65
|
}
|
69
|
-
|
66
|
+
|
70
67
|
assert_equal expected, context, "resulting @context not as expected"
|
71
68
|
end
|
72
|
-
|
69
|
+
|
73
70
|
def test_set_context_block
|
74
71
|
context = {:block => true}.context
|
75
72
|
puts "context set:" + context.inspect
|
76
73
|
expected = {
|
77
74
|
:block => true
|
78
75
|
}
|
79
|
-
|
76
|
+
|
80
77
|
assert_equal expected, context, "resulting @context not as expected"
|
81
78
|
end
|
82
|
-
|
79
|
+
|
83
80
|
def test_set_context_self
|
84
81
|
obj = Person.new "Kristian"
|
85
82
|
context = {:block => true, :self => obj}.context
|
86
83
|
puts "context set:" + context.inspect
|
87
84
|
expected = {
|
85
|
+
:block => true,
|
88
86
|
:self => obj
|
89
87
|
}
|
90
|
-
|
88
|
+
|
91
89
|
assert_equal expected, context, "resulting @context not as expected"
|
92
90
|
assert_equal "Kristian", context[:self].name, "Kristian expected as person name"
|
93
91
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require "test/unit"
|
3
|
-
|
1
|
+
require 'include'
|
4
2
|
|
5
3
|
class TestSymbolExtensions < Test::Unit::TestCase
|
6
4
|
|
@@ -18,7 +16,7 @@ class TestSymbolExtensions < Test::Unit::TestCase
|
|
18
16
|
|
19
17
|
def test_trace_class
|
20
18
|
result = :xml.trace_class
|
21
|
-
assert_equal result, Tracing::
|
19
|
+
assert_equal result, Tracing::XmlTemplate, ":xml Should result in XmlTrace"
|
22
20
|
end
|
23
21
|
|
24
22
|
def appender_class
|
@@ -1,55 +1,5 @@
|
|
1
|
-
require "
|
2
|
-
require "trace_calls"
|
3
|
-
require "output_templates"
|
4
|
-
require "rubygems"
|
5
|
-
require "duration"
|
6
|
-
require "test/unit"
|
1
|
+
require "../include"
|
7
2
|
|
8
|
-
# configure use of TraceExt
|
9
|
-
module Me
|
10
|
-
class My
|
11
|
-
|
12
|
-
def hello
|
13
|
-
puts "Hello World!"
|
14
|
-
end
|
15
|
-
|
16
|
-
def hi_there
|
17
|
-
puts "Hi there!"
|
18
|
-
end
|
19
|
-
|
20
|
-
def blip
|
21
|
-
puts "Blip!"
|
22
|
-
end
|
23
|
-
|
24
|
-
def blap
|
25
|
-
puts "Blap!"
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Method_filter_A = {
|
32
|
-
:name => 'my methods',
|
33
|
-
:method_rules => [{
|
34
|
-
# id of method rule set
|
35
|
-
:name => 'my_methods',
|
36
|
-
:include => [/hi.*/],
|
37
|
-
:exclude => ['hello'],
|
38
|
-
:default => :yield
|
39
|
-
}]
|
40
|
-
}
|
41
|
-
|
42
|
-
# Method_filter_B = {
|
43
|
-
# :name => 'my methods',
|
44
|
-
# :method_rules => [{
|
45
|
-
# # id of method rule set
|
46
|
-
# :name => 'my_methods',
|
47
|
-
# :include => ['blip', 'blop'],
|
48
|
-
# :default => :yield
|
49
|
-
# }]
|
50
|
-
# }
|
51
|
-
|
52
|
-
|
53
3
|
class TestFilter < Test::Unit::TestCase
|
54
4
|
|
55
5
|
attr_reader :ah1, :filters
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'extensions/core_extensions'
|
3
|
-
require "test/unit"
|
1
|
+
require "../include"
|
4
2
|
|
5
3
|
# for specific instance_vars, match on values (after .to_s on var)
|
6
4
|
|
@@ -44,28 +42,28 @@ class TestCompositeInstanceVarFilter < Test::Unit::TestCase
|
|
44
42
|
def test_composite_var_filter_hash_to_var
|
45
43
|
composite_filter = Var_composite_filter
|
46
44
|
result = composite_filter.filter_class
|
47
|
-
assert_equal Tracing::
|
45
|
+
assert_equal Tracing::ListInstanceVarFilter, result, "Should result in composite var filter"
|
48
46
|
end
|
49
47
|
|
50
48
|
def test_composite_var_filter_hash_to_var
|
51
49
|
composite_filter = Var_composite_filter
|
52
50
|
result = composite_filter.create_filter
|
53
|
-
assert_equal Tracing::
|
51
|
+
assert_equal Tracing::ListInstanceVarFilter, result.class, "Should result in composite var filter"
|
54
52
|
end
|
55
53
|
|
56
54
|
def test_composite_var_filter_from_hash
|
57
55
|
composite_filter = Var_composite_filter
|
58
56
|
config = {:filters => composite_filter}
|
59
57
|
result = config.filters
|
60
|
-
assert_equal Tracing::
|
58
|
+
assert_equal Tracing::ListInstanceVarFilter, result.class, "Should result in composite var filter"
|
61
59
|
end
|
62
60
|
|
63
61
|
# see allow_action in CompositeInstanceVarFilter, refactor :yield, :include .. as return values!?
|
62
|
+
|
64
63
|
def test_composite_var_filter__var_and_method_match
|
65
64
|
composite_filter = Var_composite_filter
|
66
65
|
|
67
|
-
context = {}
|
68
|
-
context.set_context :vars => {:template_path => 'rapid'}
|
66
|
+
context = {:vars => ["template_path" => 'b/taglib/b'], :self => Obj.new('b/taglib/b')}.context
|
69
67
|
|
70
68
|
options = {:filters => composite_filter}
|
71
69
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -76,8 +74,7 @@ class TestCompositeInstanceVarFilter < Test::Unit::TestCase
|
|
76
74
|
def test_composite_var_filter__var_not_match
|
77
75
|
composite_filter = Var_composite_filter
|
78
76
|
|
79
|
-
context = {}
|
80
|
-
context.set_context :class_name => 'Blip::Blap', :vars => ["template_path"]
|
77
|
+
context = {:class_name => 'Blip::Blap', :vars => ["template_path" => 'rapid']}
|
81
78
|
context[:self] = Obj.new "blop"
|
82
79
|
|
83
80
|
options = {:filters => composite_filter}
|
@@ -90,7 +87,7 @@ class TestCompositeInstanceVarFilter < Test::Unit::TestCase
|
|
90
87
|
composite_filter = Var_composite_filter
|
91
88
|
|
92
89
|
context = {}
|
93
|
-
context.set_context :class_name => 'Blip::Blap', :vars => ["template_path"]
|
90
|
+
context.set_context :class_name => 'Blip::Blap', :vars => ["template_path" => 'blip']
|
94
91
|
context[:self] = Obj.new "a/rapid_x"
|
95
92
|
|
96
93
|
options = {:filters => composite_filter}
|
@@ -1,12 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require 'filters/base_filters'
|
3
|
-
require 'filters/message_filters'
|
4
|
-
|
5
|
-
|
6
|
-
require 'extensions/core_extensions'
|
7
|
-
require "test/unit"
|
1
|
+
require '../include'
|
8
2
|
|
9
3
|
class CustomNameFilter < Tracing::NameFilter
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
10
9
|
def allow?(name)
|
11
10
|
name == options[:name]
|
12
11
|
end
|
@@ -18,7 +17,7 @@ class TestSymbolExtensions < Test::Unit::TestCase
|
|
18
17
|
def setup
|
19
18
|
# Procs of this form can be used as filters inside include/exclude lists
|
20
19
|
abc_filter = Proc.new {|name| name == 'abc' }
|
21
|
-
name_filter = CustomNameFilter.new('rapid')
|
20
|
+
name_filter = CustomNameFilter.new({:name => 'rapid'})
|
22
21
|
@meth_filter_abc = {:i_method_filter => [abc_filter], :default => :exclude}.filters
|
23
22
|
@meth_filter_name = {:i_method_filter => [name_filter], :default => :exclude}.filters
|
24
23
|
@meth_filter_comb = {:i_method_filter => [abc_filter, name_filter], :default => :exclude}.filters
|
@@ -32,18 +31,18 @@ class TestSymbolExtensions < Test::Unit::TestCase
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def test_custom_name_filter
|
35
|
-
res = @meth_filter_name.
|
36
|
-
assert_equal
|
34
|
+
res = @meth_filter_name.allow_action("hello", @context_abc)
|
35
|
+
assert_equal :yield, res, "Should allow since matching method name 'abc'"
|
37
36
|
end
|
38
37
|
|
39
38
|
def test_custom_proc_filter
|
40
|
-
res = @meth_filter_abc.
|
41
|
-
assert_equal
|
39
|
+
res = @meth_filter_abc.allow_action("hello", @context_rapid)
|
40
|
+
assert_equal :yield, res, "Should allow since matching method name 'rapid'"
|
42
41
|
end
|
43
42
|
|
44
43
|
def test_custom_filters
|
45
|
-
@meth_filter_comb.
|
46
|
-
assert_equal
|
44
|
+
res = @meth_filter_comb.allow_action("hello", @context_abc)
|
45
|
+
assert_equal :include, res, "Should allow since matching method name 'abc'"
|
47
46
|
end
|
48
47
|
|
49
48
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require "test/unit"
|
1
|
+
require "../include"
|
3
2
|
|
4
3
|
|
5
4
|
class TestBaseFilter < Test::Unit::TestCase
|
@@ -12,7 +11,7 @@ class TestBaseFilter < Test::Unit::TestCase
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def test_default_name
|
15
|
-
bf = Tracing::BaseFilter.new
|
14
|
+
bf = Tracing::BaseFilter.new({})
|
16
15
|
assert_equal "Unknown filter", bf.name, "Should result name:'Unknown filter'"
|
17
16
|
end
|
18
17
|
|
@@ -26,12 +25,15 @@ class TestBaseFilter < Test::Unit::TestCase
|
|
26
25
|
assert_equal "base", bf.name, "Should result in name:'base'"
|
27
26
|
end
|
28
27
|
|
29
|
-
def test_register_filters
|
30
|
-
|
28
|
+
def test_register_filters
|
29
|
+
Tracing::BaseFilter.new({:name => 'base'})
|
31
30
|
bF = Tracing::BaseFilter
|
31
|
+
|
32
32
|
f1 = {:x => :y}
|
33
33
|
bF.register_filters(f1)
|
34
|
-
|
34
|
+
expect = {:x => :y}
|
35
|
+
assert_equal expect, bF.filters, "Should result in x=>y filter"
|
36
|
+
|
35
37
|
f2 = {:z => :a}
|
36
38
|
bF.register_filters(f2)
|
37
39
|
expect = {:z=>:a, :x=>:y}
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'extensions/core_extensions'
|
3
|
-
require "test/unit"
|
1
|
+
require "../include"
|
4
2
|
|
5
3
|
InstanceVar_filter = {
|
6
4
|
:name => 'check template path',
|
@@ -45,18 +43,19 @@ class TestInstanceVarFilter < Test::Unit::TestCase
|
|
45
43
|
# see allow_action in InstanceVarFilter, refactor :yield, :include .. as return values!?
|
46
44
|
def test_varfilter__class_and_varmatch
|
47
45
|
var_filter = InstanceVar_filter
|
48
|
-
context = {:class_name => "Hobo::Dryml", :vars => {"template_path" => "a/taglib/x"} }.context
|
46
|
+
context = {:class_name => "Hobo::Dryml", :vars => {"template_path" => "a/taglib/x"}, :self => Obj.new("a/taglib/x") }.context
|
49
47
|
|
50
48
|
options = {:filters => var_filter}
|
51
49
|
exec = Tracing::Filter::Executor.new(options)
|
52
50
|
result = exec.filters_allow?('msg', context)
|
51
|
+
|
53
52
|
assert_equal true, result, "Filter should allow passage"
|
54
53
|
end
|
55
54
|
|
56
55
|
def test_varfilter__varnot_match
|
57
56
|
var_filter = InstanceVar_filter
|
58
57
|
|
59
|
-
context = {:class_name => 'Blip::Blap', :vars => {"template_path" => "a/taglib/x"}, :self => Obj.new("
|
58
|
+
context = {:class_name => 'Blip::Blap', :vars => {"template_path" => "a/taglib/x"}, :self => Obj.new("taglib/x") }.context
|
60
59
|
|
61
60
|
puts "Context:" + context.inspect
|
62
61
|
|
@@ -68,10 +67,7 @@ class TestInstanceVarFilter < Test::Unit::TestCase
|
|
68
67
|
|
69
68
|
def test_varfilter__varexcluded
|
70
69
|
var_filter = InstanceVar_filter
|
71
|
-
context = {:class_name => 'Blip::Blap', :vars => {"template_path" => "a/taglib/x"} }.context
|
72
|
-
|
73
|
-
context[:self] = Obj.new "a/rapid_x"
|
74
|
-
|
70
|
+
context = {:class_name => 'Blip::Blap', :vars => {"template_path" => "a/taglib/x"}, :self => Obj.new("a/rapid_x") }.context
|
75
71
|
|
76
72
|
options = {:filters => var_filter}
|
77
73
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'extensions/core_extensions'
|
3
|
-
require "test/unit"
|
1
|
+
require "../include"
|
4
2
|
|
5
3
|
Method_filter = {
|
6
4
|
:name => 'my methods',
|
@@ -41,8 +39,7 @@ class TestMethodFilter < Test::Unit::TestCase
|
|
41
39
|
def test_method_filter__class_and_method_match
|
42
40
|
composite_filter = Method_filter
|
43
41
|
|
44
|
-
context = {}
|
45
|
-
context.set_context :class_name => "Hobo::Dryml", :method_name => "build_a"
|
42
|
+
context = { :class_name => "Hobo::Dryml", :method_name => "build_a"}.context
|
46
43
|
|
47
44
|
options = {:filters => composite_filter}
|
48
45
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -53,8 +50,7 @@ class TestMethodFilter < Test::Unit::TestCase
|
|
53
50
|
def test_method_filter__method_not_match
|
54
51
|
composite_filter = Method_filter
|
55
52
|
|
56
|
-
context = {}
|
57
|
-
context.set_context :class_name => 'Blip::Blap', :method_name => "blop"
|
53
|
+
context = { :class_name => 'Blip::Blap', :method_name => "blop"}.context
|
58
54
|
|
59
55
|
options = {:filters => composite_filter}
|
60
56
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -65,8 +61,7 @@ class TestMethodFilter < Test::Unit::TestCase
|
|
65
61
|
def test_method_filter__method_excluded
|
66
62
|
composite_filter = Method_filter
|
67
63
|
|
68
|
-
context = {}
|
69
|
-
context.set_context :class_name => "Hobo::Dryml", :method_name => "add_it"
|
64
|
+
context = { :class_name => "Hobo::Dryml", :method_name => "add_it"}.context
|
70
65
|
|
71
66
|
options = {:filters => composite_filter}
|
72
67
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -1,17 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require 'extensions/core_extensions'
|
3
|
-
require "test/unit"
|
1
|
+
require "../include"
|
4
2
|
|
5
3
|
Module_filter = {
|
6
4
|
:name => 'my modules',
|
5
|
+
:default => :exclude,
|
7
6
|
:module_rules => [{
|
8
7
|
# id of modules rule set
|
9
8
|
:name => ['my_modules'],
|
10
9
|
:include => [/Hobo/],
|
11
10
|
:exclude => [/Dryml/],
|
12
11
|
:default => :exclude
|
13
|
-
}
|
14
|
-
|
12
|
+
}]
|
13
|
+
}
|
15
14
|
|
16
15
|
class TestModuleFilter < Test::Unit::TestCase
|
17
16
|
|
@@ -31,6 +30,7 @@ class TestModuleFilter < Test::Unit::TestCase
|
|
31
30
|
_filter = Module_filter
|
32
31
|
config = {:filters => _filter}
|
33
32
|
result = config.filters
|
33
|
+
puts result.inspect
|
34
34
|
assert_equal Tracing::ModuleFilter, result.class, "Should result in module filter"
|
35
35
|
end
|
36
36
|
|
@@ -38,8 +38,7 @@ class TestModuleFilter < Test::Unit::TestCase
|
|
38
38
|
def test_module_filter__module_and_method_match
|
39
39
|
_filter = Module_filter
|
40
40
|
|
41
|
-
context = {}
|
42
|
-
context.set_context :modules => ["Hobo"], :method_name => "build_a" #, :class_name => "Dryml"
|
41
|
+
context = { :modules => ["Hobo"], :method_name => "build_a", :class_name => "Dryml" }.context
|
43
42
|
|
44
43
|
options = {:filters => _filter}
|
45
44
|
exec = Tracing::Filter::Executor.new(options)
|
@@ -47,16 +46,20 @@ class TestModuleFilter < Test::Unit::TestCase
|
|
47
46
|
assert_equal true, result, "Filter should allow passage"
|
48
47
|
end
|
49
48
|
|
50
|
-
|
49
|
+
# TODO: Doesn't Work :(
|
51
50
|
def test_module_filter__module_not_match
|
52
51
|
_filter = Module_filter
|
53
52
|
|
54
|
-
context = {}
|
55
|
-
|
53
|
+
context = {:modules => ["Blip", "Blop"], :method_name => "build_a", :class_name => "Dryml"}.context
|
54
|
+
|
55
|
+
puts context.inspect
|
56
56
|
|
57
57
|
options = {:filters => _filter}
|
58
58
|
exec = Tracing::Filter::Executor.new(options)
|
59
59
|
result = exec.filters_allow?('msg', context)
|
60
|
+
|
61
|
+
puts "Result:" + result.inspect
|
62
|
+
|
60
63
|
assert_equal false, result, "Filter should NOT allow passage"
|
61
64
|
end
|
62
65
|
|