trace-util-adv 0.2.3 → 0.2.4
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/Advanced TraceUtils tutorial.pdf +0 -0
- data/CHANGELOG +4 -8
- data/{lib/TODO.txt → TODO.txt} +8 -0
- data/VERSION +1 -1
- data/lib/action_handler/action_handler.rb +40 -0
- data/lib/{action_handler.rb → action_handler/action_handler_registration.rb} +3 -41
- data/lib/appenders/appender.rb +1 -13
- data/lib/appenders/appender_mappings.rb +13 -0
- data/lib/appenders/base_appender.rb +2 -11
- data/lib/appenders/file_appender.rb +21 -13
- data/lib/appenders/include.rb +4 -0
- data/lib/appenders/types/README-NOTE.txt +2 -0
- data/lib/appenders/{html_appender.rb → types/html_appender.rb} +4 -20
- data/lib/appenders/{logger_appender.rb → types/logger_appender.rb} +0 -0
- data/lib/appenders/{stream_appender.rb → types/stream_appender.rb} +0 -0
- data/lib/appenders/{template_log_appender.rb → types/template_log_appender.rb} +0 -0
- data/lib/appenders/{xml_appender.rb → types/xml_appender.rb} +1 -1
- data/lib/extensions/array_extensions.rb +42 -0
- data/lib/extensions/hash_extensions.rb +181 -0
- data/lib/extensions/hash_rule_extensions.rb +50 -0
- data/lib/extensions/include.rb +1 -0
- data/lib/extensions/nilclass_extensions.rb +10 -0
- data/lib/extensions/object_extensions.rb +19 -0
- data/lib/extensions/string_extensions.rb +35 -0
- data/lib/extensions/symbol_extensions.rb +30 -0
- data/lib/filters/composite/composite_class_filter.rb +25 -0
- data/lib/filters/composite/composite_module_filter.rb +53 -0
- data/lib/filters/executor/filter_exec.rb +74 -0
- data/lib/filters/filter.rb +43 -0
- data/lib/filters/filter_factory.rb +1 -1
- data/lib/filters/filter_mappings.rb +36 -0
- data/lib/filters/{tracing_filter.rb → filter_registration.rb} +6 -49
- data/lib/filters/filter_use.rb +10 -0
- data/lib/filters/include.rb +8 -0
- data/lib/filters/list/README-NOTE.txt +1 -0
- data/lib/filters/list/list_instance_var_filter.rb +27 -0
- data/lib/filters/{message_filters.rb → msg_context/message_context_filters.rb} +3 -12
- data/lib/filters/simple/argument_filter.rb +24 -0
- data/lib/filters/simple/class_filter.rb +15 -0
- data/lib/filters/simple/instance_var_filter.rb +25 -0
- data/lib/filters/simple/method_filter.rb +17 -0
- data/lib/filters/simple/module_filter.rb +14 -0
- data/lib/{templates/trace_output_handler.rb → output_handler/output_handler.rb} +0 -0
- data/lib/rules/rule_mappings.rb +10 -0
- data/lib/{rule_match.rb → rules/rule_match.rb} +5 -3
- data/lib/targets/README-NOTE.txt +2 -0
- data/lib/targets/file_target.rb +65 -0
- data/lib/targets/stream_target.rb +9 -0
- data/lib/targets/string_target.rb +9 -0
- data/lib/templates/base_template.rb +3 -2
- data/lib/templates/html_template.rb +1 -2
- data/lib/templates/include.rb +2 -0
- data/lib/templates/string_template.rb +24 -25
- data/lib/templates/template_mappings.rb +10 -0
- data/lib/templates/xml_template.rb +28 -29
- data/lib/trace-util-adv.rb +24 -4
- data/lib/{trace_calls.rb → trace_calls/trace_calls.rb} +0 -0
- data/lib/trace_calls/trace_configuration.rb +29 -0
- data/lib/{trace_ext.rb → trace_calls/trace_ext.rb} +10 -9
- data/test/{test_action_handler.rb → action_handler/test_action_handler.rb} +1 -5
- data/test/action_handler/test_create_action_handler.rb +31 -0
- data/test/appenders/test_appender_filters.rb +0 -0
- data/test/appenders/test_appender_tracers.rb +56 -0
- data/test/appenders/test_create_appender.rb +49 -0
- data/test/{test_html_appender.rb → appenders/test_html_appender.rb} +3 -7
- data/test/appenders/test_stream_appender.rb +41 -0
- data/test/appenders/test_template_log_appender.rb +18 -0
- data/test/{test_xml_appender.rb → appenders/test_xml_appender.rb} +0 -0
- data/test/extensions/test_filters_creation.rb +36 -0
- data/test/extensions/test_hash_extensions.rb +208 -0
- data/test/extensions/test_hash_filter_extensions.rb +65 -0
- data/test/extensions/test_set_context.rb +94 -0
- data/test/extensions/test_string_extensions.rb +55 -0
- data/test/extensions/test_symbol_extensions.rb +35 -0
- data/test/{test_filters_chain.rb → filters/chain/test_filters_chain.rb} +2 -1
- data/test/filters/composite/test_composite_class_filter.rb +78 -0
- data/test/filters/composite/test_composite_module_filter.rb +82 -0
- data/test/filters/composite/test_composite_var_filter.rb +103 -0
- data/test/filters/executor/test_filter_exec.rb +80 -0
- data/test/filters/msg_context/test_custom_filters.rb +54 -0
- data/test/filters/simple/test_base_filter.rb +56 -0
- data/test/filters/simple/test_class_filter.rb +75 -0
- data/test/filters/simple/test_instancevar_filter.rb +82 -0
- data/test/filters/simple/test_method_filter.rb +77 -0
- data/test/filters/simple/test_module_filter.rb +63 -0
- data/test/samples/include.rb +1 -0
- data/test/samples/sample_classes.rb +23 -0
- data/test/samples/sample_composite_filters.rb +50 -0
- data/test/samples/sample_filters.rb +58 -0
- data/test/sandbox/matcher.rb +7 -0
- data/test/sandbox/sandbox.rb +25 -0
- data/test/{test_xml_gen.rb → sandbox/test_xml_gen.rb} +0 -0
- data/test/trace_calls/test_configure_.rb +70 -0
- data/test/trace_calls/tracing/test_html_tracing.rb +20 -0
- data/test/trace_calls/tracing/test_logger_tracing.rb +18 -0
- data/test/trace_calls/tracing/test_stream_tracing.rb +17 -0
- data/test/trace_calls/tracing/test_teamplate_log_tracing.rb +18 -0
- data/test/trace_calls/tracing/test_xml_tracing.rb +18 -0
- data/test/tracers/test_create_tracers.rb +46 -0
- data/test/tracers/test_exec_tracers.rb +11 -0
- data/trace-util-adv.gemspec +91 -32
- metadata +91 -32
- data/lib/core_extensions.rb +0 -101
- data/lib/filters/base_filters.rb +0 -178
- data/lib/filters/composite_filters.rb +0 -71
- data/lib/output_templates.rb +0 -5
- data/lib/sample_filters.rb +0 -97
- data/lib/trace_appenders.rb +0 -9
- data/lib/trace_filters.rb +0 -4
- data/test/test_appender.rb +0 -29
- data/test/test_file_appender.rb +0 -32
- data/test/test_filters.rb +0 -112
- data/test/test_filters_create.rb +0 -28
- data/test/test_special_filters.rb +0 -78
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
# for specific instance_vars, match on values (after .to_s on var)
|
|
6
|
+
|
|
7
|
+
# include if @template_path MATCHES 'taglib'
|
|
8
|
+
# exclude if @template_path MATCHES 'rapid_'
|
|
9
|
+
# exclude if @builder MATCHES 'bad_'
|
|
10
|
+
Var_composite_filter = {
|
|
11
|
+
:name => 'template_path',
|
|
12
|
+
:default => :exclude,
|
|
13
|
+
:vars => [
|
|
14
|
+
# include if @template_path MATCHES 'taglib'
|
|
15
|
+
# exclude if @template_path MATCHES 'rapid_'
|
|
16
|
+
{
|
|
17
|
+
:name => 'template_path',
|
|
18
|
+
:var_rules => {
|
|
19
|
+
:include => [/.*\/taglib\/.*/],
|
|
20
|
+
:exclude => [/.*\/rapid_.*/],
|
|
21
|
+
:default => :exclude_and_yield
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
# exclude if @builder MATCHES 'bad_'
|
|
25
|
+
{
|
|
26
|
+
:name => 'builder',
|
|
27
|
+
:var_rules => {
|
|
28
|
+
:exclude => [/.*\/bad.*/],
|
|
29
|
+
:default => :include
|
|
30
|
+
}
|
|
31
|
+
}]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Obj
|
|
35
|
+
attr_accessor :template_path
|
|
36
|
+
|
|
37
|
+
def initialize(value = nil)
|
|
38
|
+
@template_path = value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class TestCompositeInstanceVarFilter < Test::Unit::TestCase
|
|
43
|
+
|
|
44
|
+
def test_composite_var_filter_hash_to_var
|
|
45
|
+
composite_filter = Var_composite_filter
|
|
46
|
+
result = composite_filter.filter_class
|
|
47
|
+
assert_equal Tracing::CompositeInstanceVarFilter, result, "Should result in composite var filter"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_composite_var_filter_hash_to_var
|
|
51
|
+
composite_filter = Var_composite_filter
|
|
52
|
+
result = composite_filter.create_filter
|
|
53
|
+
assert_equal Tracing::CompositeInstanceVarFilter, result.class, "Should result in composite var filter"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_composite_var_filter_from_hash
|
|
57
|
+
composite_filter = Var_composite_filter
|
|
58
|
+
config = {:filters => composite_filter}
|
|
59
|
+
result = config.filters
|
|
60
|
+
assert_equal Tracing::CompositeInstanceVarFilter, result.class, "Should result in composite var filter"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# see allow_action in CompositeInstanceVarFilter, refactor :yield, :include .. as return values!?
|
|
64
|
+
def test_composite_var_filter__var_and_method_match
|
|
65
|
+
composite_filter = Var_composite_filter
|
|
66
|
+
|
|
67
|
+
context = {}
|
|
68
|
+
context.set_context :vars => {:template_path => 'rapid'}
|
|
69
|
+
|
|
70
|
+
options = {:filters => composite_filter}
|
|
71
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
72
|
+
result = exec.filters_allow?('msg', context)
|
|
73
|
+
assert_equal true, result, "Filter should allow passage"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_composite_var_filter__var_not_match
|
|
77
|
+
composite_filter = Var_composite_filter
|
|
78
|
+
|
|
79
|
+
context = {}
|
|
80
|
+
context.set_context :class_name => 'Blip::Blap', :vars => ["template_path"]
|
|
81
|
+
context[:self] = Obj.new "blop"
|
|
82
|
+
|
|
83
|
+
options = {:filters => composite_filter}
|
|
84
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
85
|
+
result = exec.filters_allow?('msg', context)
|
|
86
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_composite_var_filter__method_excluded
|
|
90
|
+
composite_filter = Var_composite_filter
|
|
91
|
+
|
|
92
|
+
context = {}
|
|
93
|
+
context.set_context :class_name => 'Blip::Blap', :vars => ["template_path"]
|
|
94
|
+
context[:self] = Obj.new "a/rapid_x"
|
|
95
|
+
|
|
96
|
+
options = {:filters => composite_filter}
|
|
97
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
98
|
+
result = exec.filters_allow?('msg', context)
|
|
99
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
class TestFilterExec < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@context = {:class_name => "Alpha::Beta::Gamma", :method_name => "meth_a", :vars => {:template_path => 'rapid'}, :args => {:a => 7} }.context
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def teardown
|
|
12
|
+
## Nothing really
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# include method
|
|
16
|
+
def test_single_filter_allow
|
|
17
|
+
im_filter = {:i_method_filter => "meth_b, meth_a"}
|
|
18
|
+
options = {:filters => im_filter}
|
|
19
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
20
|
+
result = exec.filters_allow?('msg', @context)
|
|
21
|
+
assert_equal true, result, "Filter should allow passage"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# exclude method
|
|
26
|
+
def test_single_filter_not_allow
|
|
27
|
+
xm_filter = {:x_method_filter => "meth_b, meth_a"}
|
|
28
|
+
options = {:filters => xm_filter}
|
|
29
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
30
|
+
result = exec.filters_allow?('msg', @context)
|
|
31
|
+
assert_equal false, result, "Filter should not allow passage"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# yield include
|
|
35
|
+
def test_single_filter_yield_include
|
|
36
|
+
xm_filter = {:x_method_filter => "meth_b, meth_c"}
|
|
37
|
+
options = {:filters => xm_filter, :final_yield_action => :include}
|
|
38
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
39
|
+
result = exec.filters_allow?('msg', @context)
|
|
40
|
+
assert_equal true, result, "Filter should not allow passage"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_single_filter_yield_exclude
|
|
44
|
+
xm_filter = {:x_method_filter => "meth_b, meth_c"}
|
|
45
|
+
options = {:filters => xm_filter, :final_yield_action => :exclude}
|
|
46
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
47
|
+
result = exec.filters_allow?('msg', @context)
|
|
48
|
+
assert_equal false, result, "Filter should not allow passage"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_single_filter_yield_exclude_default
|
|
52
|
+
xm_filter = {:x_method_filter => "a,b"}
|
|
53
|
+
# :final_yield_action => :exclude by default
|
|
54
|
+
options = {:filters => xm_filter}
|
|
55
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
56
|
+
result = exec.filters_allow?('msg', @context)
|
|
57
|
+
assert_equal false, result, "Filter should not allow passage"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_two_filters
|
|
61
|
+
im_filter = {:i_method_filter => "meth_b, meth_a"}
|
|
62
|
+
xm_filter = {:x_method_filter => "a,b"}
|
|
63
|
+
options = {:filters => [im_filter, xm_filter] }
|
|
64
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
65
|
+
result = exec.filters_allow?('msg', @context)
|
|
66
|
+
assert_equal true, result, "Should allow passage"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_two_yield_filters
|
|
70
|
+
iy_filter = {:iy_method_filter => "meth_b, meth_a"}
|
|
71
|
+
xy_filter = {:xy_method_filter => "meth_b, meth_c"}
|
|
72
|
+
options = {:filters => [iy_filter, xy_filter]}
|
|
73
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
74
|
+
result = exec.filters_allow?('msg', @context)
|
|
75
|
+
assert_equal true, result, "Should allow passage"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'core_extensions'
|
|
2
|
+
require 'filters/base_filters'
|
|
3
|
+
require 'filters/message_filters'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'extensions/core_extensions'
|
|
7
|
+
require "test/unit"
|
|
8
|
+
|
|
9
|
+
class CustomNameFilter < Tracing::NameFilter
|
|
10
|
+
def allow?(name)
|
|
11
|
+
name == options[:name]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TestSymbolExtensions < Test::Unit::TestCase
|
|
17
|
+
|
|
18
|
+
def setup
|
|
19
|
+
# Procs of this form can be used as filters inside include/exclude lists
|
|
20
|
+
abc_filter = Proc.new {|name| name == 'abc' }
|
|
21
|
+
name_filter = CustomNameFilter.new('rapid')
|
|
22
|
+
@meth_filter_abc = {:i_method_filter => [abc_filter], :default => :exclude}.filters
|
|
23
|
+
@meth_filter_name = {:i_method_filter => [name_filter], :default => :exclude}.filters
|
|
24
|
+
@meth_filter_comb = {:i_method_filter => [abc_filter, name_filter], :default => :exclude}.filters
|
|
25
|
+
|
|
26
|
+
@context_abc = {:modules => ["Hobo"], :class_name => "Dryml", :method_name => "abc"}.context
|
|
27
|
+
@context_rapid = {:modules => ["Hobo"], :class_name => "Dryml", :method_name => "rapid"}.context
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def teardown
|
|
31
|
+
## Nothing really
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_custom_name_filter
|
|
35
|
+
res = @meth_filter_name.allow?("hello", @context)
|
|
36
|
+
assert_equal true, res, "Should allow since matching method name 'abc'"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_custom_proc_filter
|
|
40
|
+
res = @meth_filter_abc.allow?("hello", @context)
|
|
41
|
+
assert_equal true, res, "Should allow since matching method name 'rapid'"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_custom_filters
|
|
45
|
+
@meth_filter_comb.allow?("hello", @context)
|
|
46
|
+
assert_equal true, res, "Should allow since matching method name 'abc'"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'filters/base_filters'
|
|
2
|
+
require "test/unit"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestBaseFilter < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
## Nothing really
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_default_name
|
|
15
|
+
bf = Tracing::BaseFilter.new
|
|
16
|
+
assert_equal "Unknown filter", bf.name, "Should result name:'Unknown filter'"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_create_w_name
|
|
20
|
+
bf = Tracing::BaseFilter.new({:name => 'base'})
|
|
21
|
+
assert_equal "base", bf.name, "Should result in name:'base'"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_create_w_name
|
|
25
|
+
bf = Tracing::BaseFilter.new({:name => 'base'})
|
|
26
|
+
assert_equal "base", bf.name, "Should result in name:'base'"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_register_filters
|
|
30
|
+
bf = Tracing::BaseFilter.new({:name => 'base'})
|
|
31
|
+
bF = Tracing::BaseFilter
|
|
32
|
+
f1 = {:x => :y}
|
|
33
|
+
bF.register_filters(f1)
|
|
34
|
+
assert_equal f1, bF.filters, "Should result in x=>y filter"
|
|
35
|
+
f2 = {:z => :a}
|
|
36
|
+
bF.register_filters(f2)
|
|
37
|
+
expect = {:z=>:a, :x=>:y}
|
|
38
|
+
assert_equal expect, bF.filters, "Should result in x=>y and z=>a filter"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_unregister_filters
|
|
42
|
+
bf = Tracing::BaseFilter.new({:name => 'base'})
|
|
43
|
+
bF = Tracing::BaseFilter
|
|
44
|
+
# clear old filters
|
|
45
|
+
bF.filters = {}
|
|
46
|
+
f1 = {:x => :y}
|
|
47
|
+
bF.unregister_filters(f1)
|
|
48
|
+
assert_equal({}, bF.filters, "Should result in empty filter")
|
|
49
|
+
f2 = {:z => :a, :x => :y}
|
|
50
|
+
bF.register_filters(f2)
|
|
51
|
+
bF.unregister_filters(f1)
|
|
52
|
+
expect = {:z=>:a}
|
|
53
|
+
assert_equal expect, bF.filters, "Should result in z=>a filter"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
Class_filter = {
|
|
6
|
+
:name => 'my classes',
|
|
7
|
+
:class_rules => [{
|
|
8
|
+
# id of class rule set
|
|
9
|
+
:name => 'my_classes',
|
|
10
|
+
:include => [/Dryml/],
|
|
11
|
+
:exclude => [/NotMy/],
|
|
12
|
+
:default => :yield
|
|
13
|
+
}]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class TestFilter < Test::Unit::TestCase
|
|
17
|
+
|
|
18
|
+
def test_class_filter_hash_to_class
|
|
19
|
+
class_filter = Class_filter
|
|
20
|
+
result = class_filter.filter_class
|
|
21
|
+
assert_equal Tracing::ClassFilter, result, "Should result in class filter"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_class_filter_hash_to_class
|
|
25
|
+
class_filter = Class_filter
|
|
26
|
+
result = class_filter.create_filter
|
|
27
|
+
assert_equal Tracing::ClassFilter, result.class, "Should result in class filter"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_class_filter_from_hash
|
|
32
|
+
class_filter = Class_filter
|
|
33
|
+
config = {:filters => class_filter}
|
|
34
|
+
result = config.filters
|
|
35
|
+
assert_equal Tracing::ClassFilter, result.class, "Should result in method filter"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# see allow_action in ClassFilter, refactor :yield, :include .. as return values!?
|
|
39
|
+
def test_class_filter__class_and_method_match
|
|
40
|
+
class_filter = Class_filter
|
|
41
|
+
|
|
42
|
+
context = {}
|
|
43
|
+
context.set_context :class_name => "Dryml", :method_name => "build_a"
|
|
44
|
+
|
|
45
|
+
options = {:filters => class_filter}
|
|
46
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
47
|
+
result = exec.filters_allow?('msg', context)
|
|
48
|
+
assert_equal true, result, "Filter should allow passage"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_class_filter__class_not_match
|
|
52
|
+
class_filter = Class_filter
|
|
53
|
+
|
|
54
|
+
context = {}
|
|
55
|
+
context.set_context :class_name => 'Blip::Blap'
|
|
56
|
+
|
|
57
|
+
options = {:filters => class_filter}
|
|
58
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
59
|
+
result = exec.filters_allow?('msg', context)
|
|
60
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_class_filter__method_excluded
|
|
64
|
+
class_filter = Class_filter
|
|
65
|
+
|
|
66
|
+
context = {}
|
|
67
|
+
context.set_context :class_name => "Hobo::Blip"
|
|
68
|
+
|
|
69
|
+
options = {:filters => class_filter}
|
|
70
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
71
|
+
result = exec.filters_allow?('msg', context)
|
|
72
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
InstanceVar_filter = {
|
|
6
|
+
:name => 'check template path',
|
|
7
|
+
:var_name => 'template_path',
|
|
8
|
+
:var_rules => {
|
|
9
|
+
:include => [/.*\/taglib\/.*/],
|
|
10
|
+
:exclude => [/.*\/rapid_.*/],
|
|
11
|
+
:default => :exclude
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class Obj
|
|
16
|
+
attr_accessor :template_path
|
|
17
|
+
|
|
18
|
+
def initialize(value = nil)
|
|
19
|
+
@template_path = value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class TestInstanceVarFilter < Test::Unit::TestCase
|
|
24
|
+
|
|
25
|
+
def test_varfilter_hash_to_class
|
|
26
|
+
var_filter = InstanceVar_filter
|
|
27
|
+
result = var_filter.filter_class
|
|
28
|
+
assert_equal Tracing::InstanceVarFilter, result, "Should result in var filter"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_varfilter_hash_to_class
|
|
32
|
+
var_filter = InstanceVar_filter
|
|
33
|
+
result = var_filter.create_filter
|
|
34
|
+
assert_equal Tracing::InstanceVarFilter, result.class, "Should result in var filter"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_varfilter_from_hash
|
|
39
|
+
var_filter = InstanceVar_filter
|
|
40
|
+
config = {:filters => var_filter}
|
|
41
|
+
result = config.filters
|
|
42
|
+
assert_equal Tracing::InstanceVarFilter, result.class, "Should result in var filter"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# see allow_action in InstanceVarFilter, refactor :yield, :include .. as return values!?
|
|
46
|
+
def test_varfilter__class_and_varmatch
|
|
47
|
+
var_filter = InstanceVar_filter
|
|
48
|
+
context = {:class_name => "Hobo::Dryml", :vars => {"template_path" => "a/taglib/x"} }.context
|
|
49
|
+
|
|
50
|
+
options = {:filters => var_filter}
|
|
51
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
52
|
+
result = exec.filters_allow?('msg', context)
|
|
53
|
+
assert_equal true, result, "Filter should allow passage"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_varfilter__varnot_match
|
|
57
|
+
var_filter = InstanceVar_filter
|
|
58
|
+
|
|
59
|
+
context = {:class_name => 'Blip::Blap', :vars => {"template_path" => "a/taglib/x"}, :self => Obj.new("blop") }.context
|
|
60
|
+
|
|
61
|
+
puts "Context:" + context.inspect
|
|
62
|
+
|
|
63
|
+
options = {:filters => var_filter}
|
|
64
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
65
|
+
result = exec.filters_allow?('msg', context)
|
|
66
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_varfilter__varexcluded
|
|
70
|
+
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
|
+
|
|
75
|
+
|
|
76
|
+
options = {:filters => var_filter}
|
|
77
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
78
|
+
result = exec.filters_allow?('msg', context)
|
|
79
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
Method_filter = {
|
|
6
|
+
:name => 'my methods',
|
|
7
|
+
:method_rules => [{
|
|
8
|
+
# id of method rule set
|
|
9
|
+
:name => 'my_methods',
|
|
10
|
+
:include => [/by.*/, 'build_a', 'do_it'],
|
|
11
|
+
:exclude => ['add.*'],
|
|
12
|
+
:exclude_and_yield => ['blip'],
|
|
13
|
+
:default => :exclude
|
|
14
|
+
}]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestMethodFilter < Test::Unit::TestCase
|
|
19
|
+
|
|
20
|
+
def test_method_filter_hash_to_class
|
|
21
|
+
composite_filter = Method_filter
|
|
22
|
+
result = composite_filter.filter_class
|
|
23
|
+
assert_equal Tracing::MethodFilter, result, "Should result in method filter"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_method_filter_hash_to_class
|
|
27
|
+
composite_filter = Method_filter
|
|
28
|
+
result = composite_filter.create_filter
|
|
29
|
+
assert_equal Tracing::MethodFilter, result.class, "Should result in method filter"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_method_filter_from_hash
|
|
34
|
+
composite_filter = Method_filter
|
|
35
|
+
config = {:filters => composite_filter}
|
|
36
|
+
result = config.filters
|
|
37
|
+
assert_equal Tracing::MethodFilter, result.class, "Should result in method filter"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# see allow_action in MethodFilter, refactor :yield, :include .. as return values!?
|
|
41
|
+
def test_method_filter__class_and_method_match
|
|
42
|
+
composite_filter = Method_filter
|
|
43
|
+
|
|
44
|
+
context = {}
|
|
45
|
+
context.set_context :class_name => "Hobo::Dryml", :method_name => "build_a"
|
|
46
|
+
|
|
47
|
+
options = {:filters => composite_filter}
|
|
48
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
49
|
+
result = exec.filters_allow?('msg', context)
|
|
50
|
+
assert_equal true, result, "Filter should allow passage"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_method_filter__method_not_match
|
|
54
|
+
composite_filter = Method_filter
|
|
55
|
+
|
|
56
|
+
context = {}
|
|
57
|
+
context.set_context :class_name => 'Blip::Blap', :method_name => "blop"
|
|
58
|
+
|
|
59
|
+
options = {:filters => composite_filter}
|
|
60
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
61
|
+
result = exec.filters_allow?('msg', context)
|
|
62
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_method_filter__method_excluded
|
|
66
|
+
composite_filter = Method_filter
|
|
67
|
+
|
|
68
|
+
context = {}
|
|
69
|
+
context.set_context :class_name => "Hobo::Dryml", :method_name => "add_it"
|
|
70
|
+
|
|
71
|
+
options = {:filters => composite_filter}
|
|
72
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
73
|
+
result = exec.filters_allow?('msg', context)
|
|
74
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'filters/filter_exec'
|
|
2
|
+
require 'extensions/core_extensions'
|
|
3
|
+
require "test/unit"
|
|
4
|
+
|
|
5
|
+
Module_filter = {
|
|
6
|
+
:name => 'my modules',
|
|
7
|
+
:module_rules => [{
|
|
8
|
+
# id of modules rule set
|
|
9
|
+
:name => ['my_modules'],
|
|
10
|
+
:include => [/Hobo/],
|
|
11
|
+
:exclude => [/Dryml/],
|
|
12
|
+
:default => :exclude
|
|
13
|
+
}
|
|
14
|
+
]}
|
|
15
|
+
|
|
16
|
+
class TestModuleFilter < Test::Unit::TestCase
|
|
17
|
+
|
|
18
|
+
def test_module_filter_hash_to_module
|
|
19
|
+
_filter = Module_filter
|
|
20
|
+
result = _filter.filter_module
|
|
21
|
+
assert_equal Tracing::ModuleFilter, result, "Should result in module filter"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_module_filter_hash_to_module
|
|
25
|
+
_filter = Module_filter
|
|
26
|
+
result = _filter.create_filter
|
|
27
|
+
assert_equal Tracing::ModuleFilter, result.class, "Should result in module filter"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_module_filter_from_hash
|
|
31
|
+
_filter = Module_filter
|
|
32
|
+
config = {:filters => _filter}
|
|
33
|
+
result = config.filters
|
|
34
|
+
assert_equal Tracing::ModuleFilter, result.class, "Should result in module filter"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# see allow_action in ModuleFilter, refactor :yield, :include .. as return values!?
|
|
38
|
+
def test_module_filter__module_and_method_match
|
|
39
|
+
_filter = Module_filter
|
|
40
|
+
|
|
41
|
+
context = {}
|
|
42
|
+
context.set_context :modules => ["Hobo"], :method_name => "build_a" #, :class_name => "Dryml"
|
|
43
|
+
|
|
44
|
+
options = {:filters => _filter}
|
|
45
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
46
|
+
result = exec.filters_allow?('msg', context)
|
|
47
|
+
assert_equal true, result, "Filter should allow passage"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_module_filter__module_not_match
|
|
52
|
+
_filter = Module_filter
|
|
53
|
+
|
|
54
|
+
context = {}
|
|
55
|
+
context.set_context :modules => ['Blip', 'Blap']
|
|
56
|
+
|
|
57
|
+
options = {:filters => _filter}
|
|
58
|
+
exec = Tracing::Filter::Executor.new(options)
|
|
59
|
+
result = exec.filters_allow?('msg', context)
|
|
60
|
+
assert_equal false, result, "Filter should NOT allow passage"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), '**/*.rb')).each {|f| require f }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# configure use of TraceExt
|
|
2
|
+
module Me
|
|
3
|
+
class My
|
|
4
|
+
|
|
5
|
+
def hello
|
|
6
|
+
puts "Hello cruel World!"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def hi_there
|
|
10
|
+
puts "Hello cruel World!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def blip
|
|
14
|
+
puts "Blip!"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def blap
|
|
18
|
+
puts "Blap!"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Class_composite_filter_A = {
|
|
2
|
+
# id of composite rule set
|
|
3
|
+
:name => 'Template stuff',
|
|
4
|
+
:classes => [{
|
|
5
|
+
:names => ['My', /My/],
|
|
6
|
+
:method_rules => {
|
|
7
|
+
:include => [/by.*/, 'DRYMLBuilder'],
|
|
8
|
+
:exclude => ['Taglib'],
|
|
9
|
+
:default => :exclude
|
|
10
|
+
}
|
|
11
|
+
}]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Module_composite_filter_A = {
|
|
15
|
+
# id of composite rule set
|
|
16
|
+
:name => 'dryml_filter',
|
|
17
|
+
:modules => [{
|
|
18
|
+
:names => ['Hobo:Dryml', /Dryml/],
|
|
19
|
+
:class_rules => {
|
|
20
|
+
:include => [/Template.*/, 'DRYMLBuilder'],
|
|
21
|
+
:exclude => ['Taglib'],
|
|
22
|
+
:default => :include
|
|
23
|
+
},
|
|
24
|
+
:method_rules => {
|
|
25
|
+
:include => [/Template.*/, 'DRYMLBuilder'],
|
|
26
|
+
:exclude => ['Taglib'],
|
|
27
|
+
:default => :include
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# for specific instance_vars, match on values (after .to_s on var)
|
|
34
|
+
Var_composite_filter_A = {
|
|
35
|
+
:name => 'template_path',
|
|
36
|
+
:vars => [{
|
|
37
|
+
:name => 'template_path', :type => :string,
|
|
38
|
+
:var_rules => {
|
|
39
|
+
:include => [/.*\/taglib\/.*/],
|
|
40
|
+
:exclude => [/.*\/rapid_.*/]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
:name => 'template_path',
|
|
45
|
+
:var_rules => {
|
|
46
|
+
:exclude => [/.*\/rapid_.*/],
|
|
47
|
+
:default => :include
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
}
|