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,23 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id$
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Dumpers
|
10
|
+
|
11
|
+
class Basic < Dumper
|
12
|
+
include Concrete
|
13
|
+
|
14
|
+
def update ( *a, &b )
|
15
|
+
super
|
16
|
+
puts "NOTIFICATION: #{a.inspect} block_given: #{not b.nil?}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end # class Basic
|
20
|
+
|
21
|
+
end # module Dumpers
|
22
|
+
|
23
|
+
end # module Uttk
|
@@ -0,0 +1,35 @@
|
|
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/dumpers/BasicColor.rb 21970 2006-02-19T22:15:36.271512Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Dumpers
|
10
|
+
|
11
|
+
class BasicColor < Dumper
|
12
|
+
include Concrete
|
13
|
+
|
14
|
+
def initialize ( *a, &b )
|
15
|
+
super
|
16
|
+
raise "HighLine not available" unless defined? HighLine
|
17
|
+
@h = HighLine.new(nil, self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update ( *a, &b )
|
21
|
+
super
|
22
|
+
msg, path, node, options = a
|
23
|
+
path = Logger::Path.new(path) unless path.nil?
|
24
|
+
@h.say "#{@h.color msg.inspect.ljust(10), :red} " +
|
25
|
+
"#{@h.color path.inspect, :green} " +
|
26
|
+
"#{@h.color node.inspect, :magenta} " +
|
27
|
+
"#{@h.color options.inspect, :yellow} " +
|
28
|
+
"<%=color 'block_given: #{not b.nil?}', :cyan %>"
|
29
|
+
end
|
30
|
+
|
31
|
+
end # class BasicColor
|
32
|
+
|
33
|
+
end # module Dumpers
|
34
|
+
|
35
|
+
end # module Uttk
|
@@ -0,0 +1,77 @@
|
|
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/Dumper.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
# Dumpers are backends of Uttk.
|
10
|
+
# You can easily write your own dumper. See Uttk::Dumpers::Dumper
|
11
|
+
module Dumpers
|
12
|
+
|
13
|
+
# The dumper is a specific Logger::Backend.
|
14
|
+
#
|
15
|
+
# It react to method calls by writting in the output.
|
16
|
+
# The output must be acceded like that:
|
17
|
+
#
|
18
|
+
# * Using the print method
|
19
|
+
# * Using the puts method
|
20
|
+
# * Using the << method
|
21
|
+
#
|
22
|
+
# If you really need to access to the real outputs use each_output.
|
23
|
+
#
|
24
|
+
# You can safely call flush in your methods because this method take care
|
25
|
+
# of closed and unflushable outputs.
|
26
|
+
class Dumper < Logger::Backend
|
27
|
+
include Abstract
|
28
|
+
attr_accessor :options
|
29
|
+
|
30
|
+
def initialize ( output=STDOUT, *args )
|
31
|
+
@outputs = [output]
|
32
|
+
while args.first.is_a? IO do
|
33
|
+
@outputs << args.shift
|
34
|
+
end
|
35
|
+
@options = args
|
36
|
+
super()
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def flush
|
41
|
+
each_output do |o|
|
42
|
+
o.flush if o.respond_to? :flush and (not o.closed?)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def each_output ( &block )
|
48
|
+
@outputs.each(&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def puts ( *args )
|
53
|
+
each_output do |o|
|
54
|
+
o.puts(*args)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def print ( *args )
|
60
|
+
each_output do |o|
|
61
|
+
o.print(*args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def << ( arg )
|
67
|
+
each_output do |o|
|
68
|
+
o << arg
|
69
|
+
end
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
end # class Dumper
|
74
|
+
|
75
|
+
end # module Dumpers
|
76
|
+
|
77
|
+
end # module Uttk
|
@@ -0,0 +1,271 @@
|
|
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/dumpers/Html.rb 21970 2006-02-19T22:15:36.271512Z pouillar $
|
5
|
+
|
6
|
+
require 'stringio'
|
7
|
+
HtmlEncode.import!
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
module Dumpers
|
12
|
+
|
13
|
+
#
|
14
|
+
# Use me at least with the Compact filter:
|
15
|
+
# Compact: [NodeCut: [!skip ^contents$, [Html: [log.html]]]]
|
16
|
+
#
|
17
|
+
class Html < Dumper
|
18
|
+
include Concrete
|
19
|
+
cattr_reader :base_url
|
20
|
+
@@base_url = 'http://api.uttk.org/'
|
21
|
+
|
22
|
+
# Use this one when you have made changes in lib/www
|
23
|
+
# @@base_url = "file://#{Uttk.dir.parent.expand_path}/www/"
|
24
|
+
|
25
|
+
class XmlMarkup < Builder::XmlMarkup #:nodoc:
|
26
|
+
def initialize ( *a, &b )
|
27
|
+
@self = nil
|
28
|
+
super
|
29
|
+
end
|
30
|
+
def itext! ( str )
|
31
|
+
_indent
|
32
|
+
text! str.to_s.chomp
|
33
|
+
_newline
|
34
|
+
end
|
35
|
+
alias_method :html!, :<<
|
36
|
+
def ihtml! ( str )
|
37
|
+
_indent
|
38
|
+
self << str.to_s.chomp
|
39
|
+
_newline
|
40
|
+
end
|
41
|
+
def expand_and_collapse ( type, name )
|
42
|
+
td do
|
43
|
+
a :onClick => "uttk_expand_all(#{type});" do
|
44
|
+
itext! "Expand all #{name}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
td do
|
48
|
+
a :onClick => "uttk_collapse_all(#{type});" do
|
49
|
+
itext! "Collapse all #{name}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class BaseNode # :nodoc:
|
56
|
+
attr_reader :father, :name, :status, :id, :contents, :state
|
57
|
+
|
58
|
+
@@template_images = Html.base_url + 'images/%%%IMAGE_SPLIT%%%triangle.gif'
|
59
|
+
|
60
|
+
def initialize ( h )
|
61
|
+
@father, @status, @id = h[:father], h[:status], h[:id]
|
62
|
+
@name, @contents, @state = h[:name], h[:contents], h[:state]
|
63
|
+
end
|
64
|
+
|
65
|
+
def unquote ( s )
|
66
|
+
s.gsub('"', '')
|
67
|
+
end
|
68
|
+
|
69
|
+
def html
|
70
|
+
@status ||= ''
|
71
|
+
x = XmlMarkup.new
|
72
|
+
x.div :class => self.class.name.demodulize.underscore do
|
73
|
+
x.table :class => 'title', :id => unquote(status).sub(/\(.+\)/, '') do
|
74
|
+
x.tr do
|
75
|
+
if state == 2
|
76
|
+
x.td { x.text!(name.to_s + ': ') }
|
77
|
+
x.td { x.pre clean_yaml_str(contents),
|
78
|
+
:class => 'attribute_alone' }
|
79
|
+
else
|
80
|
+
x.td :width => '11px',
|
81
|
+
:onClick => "uttk_toggle_state(#{id.gsub('"', "'")})" do
|
82
|
+
x.img :src => @@template_images
|
83
|
+
end
|
84
|
+
x.td { x.text!(name.to_s) }
|
85
|
+
x.td(:width => '20px') { x.text!(unquote(status).gsub('NONE', '')) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
result = x.target!
|
91
|
+
raise unless result =~ /<\/div>\Z/
|
92
|
+
result.sub!(/<\/div>\Z/, '')
|
93
|
+
result.split('%%%IMAGE_SPLIT%%%').map do |x|
|
94
|
+
x.dump
|
95
|
+
end.join(', ')
|
96
|
+
end
|
97
|
+
|
98
|
+
def clean_yaml_str ( anObject )
|
99
|
+
str = ''
|
100
|
+
io = StringIO.new str
|
101
|
+
log = Logger.new(Dumpers::Yaml.new(io))
|
102
|
+
log << anObject
|
103
|
+
log.close
|
104
|
+
io.close
|
105
|
+
str.sub!(/^---\s*/, '')
|
106
|
+
str.chomp!
|
107
|
+
str
|
108
|
+
end
|
109
|
+
private :clean_yaml_str
|
110
|
+
end
|
111
|
+
|
112
|
+
class Node < BaseNode # :nodoc:
|
113
|
+
def to_html_uttk_js ( status_h )
|
114
|
+
@status = status_h[@status]
|
115
|
+
"uttk_add_node(#@id, #@father, #@state, #{html});"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class Leaf < BaseNode # :nodoc:
|
120
|
+
def to_html_uttk_js ( status_h )
|
121
|
+
"uttk_add_leaf(#@id, #@father, #@state, #{html}, #{html_contents});"
|
122
|
+
end
|
123
|
+
def html_contents
|
124
|
+
return '""' if state == 2
|
125
|
+
x = XmlMarkup.new
|
126
|
+
x.table :class => 'attribute' do
|
127
|
+
contents.each do |k, v|
|
128
|
+
x.tr do
|
129
|
+
x.td "#{k}:", :class => 'key'
|
130
|
+
x.td :class => 'value' do
|
131
|
+
x.pre clean_yaml_str(v), :class => 'attribute'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
x.target!.dump
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
def initialize ( *a, &b )
|
143
|
+
@uttk_js = base_url + 'javascripts/uttk.js'
|
144
|
+
@uttk_css = base_url + 'stylesheets/uttk.css'
|
145
|
+
super
|
146
|
+
reset
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def reset
|
151
|
+
@current_ids = Hash.new(0)
|
152
|
+
@ids = {}
|
153
|
+
@ids[:node] = { '/' => 'null' }
|
154
|
+
@elts = []
|
155
|
+
@status = Hash.new('"NONE"')
|
156
|
+
@x = Builder::XmlMarkup.new(:target => self, :indent => 2)
|
157
|
+
end
|
158
|
+
protected :reset
|
159
|
+
|
160
|
+
|
161
|
+
def new_node ( path, node )
|
162
|
+
super
|
163
|
+
father = id_of :node, path
|
164
|
+
path << node
|
165
|
+
id = id_of :node, path
|
166
|
+
path << :status
|
167
|
+
status = id_of :status, path
|
168
|
+
@elts << Node.new(:father => father,
|
169
|
+
:name => node.segment,
|
170
|
+
:id => id,
|
171
|
+
:status => status,
|
172
|
+
:state => 1)
|
173
|
+
end
|
174
|
+
protected :new_node
|
175
|
+
|
176
|
+
|
177
|
+
def new_leaf ( path, leaf )
|
178
|
+
super
|
179
|
+
if path.last.segment == :status
|
180
|
+
@status[id_of(:status, path)] = leaf
|
181
|
+
@elts.pop
|
182
|
+
else
|
183
|
+
father = id_of :node, path
|
184
|
+
path << leaf
|
185
|
+
id = id_of :leaf, path
|
186
|
+
contents = leaf
|
187
|
+
n = @elts.pop
|
188
|
+
father, leaf, id, status = n.father, n.name, n.id, n.status
|
189
|
+
state, status = 0, ''
|
190
|
+
if contents.is_a? Hash
|
191
|
+
status = contents[:status]
|
192
|
+
[:status].each do |k|
|
193
|
+
contents.delete k if contents.has_key? k
|
194
|
+
end
|
195
|
+
else
|
196
|
+
state = 2
|
197
|
+
end
|
198
|
+
@elts << Leaf.new(:father => father,
|
199
|
+
:id => id,
|
200
|
+
:name => leaf,
|
201
|
+
:status => status,
|
202
|
+
:state => state,
|
203
|
+
:contents => contents)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
protected :new_leaf
|
207
|
+
|
208
|
+
|
209
|
+
def close
|
210
|
+
super
|
211
|
+
x = XmlMarkup.new(:indent => 2, :target => self)
|
212
|
+
x.html do
|
213
|
+
x.head do
|
214
|
+
x.script '', :language => 'javascript', :src => @uttk_js
|
215
|
+
x.style :type => 'text/css' do
|
216
|
+
x.itext! "@import url('#@uttk_css');"
|
217
|
+
end
|
218
|
+
x.script :language => 'javascript' do
|
219
|
+
@elts.each do |elt|
|
220
|
+
x << elt.to_html_uttk_js(@status) << "\n"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
x.body :onLoad => 'uttk_main()' do
|
225
|
+
x.table :class => 'uttk_infos' do
|
226
|
+
x.tr :class => 'uttk_infos_box' do
|
227
|
+
x.expand_and_collapse 'null', ''
|
228
|
+
x.expand_and_collapse "'node'", 'nodes'
|
229
|
+
x.expand_and_collapse "'leaf'", 'leaves'
|
230
|
+
end
|
231
|
+
end
|
232
|
+
x.div '', :id => 'uttk_contents'
|
233
|
+
end
|
234
|
+
end
|
235
|
+
reset
|
236
|
+
end
|
237
|
+
protected :close
|
238
|
+
|
239
|
+
|
240
|
+
def id_of ( prefix, path )
|
241
|
+
path = path.inspect
|
242
|
+
@ids[prefix] ||= {}
|
243
|
+
result = @ids[prefix][path]
|
244
|
+
if result.nil?
|
245
|
+
result = @ids[prefix][path] = new_id(prefix)
|
246
|
+
end
|
247
|
+
result
|
248
|
+
end
|
249
|
+
protected :id_of
|
250
|
+
|
251
|
+
|
252
|
+
def new_id ( prefix )
|
253
|
+
id = "#{prefix}#{@current_ids[prefix]}"
|
254
|
+
@current_ids[prefix] += 1
|
255
|
+
id.dump
|
256
|
+
end
|
257
|
+
protected :new_id
|
258
|
+
|
259
|
+
|
260
|
+
def self.clean_js_str ( str )
|
261
|
+
res = str.to_s.html_encode.dump
|
262
|
+
res.gsub!(/([^\\])\\n/, '\1<BR>\n')
|
263
|
+
res
|
264
|
+
end
|
265
|
+
|
266
|
+
end # class Html
|
267
|
+
|
268
|
+
end # module Dumpers
|
269
|
+
|
270
|
+
end # module Uttk
|
271
|
+
|
@@ -0,0 +1,24 @@
|
|
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/dumpers/Path.rb 21970 2006-02-19T22:15:36.271512Z pouillar $
|
5
|
+
|
6
|
+
module Uttk
|
7
|
+
|
8
|
+
module Dumpers
|
9
|
+
|
10
|
+
class Path < Dumper
|
11
|
+
include Concrete
|
12
|
+
|
13
|
+
def new_leaf ( *args )
|
14
|
+
super
|
15
|
+
puts args.to_yaml
|
16
|
+
flush
|
17
|
+
end
|
18
|
+
protected :new_leaf
|
19
|
+
|
20
|
+
end # class Path
|
21
|
+
|
22
|
+
end # module Dumpers
|
23
|
+
|
24
|
+
end # module Uttk
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Author:: Jerome Pouiller <pouill_j@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/Xml.rb 21970 2006-02-19T22:15:36.271512Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
module Dumpers
|
12
|
+
|
13
|
+
class Xml < Dumper
|
14
|
+
include Concrete
|
15
|
+
|
16
|
+
|
17
|
+
def initialize ( *a, &b )
|
18
|
+
super
|
19
|
+
puts '<?xml version="1.0" encoding="iso-8859-1"?>'
|
20
|
+
reset
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def reset
|
25
|
+
@doc = @root = REXML::Document.new
|
26
|
+
@doc_stack = []
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def add_elt ( elt, hsh={} )
|
31
|
+
return @doc if @doc.eql? @root and @root.has_elements?
|
32
|
+
@doc = @doc.add_element(REXML::Element.new(clean_for_xml(elt)))
|
33
|
+
hsh.each do |k, v|
|
34
|
+
@doc.add_attribute(clean_for_xml(k), v)
|
35
|
+
end
|
36
|
+
@doc
|
37
|
+
end
|
38
|
+
private :add_elt
|
39
|
+
|
40
|
+
|
41
|
+
def new_node ( path, node )
|
42
|
+
super
|
43
|
+
doc_ = @doc
|
44
|
+
opts = { :name => node.segment }
|
45
|
+
if type = node.options[:type]
|
46
|
+
opts[:type] = type
|
47
|
+
end
|
48
|
+
add_elt(:node, opts)
|
49
|
+
@doc_stack << doc_
|
50
|
+
end
|
51
|
+
protected :new_node
|
52
|
+
|
53
|
+
|
54
|
+
def new_leaf ( path, leaf )
|
55
|
+
super
|
56
|
+
@doc.add_text(leaf.to_s)
|
57
|
+
end
|
58
|
+
protected :new_leaf
|
59
|
+
|
60
|
+
|
61
|
+
def up ( path )
|
62
|
+
super
|
63
|
+
@doc = @doc_stack.pop unless @doc_stack.empty?
|
64
|
+
end
|
65
|
+
protected :up
|
66
|
+
|
67
|
+
|
68
|
+
def close
|
69
|
+
@root.write(self, 0, false)
|
70
|
+
puts
|
71
|
+
reset
|
72
|
+
super
|
73
|
+
end
|
74
|
+
protected :close
|
75
|
+
|
76
|
+
|
77
|
+
def clean_for_xml ( anObject )
|
78
|
+
str = anObject.to_s
|
79
|
+
str.gsub!(/[^a-zA-Z:-_]/, '_')
|
80
|
+
str
|
81
|
+
end
|
82
|
+
protected :clean_for_xml
|
83
|
+
|
84
|
+
end # class Xml
|
85
|
+
|
86
|
+
end # module Dumpers
|
87
|
+
|
88
|
+
end # module Uttk
|