uttk 0.3.1.2
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/AUTHORS +36 -0
- data/COPYING +18 -0
- data/ChangeLog +7673 -0
- data/GUIDELINES +86 -0
- data/LGPL +504 -0
- data/NEWS +158 -0
- data/NORM +137 -0
- data/README +180 -0
- data/Rakefile +8 -0
- data/SPEC.gemspec +15 -0
- data/SPEC.yml +60 -0
- data/TODO +23 -0
- data/TODO.old +31 -0
- data/VERSION +5 -0
- data/bin/getopts/uttk.rb +390 -0
- data/bin/uttk +188 -0
- data/bin/uttk-unit +125 -0
- data/lib/uttk.rb +288 -0
- data/lib/uttk/dumpers/Basic.rb +23 -0
- data/lib/uttk/dumpers/BasicColor.rb +35 -0
- data/lib/uttk/dumpers/Dumper.rb +77 -0
- data/lib/uttk/dumpers/Html.rb +271 -0
- data/lib/uttk/dumpers/Path.rb +24 -0
- data/lib/uttk/dumpers/Xml.rb +88 -0
- data/lib/uttk/dumpers/Yaml.rb +138 -0
- data/lib/uttk/filters.rb +128 -0
- data/lib/uttk/filters/Buffer.rb +119 -0
- data/lib/uttk/filters/Compact.rb +75 -0
- data/lib/uttk/filters/Default.rb +27 -0
- data/lib/uttk/filters/DefaultColor.rb +27 -0
- data/lib/uttk/filters/Filter.rb +53 -0
- data/lib/uttk/filters/Id.rb +30 -0
- data/lib/uttk/filters/JustStatus.rb +25 -0
- data/lib/uttk/filters/KeepSkipBased.rb +38 -0
- data/lib/uttk/filters/NodeCut.rb +97 -0
- data/lib/uttk/filters/RPathFilter.rb +134 -0
- data/lib/uttk/filters/Saver.rb +53 -0
- data/lib/uttk/filters/TextFilter.rb +69 -0
- data/lib/uttk/generators/dumper_generator.rb +28 -0
- data/lib/uttk/generators/filter_generator.rb +28 -0
- data/lib/uttk/generators/generator.rb +86 -0
- data/lib/uttk/generators/generator_generator.rb +26 -0
- data/lib/uttk/generators/loader_generator.rb +28 -0
- data/lib/uttk/generators/path_filter_generator.rb +28 -0
- data/lib/uttk/generators/strategy_generator.rb +28 -0
- data/lib/uttk/generators/templates/dumper.rb +50 -0
- data/lib/uttk/generators/templates/filter.rb +50 -0
- data/lib/uttk/generators/templates/generator.rb +28 -0
- data/lib/uttk/generators/templates/loader.rb +26 -0
- data/lib/uttk/generators/templates/path_filter.rb +28 -0
- data/lib/uttk/generators/templates/strategy.rb +59 -0
- data/lib/uttk/generators/templates/strategy.yml +28 -0
- data/lib/uttk/generators/templates/unit_test.rb +46 -0
- data/lib/uttk/loaders/Loader.rb +180 -0
- data/lib/uttk/loaders/Ruby.rb +28 -0
- data/lib/uttk/loaders/Yaml.rb +98 -0
- data/lib/uttk/logger.rb +306 -0
- data/lib/uttk/logger/backend.rb +170 -0
- data/lib/uttk/logger/path.rb +202 -0
- data/lib/uttk/logger/section_node.rb +214 -0
- data/lib/uttk/logger/severity.rb +63 -0
- data/lib/uttk/logger/to_uttk_log.rb +127 -0
- data/lib/uttk/logger/verbosity.rb +61 -0
- data/lib/uttk/logger_factory.rb +55 -0
- data/lib/uttk/path_filters/ColorStatus.rb +57 -0
- data/lib/uttk/path_filters/PathFilter.rb +27 -0
- data/lib/uttk/path_filters/RemoveTypes.rb +25 -0
- data/lib/uttk/status.rb +146 -0
- data/lib/uttk/strategies/Abort.rb +24 -0
- data/lib/uttk/strategies/Assert.rb +44 -0
- data/lib/uttk/strategies/Authors.rb +45 -0
- data/lib/uttk/strategies/Block.rb +113 -0
- data/lib/uttk/strategies/Bootstrap.rb +55 -0
- data/lib/uttk/strategies/Checkout.rb +64 -0
- data/lib/uttk/strategies/Clean.rb +29 -0
- data/lib/uttk/strategies/Cmd.rb +60 -0
- data/lib/uttk/strategies/CmdBase.rb +130 -0
- data/lib/uttk/strategies/Collection.rb +158 -0
- data/lib/uttk/strategies/Compile.rb +59 -0
- data/lib/uttk/strategies/Composite.rb +201 -0
- data/lib/uttk/strategies/Composite/contents_eval.rb +40 -0
- data/lib/uttk/strategies/Configure.rb +66 -0
- data/lib/uttk/strategies/Error.rb +23 -0
- data/lib/uttk/strategies/Fail.rb +26 -0
- data/lib/uttk/strategies/IOBased.rb +159 -0
- data/lib/uttk/strategies/Import.rb +60 -0
- data/lib/uttk/strategies/Iterate.rb +139 -0
- data/lib/uttk/strategies/JUnit.rb +205 -0
- data/lib/uttk/strategies/KillAll.rb +62 -0
- data/lib/uttk/strategies/Make.rb +94 -0
- data/lib/uttk/strategies/Package.rb +129 -0
- data/lib/uttk/strategies/PackageCollection.rb +78 -0
- data/lib/uttk/strategies/Pass.rb +24 -0
- data/lib/uttk/strategies/Pool.rb +104 -0
- data/lib/uttk/strategies/ProbabilityThreshold.rb +46 -0
- data/lib/uttk/strategies/Proxy.rb +42 -0
- data/lib/uttk/strategies/RMatch.rb +92 -0
- data/lib/uttk/strategies/RUnit.rb +132 -0
- data/lib/uttk/strategies/SignalCmd.rb +85 -0
- data/lib/uttk/strategies/Sleep.rb +36 -0
- data/lib/uttk/strategies/SqlQuery.rb +120 -0
- data/lib/uttk/strategies/Strategy.rb +683 -0
- data/lib/uttk/strategies/Stub.rb +37 -0
- data/lib/uttk/strategies/SubCmd.rb +77 -0
- data/lib/uttk/strategies/Suite.rb +71 -0
- data/lib/uttk/strategies/Test.rb +89 -0
- data/lib/uttk/streams.rb +69 -0
- data/lib/uttk/streams/Diff.rb +60 -0
- data/lib/uttk/streams/HexaDiff.rb +35 -0
- data/lib/uttk/streams/Stream.rb +76 -0
- data/lib/uttk/weights.rb +17 -0
- data/lib/uttk/weights/WExpr.rb +68 -0
- data/lib/uttk/weights/WFloat.rb +23 -0
- data/lib/uttk/weights/WMin.rb +22 -0
- data/lib/uttk/weights/Weight.rb +105 -0
- data/lib/www/javascripts/uttk.js +185 -0
- data/misc/expandtab.rb +29 -0
- data/misc/header.rb +44 -0
- data/misc/renaming +57 -0
- data/misc/textile_compiler +194 -0
- data/misc/uttk-grep.sh +8 -0
- data/misc/uttk-line-count.rb +143 -0
- data/test/examples-suite.yml +8 -0
- data/test/examples/README +68 -0
- data/test/examples/basic.rb +10 -0
- data/test/examples/basic.yml +9 -0
- data/test/examples/cache/cache_and_fatal.yml +5 -0
- data/test/examples/cache/simple.yml +30 -0
- data/test/examples/sql/basic.yml +24 -0
- data/test/examples/students-suite.yml +9 -0
- data/test/examples/students/ball.yml +11 -0
- data/test/examples/students/glob_stud.yml +20 -0
- data/test/examples/students/mini-lib.yml +61 -0
- data/test/examples/students/pool_stud.yml +31 -0
- data/test/examples/students/stud.yml +21 -0
- data/test/fixtures/ball/20040804-exam_a1-zapngo-tessar_m.tar.gz +0 -0
- data/test/fixtures/ball/Makefile +24 -0
- data/test/fixtures/ball/bar_p-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/bar_p-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/bar_p-mini-lib/my_strlen.c +13 -0
- data/test/fixtures/ball/foo_s-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/foo_s-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/foo_s-mini-lib/configure +2 -0
- data/test/fixtures/ball/foo_s-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/hello.tar.bz2 +0 -0
- data/test/fixtures/ball/hello.tar.gz +0 -0
- data/test/fixtures/ball/hello/Makefile +14 -0
- data/test/fixtures/ball/hello/hello.c +7 -0
- data/test/fixtures/ball/jack-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/jack-exit/Makefile +14 -0
- data/test/fixtures/ball/jack-exit/exit.c +16 -0
- data/test/fixtures/ball/joe-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/joe-exit/Makefile +14 -0
- data/test/fixtures/ball/joe-exit/exit.c +8 -0
- data/test/fixtures/ball/joe_i-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/joe_i-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/joe_i-mini-lib/configure +2 -0
- data/test/fixtures/ball/joe_i-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/john-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/john-exit/Makefile +14 -0
- data/test/fixtures/ball/john-exit/exit.c +6 -0
- data/test/fixtures/ball/qux_j-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/qux_j-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/qux_j-mini-lib/my_strlen.c +12 -0
- data/test/fixtures/binaries/segv +0 -0
- data/test/fixtures/binaries/segv.c +10 -0
- data/test/fixtures/binaries/segv.rb +2 -0
- data/test/fixtures/demo/command-tutorial/steps/1/check.yml +5 -0
- data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/3/check.yml +14 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +12 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5/check.yml +16 -0
- data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +16 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6/check.yml +21 -0
- data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/7/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +17 -0
- data/test/fixtures/demo/filter-tutorial/check.yml +20 -0
- data/test/fixtures/demo/filter-tutorial/filters/CutSkip100.rb +19 -0
- data/test/fixtures/demo/filter-tutorial/pluralizer.rb +17 -0
- data/test/fixtures/java/unit/MultiRight/Foo/Foo.java +11 -0
- data/test/fixtures/java/unit/MultiRight/Foo/FooTest.java +15 -0
- data/test/fixtures/java/unit/MultiRight/MultiRight.java +13 -0
- data/test/fixtures/java/unit/MultiRight/MultiRightTest.java +12 -0
- data/test/fixtures/java/unit/MultiRight/bar/Bar.java +11 -0
- data/test/fixtures/java/unit/MultiRight/bar/BarTest.java +21 -0
- data/test/fixtures/java/unit/MultiRight/build.sh +7 -0
- data/test/fixtures/java/unit/SimpleException/SimpleExceptionTest.java +11 -0
- data/test/fixtures/java/unit/SimpleException/build.sh +4 -0
- data/test/fixtures/java/unit/build.sh +9 -0
- data/test/fixtures/java/unit/multibar.yml +6 -0
- data/test/fixtures/java/unit/multifoo.yml +6 -0
- data/test/fixtures/java/unit/multiright.yml +8 -0
- data/test/fixtures/java/unit/simple_exception.yml +6 -0
- data/test/fixtures/mini-lib/Makefile +9 -0
- data/test/fixtures/mini-lib/strlen.c +15 -0
- data/test/fixtures/package/pkg_foo.tar.gz +0 -0
- data/test/fixtures/package/pkg_foo/Makefile +20 -0
- data/test/fixtures/package/pkg_foo/bootstrap +3 -0
- data/test/fixtures/package/pkg_foo/configure +3 -0
- data/test/fixtures/package/pkg_foo/foo.sh +2 -0
- data/test/fixtures/text/1.txt +4 -0
- data/test/fixtures/unit/bad.rb +26 -0
- data/test/fixtures/unit/error.rb +6 -0
- data/test/fixtures/unit/good.rb +26 -0
- data/test/functional-suite.yml +10 -0
- data/test/functional/author.yml +11 -0
- data/test/functional/base.yml +119 -0
- data/test/functional/base_pool.yml +13 -0
- data/test/functional/block.yml +13 -0
- data/test/functional/cat.yml +16 -0
- data/test/functional/cmd.yml +17 -0
- data/test/functional/diff.yml +27 -0
- data/test/functional/env_cmd.yml +53 -0
- data/test/functional/exit.yml +15 -0
- data/test/functional/fatal.yml +23 -0
- data/test/functional/glob.yml +11 -0
- data/test/functional/hexa-diff.yml +25 -0
- data/test/functional/import.yml +41 -0
- data/test/functional/iterate.yml +99 -0
- data/test/functional/killall.yml +31 -0
- data/test/functional/pkg.yml +14 -0
- data/test/functional/probability_threshold.yml +35 -0
- data/test/functional/r_unit.yml +26 -0
- data/test/functional/rmatch.yml +122 -0
- data/test/functional/signal_cmd.yml +22 -0
- data/test/functional/sub.yml +15 -0
- data/test/functional/test.yml +25 -0
- data/test/functional/timeout.yml +20 -0
- data/test/functional/wc.yml +26 -0
- data/test/functional/weight.yml +152 -0
- data/test/pkg-suite.yml +8 -0
- data/test/pkg/cmdline.yml +80 -0
- data/test/pool-suite.yml +8 -0
- data/test/pool/base.yml +12 -0
- data/test/pool/pool.yml +25 -0
- data/test/ruby-suite.rb +10 -0
- data/test/ruby-suite.yml +5 -0
- data/test/ruby/base.rb +119 -0
- data/test/ruby/iterate.rb +21 -0
- data/test/ruby/wc.rb +43 -0
- data/test/unit-suite.yml +10 -0
- data/test/unit/dumpers/path_test.rb +46 -0
- data/test/unit/dumpers/xml_test.rb +65 -0
- data/test/unit/dumpers/yaml_test.rb +65 -0
- data/test/unit/filters/buffer_test.rb +168 -0
- data/test/unit/filters/keep_skip_based_test.rb +46 -0
- data/test/unit/filters/node_cut_test.rb +72 -0
- data/test/unit/filters/rpath_filter_test.rb +191 -0
- data/test/unit/filters/text_filter_test.rb +46 -0
- data/test/unit/filters_test.rb +119 -0
- data/test/unit/logger/section_node_test.rb +120 -0
- data/test/unit/logger/severity_test.rb +37 -0
- data/test/unit/logger/to_uttk_log_test.rb +113 -0
- data/test/unit/logger/verbosity_test.rb +44 -0
- data/test/unit/logger_test.rb +203 -0
- data/test/unit/strategies/suite_test.rb +151 -0
- data/test/uttk-check.yml +8 -0
- data/test/uttk-distcheck.yml +18 -0
- metadata +399 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/logger/path.rb 22244 2006-02-25T10:48:53.146614Z pouillar $
|
|
5
|
+
|
|
6
|
+
require 'forwardable'
|
|
7
|
+
|
|
8
|
+
module Uttk
|
|
9
|
+
|
|
10
|
+
class Logger
|
|
11
|
+
|
|
12
|
+
class Segment
|
|
13
|
+
attr_accessor :segment, :options
|
|
14
|
+
def initialize ( segment, options=nil )
|
|
15
|
+
raise if segment.is_a? Segment
|
|
16
|
+
@segment, @options = segment, (options || {})
|
|
17
|
+
end
|
|
18
|
+
def initialize_copy ( rhs )
|
|
19
|
+
@segment, @options = rhs.segment.try_dup, rhs.options.dup
|
|
20
|
+
end
|
|
21
|
+
def == ( rhs )
|
|
22
|
+
rhs.is_a?(self.class) && @segment == rhs.segment && @options == rhs.options
|
|
23
|
+
end
|
|
24
|
+
def self.quote ( s )
|
|
25
|
+
s.gsub(/(?:([\/\]\[])|\\(.))/, '\\\\\1\2')
|
|
26
|
+
end
|
|
27
|
+
def quoted_segment
|
|
28
|
+
Segment.quote(@segment.to_s)
|
|
29
|
+
end
|
|
30
|
+
def regexp_quoted_segment
|
|
31
|
+
Segment.quote(Regexp.quote(@segment.to_s))
|
|
32
|
+
end
|
|
33
|
+
end # class Segment
|
|
34
|
+
|
|
35
|
+
class Path
|
|
36
|
+
|
|
37
|
+
def initialize ( anArray=[] )
|
|
38
|
+
@contents = []
|
|
39
|
+
anArray.each { |x| self << x }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def initialize_copy ( rhs )
|
|
43
|
+
@contents = rhs.instance_variable_get(:@contents).map { |x| x.dup }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
extend Forwardable
|
|
47
|
+
|
|
48
|
+
def_delegators :@contents, :map, :size, :each, :each_with_index, :[],
|
|
49
|
+
:empty?, :last, :pop, :delete_if
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def << ( seg )
|
|
53
|
+
@contents <<
|
|
54
|
+
case seg
|
|
55
|
+
when Segment then seg
|
|
56
|
+
else Segment.new seg
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def to_a
|
|
62
|
+
map { |x| x.segment }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def + ( rhs )
|
|
67
|
+
if rhs.is_a? Path
|
|
68
|
+
tab = rhs.instance_variable_get(:@contents)
|
|
69
|
+
else
|
|
70
|
+
tab = rhs.to_a
|
|
71
|
+
end
|
|
72
|
+
self.class.new(@contents + tab)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def to_s
|
|
77
|
+
'/' + map { |x| x.quoted_segment }.join('/')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def inspect
|
|
82
|
+
return '/' if @contents.empty?
|
|
83
|
+
result = ''
|
|
84
|
+
each do |seg|
|
|
85
|
+
result << '/' << seg.quoted_segment
|
|
86
|
+
unless seg.options.empty?
|
|
87
|
+
opts = []
|
|
88
|
+
opts << 'ordered' if seg.options[:ordered]
|
|
89
|
+
if type = seg.options[:type]
|
|
90
|
+
opts << "type: #{type}"
|
|
91
|
+
end
|
|
92
|
+
result << '[' << opts.join(', ') << ']'
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
result
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def to_regex_path_string
|
|
99
|
+
'/' + map { |x| x.regexp_quoted_segment }.join('/')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def to_regex_path
|
|
104
|
+
RegexPath.new(to_regex_path_string)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def rpath ( re, &block )
|
|
109
|
+
# We work with uncaptured path here
|
|
110
|
+
|
|
111
|
+
args = []
|
|
112
|
+
|
|
113
|
+
raise NotImplementedError unless re.root? or re.final?
|
|
114
|
+
|
|
115
|
+
re_segs = re.segments
|
|
116
|
+
segs = to_a
|
|
117
|
+
|
|
118
|
+
if re.final?
|
|
119
|
+
re_segs = re_segs.reverse
|
|
120
|
+
segs = segs.reverse
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
re_segs.zip(segs).each do |re_seg, seg|
|
|
124
|
+
if re.negative?
|
|
125
|
+
break if seg.nil? or re_seg !~ seg.to_s
|
|
126
|
+
return
|
|
127
|
+
else
|
|
128
|
+
return if seg.nil?
|
|
129
|
+
if match_data = re_seg =~ seg.to_s
|
|
130
|
+
args << match_data.to_a[1..-1]
|
|
131
|
+
else
|
|
132
|
+
return
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
args.reverse! if re.final?
|
|
138
|
+
|
|
139
|
+
block[self, *args.flatten]
|
|
140
|
+
nil
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def rpath_prefix ( re )
|
|
145
|
+
re_segs = re.segments
|
|
146
|
+
re_segs.zip(to_a).each_with_index do |args, i|
|
|
147
|
+
re_seg, seg = args
|
|
148
|
+
return false if seg.nil?
|
|
149
|
+
return false unless re_seg =~ seg.to_s
|
|
150
|
+
re_seg = re_segs[i+1]
|
|
151
|
+
return true if re_seg and re_seg.captured?
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
raise ArgumentError, 'no capture'
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def lpath_prefix ( re )
|
|
159
|
+
re_segs = re.segments
|
|
160
|
+
re_segs.zip(to_a).each_with_index do |args, i|
|
|
161
|
+
re_seg, seg = args
|
|
162
|
+
return true if seg.nil?
|
|
163
|
+
return false unless re_seg =~ seg.to_s
|
|
164
|
+
re_seg = re_segs[i+1]
|
|
165
|
+
return true if re_seg and re_seg.captured?
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
raise ArgumentError, 'no capture'
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def to_logger_path
|
|
173
|
+
self
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def == ( rhs )
|
|
177
|
+
rhs.is_a?(self.class) && @contents == rhs.instance_variable_get(:@contents)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end # class Path
|
|
181
|
+
|
|
182
|
+
end # class Logger
|
|
183
|
+
|
|
184
|
+
end # module Uttk
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class Array
|
|
189
|
+
|
|
190
|
+
def to_logger_path
|
|
191
|
+
obj = Uttk::Logger::Path.new
|
|
192
|
+
each do |x|
|
|
193
|
+
if x.is_a? Array
|
|
194
|
+
obj << Uttk::Logger::Segment.new(*x)
|
|
195
|
+
else
|
|
196
|
+
obj << x
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
obj
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
end # class Array
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/logger/section_node.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
class Logger
|
|
10
|
+
|
|
11
|
+
# Implement a tree of section. A section node has a name and a `active'
|
|
12
|
+
# flag that say if the section node is on/off. A section tree verifies the
|
|
13
|
+
# following property:
|
|
14
|
+
#
|
|
15
|
+
# a node is active iff at least one of its sub nodes is active
|
|
16
|
+
#
|
|
17
|
+
# Obviously, when activating a node, all its sub nodes are also activated.
|
|
18
|
+
class SectionNode
|
|
19
|
+
|
|
20
|
+
def initialize(name, *sub_sections)
|
|
21
|
+
self.name = name
|
|
22
|
+
@sub_sections = {}
|
|
23
|
+
sub_sections.each { |s| self << s }
|
|
24
|
+
@active = false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
attr_reader :name
|
|
28
|
+
|
|
29
|
+
def name=(new_name)
|
|
30
|
+
@name = new_name.to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def sub_sections
|
|
34
|
+
@sub_sections.values
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def [](name)
|
|
38
|
+
@sub_sections[name]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def []=(name, sub_section)
|
|
42
|
+
check_sub_section_type(sub_section)
|
|
43
|
+
sub_section.name = name
|
|
44
|
+
@sub_sections[sub_section.name] = sub_section
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def <<(sub_section)
|
|
48
|
+
check_sub_section_type(sub_section)
|
|
49
|
+
@sub_sections[sub_section.name] = sub_section
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def push(*sub_sections)
|
|
53
|
+
sub_sections.each { |ss| self << ss }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def active=(new_active)
|
|
57
|
+
active_tree(new_active)
|
|
58
|
+
@active
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def active?
|
|
62
|
+
@active
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def active_tree(new_active)
|
|
66
|
+
accu = []
|
|
67
|
+
active_tree_rec(new_active, accu) unless new_active == @active
|
|
68
|
+
accu
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def active_tree_rec(new_active, accu)
|
|
72
|
+
@active = new_active
|
|
73
|
+
accu << @name
|
|
74
|
+
@sub_sections.each_value { |s| s.active_tree_rec(new_active, accu) }
|
|
75
|
+
end
|
|
76
|
+
protected :active_tree_rec
|
|
77
|
+
|
|
78
|
+
# Active the given section name in the tree. Return an array of all the
|
|
79
|
+
# section name that have been activated. The returned array is empty if
|
|
80
|
+
# the section name doesn't exists in the tree.
|
|
81
|
+
def active_section(section_name)
|
|
82
|
+
accu = []
|
|
83
|
+
active_section_rec(section_name, accu)
|
|
84
|
+
accu
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def active_section_rec(section_name, accu)
|
|
88
|
+
if @name == section_name
|
|
89
|
+
accu.concat(active_tree(true))
|
|
90
|
+
true
|
|
91
|
+
else
|
|
92
|
+
ret = false
|
|
93
|
+
@sub_sections.each_value do |s|
|
|
94
|
+
if s.active_section_rec(section_name, accu)
|
|
95
|
+
@active = true
|
|
96
|
+
accu << @name
|
|
97
|
+
ret = true
|
|
98
|
+
break
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
ret
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
protected :active_section_rec
|
|
105
|
+
|
|
106
|
+
# Unactive the given section name in the tree. Return an array of all the
|
|
107
|
+
# section name that have been unactivated. The returned array is empty if
|
|
108
|
+
# the section name doesn't exists in the tree or if none section have
|
|
109
|
+
# been unactivated.
|
|
110
|
+
def unactive_section(section_name)
|
|
111
|
+
accu = []
|
|
112
|
+
unactive_section_rec(section_name, accu)
|
|
113
|
+
accu
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def unactive_section_rec(section_name, accu)
|
|
117
|
+
if @name == section_name
|
|
118
|
+
accu.concat(active_tree(false))
|
|
119
|
+
true
|
|
120
|
+
else
|
|
121
|
+
not_unactivable = ret = false
|
|
122
|
+
@sub_sections.each_value do |s|
|
|
123
|
+
ret ||= s.unactive_section_rec(section_name, accu)
|
|
124
|
+
not_unactivable ||= s.active?
|
|
125
|
+
end
|
|
126
|
+
if ret and (not not_unactivable)
|
|
127
|
+
@active = false
|
|
128
|
+
accu << @name
|
|
129
|
+
true
|
|
130
|
+
else
|
|
131
|
+
false
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
protected :unactive_section_rec
|
|
136
|
+
|
|
137
|
+
def set_active_section(active, *section_names)
|
|
138
|
+
section = []
|
|
139
|
+
section_names.each do |s|
|
|
140
|
+
section.concat(active ? active_section(s) : unactive_section(s))
|
|
141
|
+
end
|
|
142
|
+
section.uniq!
|
|
143
|
+
section
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def each(&block)
|
|
147
|
+
@sub_sections.each(&block)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
alias :each_pair :each
|
|
151
|
+
|
|
152
|
+
def each_section(&block)
|
|
153
|
+
@sub_sections.each_value(&block)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
alias :each_value :each_section
|
|
157
|
+
|
|
158
|
+
def each_label(&block)
|
|
159
|
+
@sub_sections.each_key(&block)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
alias :each_key :each_label
|
|
163
|
+
|
|
164
|
+
def delete(name)
|
|
165
|
+
@sub_sections.delete(name)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def clear(name)
|
|
169
|
+
@sub_sections.clear
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def nb_sub_sections
|
|
173
|
+
@sub_sections.size
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
alias :size :nb_sub_sections
|
|
177
|
+
alias :length :nb_sub_sections
|
|
178
|
+
|
|
179
|
+
def leaf?
|
|
180
|
+
@sub_sections.empty?
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def pre_depth_first(&block)
|
|
184
|
+
block[self]
|
|
185
|
+
@sub_sections.each_value { |s| s.pre_depth_first(&block) }
|
|
186
|
+
nil
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def find(name)
|
|
190
|
+
if @name == name
|
|
191
|
+
self
|
|
192
|
+
else
|
|
193
|
+
@sub_sections.each_value do |s|
|
|
194
|
+
ret = s.find(name)
|
|
195
|
+
return ret unless ret.nil?
|
|
196
|
+
end
|
|
197
|
+
nil
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
protected
|
|
202
|
+
def check_sub_section_type(sub_section)
|
|
203
|
+
unless sub_section.is_a?(self.class)
|
|
204
|
+
raise(TypeError, "`#{sub_section}' - must be a #{self.class}")
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
end # class SectionNode
|
|
209
|
+
|
|
210
|
+
end # class Logger
|
|
211
|
+
|
|
212
|
+
end # module Uttk
|
|
213
|
+
|
|
214
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/logger/severity.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
class Logger
|
|
10
|
+
|
|
11
|
+
module Severity
|
|
12
|
+
|
|
13
|
+
@@labels = %w(DEBUG VERBOSE_INFO INFO WARN ERROR FATAL UNKNOWN)
|
|
14
|
+
@@lower = 0
|
|
15
|
+
@@higher = @@labels.size - 1
|
|
16
|
+
|
|
17
|
+
@@labels.each_with_index do |label, i|
|
|
18
|
+
const_set(label, i)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
module_function
|
|
22
|
+
|
|
23
|
+
def lower
|
|
24
|
+
@@lower
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def higher
|
|
28
|
+
@@higher
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def unshift(*levels)
|
|
32
|
+
levels.each do |l|
|
|
33
|
+
@@lower -= 1
|
|
34
|
+
const_set(l, @@lower)
|
|
35
|
+
@@labels.unshift(l)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def push(*levels)
|
|
40
|
+
levels.each do |l|
|
|
41
|
+
@@higher += 1
|
|
42
|
+
const_set(l, @@higher)
|
|
43
|
+
@@labels.push(l)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# FIXME add the insert method
|
|
48
|
+
|
|
49
|
+
def label(level)
|
|
50
|
+
@@labels[level]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def labels
|
|
54
|
+
@@labels
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end # module Severity
|
|
58
|
+
|
|
59
|
+
end # class Logger
|
|
60
|
+
|
|
61
|
+
end # module Uttk
|
|
62
|
+
|
|
63
|
+
|