uttk 0.3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,138 @@
|
|
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/dumpers/Yaml.rb 21970 2006-02-19T22:15:36.271512Z pouillar $
|
5
|
+
|
6
|
+
class Symbol
|
7
|
+
alias_method :old_to_yaml, :to_yaml
|
8
|
+
def to_yaml ( opts={} )
|
9
|
+
if YAML.have_option? opts, :uttk
|
10
|
+
self.to_s.to_yaml(opts)
|
11
|
+
else
|
12
|
+
old_to_yaml(opts)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class OHash
|
18
|
+
def to_yaml ( opts={} )
|
19
|
+
if YAML.have_option? opts, :uttk
|
20
|
+
YAML::quick_emit(self.object_id, opts) do |out|
|
21
|
+
out.seq('') do |seq|
|
22
|
+
self.each do |k,v|
|
23
|
+
seq.add( { k => v } )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
else
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
module Uttk
|
35
|
+
|
36
|
+
module Dumpers
|
37
|
+
|
38
|
+
class Yaml < Dumper
|
39
|
+
include Concrete
|
40
|
+
|
41
|
+
MAP_INDENT = 2
|
42
|
+
MAP_SHIFT = ' ' * MAP_INDENT
|
43
|
+
OMAP_SHIFT = ' ' * 4
|
44
|
+
|
45
|
+
def initialize ( *a, &b )
|
46
|
+
super
|
47
|
+
@indent = ''
|
48
|
+
@stack_indent = []
|
49
|
+
@endl = true
|
50
|
+
puts '---'
|
51
|
+
@opts = {:uttk => true, :Inline => true}
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def new_node ( path, node )
|
56
|
+
super
|
57
|
+
options = nil
|
58
|
+
if ! path.nil? and ! path.empty?
|
59
|
+
options = path.last.options
|
60
|
+
end
|
61
|
+
puts unless @endl
|
62
|
+
@stack_indent << @indent
|
63
|
+
self << @indent
|
64
|
+
if options.nil? or not options[:ordered]
|
65
|
+
@indent += MAP_SHIFT
|
66
|
+
else
|
67
|
+
self << '- '
|
68
|
+
@indent += OMAP_SHIFT
|
69
|
+
end
|
70
|
+
self << clean_to_yaml(node.segment) << ':'
|
71
|
+
if type = node.options[:type]
|
72
|
+
if type.is_a? Class
|
73
|
+
# FIXME handle this better
|
74
|
+
if HAVE_YAML_TAGURI
|
75
|
+
self << ' !' << type.taguri.sub(/^tag:.*?:/, '')
|
76
|
+
else
|
77
|
+
self << ' ' << type.to_yaml_type
|
78
|
+
end
|
79
|
+
else
|
80
|
+
self << ' !' << type.to_s
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@endl = false
|
84
|
+
end
|
85
|
+
protected :new_node
|
86
|
+
|
87
|
+
|
88
|
+
def new_leaf ( path, leaf )
|
89
|
+
super
|
90
|
+
val = leaf
|
91
|
+
return if val.respond_to?(:hidden)
|
92
|
+
if val.is_a?(String) and val =~ /\n/
|
93
|
+
if val =~ /\A[ \t]/
|
94
|
+
val = "|#{MAP_INDENT}\n#{val}"
|
95
|
+
else
|
96
|
+
val = "|\n#{val}"
|
97
|
+
end
|
98
|
+
val.chomp!
|
99
|
+
else
|
100
|
+
val = clean_to_yaml(val)
|
101
|
+
val = "\n" + val if val =~ /\n/ and val !~ /^\n/
|
102
|
+
end
|
103
|
+
val.gsub!(/[ \t]*\n/, "\n#@indent")
|
104
|
+
print ' ', val, "\n"
|
105
|
+
@endl = true
|
106
|
+
end
|
107
|
+
protected :new_leaf
|
108
|
+
|
109
|
+
|
110
|
+
def up ( path )
|
111
|
+
super
|
112
|
+
@indent = @stack_indent.pop || ''
|
113
|
+
end
|
114
|
+
protected :up
|
115
|
+
|
116
|
+
|
117
|
+
def clean_to_yaml ( val )
|
118
|
+
val = val.to_yaml(@opts)
|
119
|
+
val.sub!(/^--- /, '')
|
120
|
+
val.chomp!
|
121
|
+
val.gsub!(/(^\s*)- \n\s+([^\s-])/, '\1- \2')
|
122
|
+
val = '""' if val == "''"
|
123
|
+
val
|
124
|
+
end
|
125
|
+
private :clean_to_yaml
|
126
|
+
|
127
|
+
|
128
|
+
def update ( *a, &b )
|
129
|
+
super
|
130
|
+
flush
|
131
|
+
end
|
132
|
+
|
133
|
+
end # class Yaml
|
134
|
+
|
135
|
+
end # module Dumpers
|
136
|
+
|
137
|
+
end # module Uttk
|
138
|
+
|
data/lib/uttk/filters.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Author:: Nicolas Despr�s <nicolas.despres@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/filters.rb 22057 2006-02-20T21:40:27.185401Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Filters
|
10
|
+
|
11
|
+
def self.[] ( *yaml_desc )
|
12
|
+
joined_yaml_desc = yaml_desc.join(', ')
|
13
|
+
joined_yaml_desc.sub!(/^\s+/, '')
|
14
|
+
if joined_yaml_desc[0,1] != '{' and joined_yaml_desc[0,1] != '['
|
15
|
+
full_doc = "--- {#{joined_yaml_desc}}"
|
16
|
+
else
|
17
|
+
full_doc = "--- #{joined_yaml_desc}"
|
18
|
+
end
|
19
|
+
create_backend(YAML.load(full_doc)).flatten
|
20
|
+
end
|
21
|
+
|
22
|
+
def Symbol.yaml_load ( val )
|
23
|
+
val.to_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
def Integer.yaml_load ( val )
|
27
|
+
val.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
class FilterOption
|
31
|
+
attr_reader :option
|
32
|
+
def initialize ( anObject )
|
33
|
+
@option = anObject
|
34
|
+
end
|
35
|
+
def to_hash
|
36
|
+
{ self.class.name.demodulize.underscore.to_sym => option }
|
37
|
+
end
|
38
|
+
def self.yaml_load ( anObject )
|
39
|
+
new(superclass.name.demodulize.sub(/Option$/, '').constantize.yaml_load(anObject))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class SymbolOption < FilterOption
|
44
|
+
end
|
45
|
+
|
46
|
+
class RegexpOption < FilterOption
|
47
|
+
end # class RegexpOption
|
48
|
+
|
49
|
+
class IntegerOption < FilterOption
|
50
|
+
end # class IntegerOption
|
51
|
+
|
52
|
+
class BooleanOption < FilterOption
|
53
|
+
def self.yaml_load ( anObject )
|
54
|
+
new(anObject)
|
55
|
+
end
|
56
|
+
end # class BooleanOption
|
57
|
+
|
58
|
+
class Action < SymbolOption
|
59
|
+
have YamlExtension
|
60
|
+
end
|
61
|
+
|
62
|
+
class Keep < RegexpOption
|
63
|
+
have YamlExtension
|
64
|
+
end # class Keep
|
65
|
+
|
66
|
+
class Skip < RegexpOption
|
67
|
+
have YamlExtension
|
68
|
+
end # class Skip
|
69
|
+
|
70
|
+
class Width < IntegerOption
|
71
|
+
have YamlExtension
|
72
|
+
end # class Width
|
73
|
+
|
74
|
+
class Prune < BooleanOption
|
75
|
+
have YamlExtension
|
76
|
+
end # class Prune
|
77
|
+
|
78
|
+
class << self
|
79
|
+
def create_backend ( desc )
|
80
|
+
case desc
|
81
|
+
when Array
|
82
|
+
desc.map { |elt| create_backend(elt) }
|
83
|
+
when String
|
84
|
+
[create_backend_leaf(desc, STDOUT)]
|
85
|
+
when Hash
|
86
|
+
desc.map do |k, v|
|
87
|
+
create_backend_leaf(k, *create_backend(v).flatten)
|
88
|
+
end
|
89
|
+
when FilterOption
|
90
|
+
[desc]
|
91
|
+
when nil
|
92
|
+
[STDOUT]
|
93
|
+
else
|
94
|
+
raise OptionParser::InvalidArgument,
|
95
|
+
"need a string or a hash not #{desc.inspect}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
private :create_backend
|
99
|
+
|
100
|
+
def create_backend_leaf ( aConst, *args )
|
101
|
+
unless aConst.is_a? String
|
102
|
+
raise OptionParser::InvalidArgument,
|
103
|
+
"need a string not #{aConst.inspect}"
|
104
|
+
end
|
105
|
+
if aConst =~ ConstRegexp::RB_CONST
|
106
|
+
if Dumpers.const_defined? aConst
|
107
|
+
return Dumpers.const_get(aConst).new(*args)
|
108
|
+
else
|
109
|
+
if Filters.const_defined? aConst
|
110
|
+
mod = Filters
|
111
|
+
elsif PathFilters.const_defined? aConst
|
112
|
+
mod = PathFilters
|
113
|
+
else
|
114
|
+
return aConst.to_path.open('w')
|
115
|
+
end
|
116
|
+
options, observers = args.partition { |arg| arg.is_a? FilterOption }
|
117
|
+
options = options.inject({}) { |accu, opt| accu.merge! opt.to_hash }
|
118
|
+
return mod.const_get(aConst).new(observers, options)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
aConst.to_path.open('w')
|
122
|
+
end
|
123
|
+
private :create_backend_leaf
|
124
|
+
end
|
125
|
+
|
126
|
+
end # module Filters
|
127
|
+
|
128
|
+
end # module Uttk
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Author:: Yannick Lacaute <lacaut_y@epita.fr>
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: Buffer.rb 645 2005-07-11 21:52:01 thor $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Filters
|
10
|
+
|
11
|
+
#
|
12
|
+
# This basic filter observe a logger and
|
13
|
+
# bufferize all received messages, with a tree formatting.
|
14
|
+
# The buffer can be flushed when the data are not usefull
|
15
|
+
# anymore. That imply that another entity, a kind of controller,
|
16
|
+
# should always be connected to this class.
|
17
|
+
#
|
18
|
+
# The buffer is simple, all notified datas are directly putted inside,
|
19
|
+
# and when a flush is needed (or asked) it erases all datas. So, it
|
20
|
+
# is possible to think to a new class, derived from this one, which
|
21
|
+
# examin more precisely the notifications, and stock into the buffer
|
22
|
+
# just the desired. It could do the same for flush the buffer, just clear
|
23
|
+
# some part of the buffer. The tool Rpath could be very usefull to do that.
|
24
|
+
#
|
25
|
+
# The messages are putted into the buffer in order to make a tree,
|
26
|
+
# only with Hash and OHash objects. So, that tree could be given at
|
27
|
+
# any time.
|
28
|
+
#
|
29
|
+
# The main utiliy of this class is to provide exactly all the
|
30
|
+
# datas that another entity want. Moreover, that ones are given
|
31
|
+
# under a tree form, which allow simple navigation inside, especialy
|
32
|
+
# with the Rpath tool.
|
33
|
+
#
|
34
|
+
class Buffer < Filter
|
35
|
+
include Concrete
|
36
|
+
|
37
|
+
attr_reader :buffer
|
38
|
+
|
39
|
+
def initialize(*a, &b)
|
40
|
+
super
|
41
|
+
reset
|
42
|
+
end
|
43
|
+
|
44
|
+
def reset
|
45
|
+
@buffer = {}
|
46
|
+
@path = [@buffer]
|
47
|
+
@last_node = nil
|
48
|
+
@reset_planned = false
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :clear :reset
|
52
|
+
|
53
|
+
def new_node ( path, node )
|
54
|
+
super
|
55
|
+
value = (node.options[:ordered]) ? OHash.new : {}
|
56
|
+
value[:strategy] = node.options[:type] if node.options.has_key? :type
|
57
|
+
@path.last[node.segment] = value
|
58
|
+
@path << value
|
59
|
+
@last_node = node.segment
|
60
|
+
end
|
61
|
+
protected :new_node
|
62
|
+
|
63
|
+
def new_leaf ( path, leaf )
|
64
|
+
super
|
65
|
+
if @last_node.nil?
|
66
|
+
@buffer = leaf
|
67
|
+
@path = [@buffer]
|
68
|
+
else
|
69
|
+
father = @path[-2]
|
70
|
+
if father[@last_node].is_a? Hash
|
71
|
+
father[@last_node] = leaf
|
72
|
+
else
|
73
|
+
father[@last_node] = [father[@last_node], leaf]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
protected :new_leaf
|
78
|
+
|
79
|
+
def up ( path )
|
80
|
+
super
|
81
|
+
@path.pop if @path.size > 1
|
82
|
+
end
|
83
|
+
protected :up
|
84
|
+
|
85
|
+
def close
|
86
|
+
super
|
87
|
+
notif :new_leaf, [], @buffer
|
88
|
+
@reset_planned = true
|
89
|
+
end
|
90
|
+
protected :close
|
91
|
+
|
92
|
+
def update ( *a, &b )
|
93
|
+
reset if @reset_planned
|
94
|
+
super
|
95
|
+
end
|
96
|
+
|
97
|
+
def empty?
|
98
|
+
@buffer.is_a? Hash and @buffer.empty?
|
99
|
+
end
|
100
|
+
|
101
|
+
module Assertions
|
102
|
+
|
103
|
+
attr_accessor :buffer
|
104
|
+
|
105
|
+
def assert_buffer ( ref )
|
106
|
+
assert_equal(ref, @buffer.buffer)
|
107
|
+
end
|
108
|
+
|
109
|
+
def assert_not_buffer ( ref )
|
110
|
+
assert_not_equal(ref, @buffer.buffer)
|
111
|
+
end
|
112
|
+
|
113
|
+
end # module Assertions
|
114
|
+
|
115
|
+
end # class Buffer
|
116
|
+
|
117
|
+
end # module Filters
|
118
|
+
|
119
|
+
end # Uttk
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/filters/Compact.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Filters
|
10
|
+
|
11
|
+
class Compact < Id
|
12
|
+
include Concrete
|
13
|
+
|
14
|
+
class InternalError < Exception
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize ( *a, &b )
|
18
|
+
super
|
19
|
+
@record = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def new_node ( path, node )
|
24
|
+
if type = node.options[:type]
|
25
|
+
unless type.is_a? Class
|
26
|
+
if type.is_a? String and type =~ /^[A-Z]([a-zA-Z_]|::)*$/
|
27
|
+
type = eval type
|
28
|
+
else
|
29
|
+
raise ArgumentError, "bad type name #{type} : #{type.class}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
# We record the flow if the type is NOT a subclass of Composite nor
|
33
|
+
# a subclass of SubCmd (SubCmd and Composite included)
|
34
|
+
unless type <= Strategies::Composite or type <= Strategies::SubCmd
|
35
|
+
@record[path.to_s] = [Buffer.new, node]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
if node.segment == :attributes
|
39
|
+
@record[path.to_s] = [Buffer.new, node]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
protected :new_node
|
43
|
+
|
44
|
+
|
45
|
+
def up ( path )
|
46
|
+
if buf = @record[path.to_s] # If this path was recorded
|
47
|
+
@record.delete path.to_s
|
48
|
+
path << buf.last
|
49
|
+
# We dump it as leaf
|
50
|
+
leaf = buf.first.buffer.rpath_find(:first, path.to_regex_path_string)
|
51
|
+
raise InternalError, 'in Compact#up the leaf cannot be nil' if leaf.nil?
|
52
|
+
notif :new_leaf, path, leaf
|
53
|
+
end
|
54
|
+
super
|
55
|
+
end
|
56
|
+
protected :up
|
57
|
+
|
58
|
+
|
59
|
+
def new_leaf ( path, leaf )
|
60
|
+
if @record.empty?
|
61
|
+
# We are recording nothing so we transmit the message as is.
|
62
|
+
super
|
63
|
+
else
|
64
|
+
# Each buffer receive the message
|
65
|
+
@record.each do |path_s, buf|
|
66
|
+
buf.first.update(:new_leaf, path, leaf)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end # class Compact
|
72
|
+
|
73
|
+
end # module Filters
|
74
|
+
|
75
|
+
end # module Uttk
|