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,69 @@
|
|
|
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/TextFilter.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
|
5
|
+
|
|
6
|
+
module Uttk
|
|
7
|
+
|
|
8
|
+
module Filters
|
|
9
|
+
|
|
10
|
+
class TextFilter < KeepSkipBased
|
|
11
|
+
include Concrete
|
|
12
|
+
|
|
13
|
+
default_options.merge! :action => nil # No default action
|
|
14
|
+
|
|
15
|
+
# FIXME can be path based
|
|
16
|
+
# This filter use the Text manipulation class of RubyEx.
|
|
17
|
+
# You can apply transformation over leaves content.
|
|
18
|
+
#
|
|
19
|
+
# This filter takes two arguments:
|
|
20
|
+
# - observers: An observer list like any filter
|
|
21
|
+
# - options:
|
|
22
|
+
# keep: A regular expression (all keys which match this regexp are transformed)
|
|
23
|
+
# skip: Antoher regexp that skip keys which match
|
|
24
|
+
# action: What transformation apply (e.g. justify), see the _Text_ class for
|
|
25
|
+
# more informations
|
|
26
|
+
# width: Maximal width of a line
|
|
27
|
+
#
|
|
28
|
+
# Examples:
|
|
29
|
+
# Yaml syntax: 'TextFilter: [!keep "^(in|out)put$", !action justify, Yaml]'
|
|
30
|
+
#
|
|
31
|
+
def initialize ( observers, options, &b )
|
|
32
|
+
super
|
|
33
|
+
@text_factory = MetaFactory.new(Text, @options)
|
|
34
|
+
@filter_next_leaf = false
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def new_node ( path, node )
|
|
39
|
+
@filter_next_leaf = keep? node.segment
|
|
40
|
+
super
|
|
41
|
+
end
|
|
42
|
+
protected :new_node
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def new_leaf ( path, node )
|
|
46
|
+
super(path, (@filter_next_leaf)? node_filter(node) : node)
|
|
47
|
+
end
|
|
48
|
+
protected :new_leaf
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def up ( path )
|
|
52
|
+
@filter_next_leaf = false
|
|
53
|
+
super
|
|
54
|
+
end
|
|
55
|
+
protected :up
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def node_filter ( anObject )
|
|
59
|
+
return anObject unless anObject.is_a? String
|
|
60
|
+
o = @text_factory.create([anObject])
|
|
61
|
+
eval("o.#@action").text
|
|
62
|
+
end
|
|
63
|
+
protected :node_filter
|
|
64
|
+
|
|
65
|
+
end # class TextFilter
|
|
66
|
+
|
|
67
|
+
end # module Filters
|
|
68
|
+
|
|
69
|
+
end # module Uttk
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/dumper_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::DumperGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::Dumpers::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/dumpers
|
|
16
|
+
m.directory root/test/unit/dumpers
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template 'dumper.rb', root/lib/uttk/dumpers/"#{class_name}.rb"
|
|
20
|
+
m.template 'unit_test.rb', root/test/unit/dumpers/"#{file_name}_test.rb"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:Dumpers
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::DumperGenerator
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/filter_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::FilterGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::Filters::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/filters
|
|
16
|
+
m.directory root/test/unit/filters
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template 'filter.rb', root/lib/uttk/filters/"#{class_name}.rb"
|
|
20
|
+
m.template 'unit_test.rb', root/test/unit/filters/"#{file_name}_test.rb"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:Filters
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::FilterGenerator
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
module Uttk
|
|
7
|
+
|
|
8
|
+
# = How to use these generators
|
|
9
|
+
#
|
|
10
|
+
# == Requirements:
|
|
11
|
+
#
|
|
12
|
+
# - Ruby on rails
|
|
13
|
+
#
|
|
14
|
+
# - Environment:
|
|
15
|
+
#
|
|
16
|
+
# Check that you have exported these variables:
|
|
17
|
+
#
|
|
18
|
+
# - EMAIL: e.g. ertai@lrde.epita.fr
|
|
19
|
+
# - FULLNAME: e.g. Nicolas Pouillard
|
|
20
|
+
#
|
|
21
|
+
# - Example, create a new startegy:
|
|
22
|
+
# ruby script/generate strategy MyBrandNewStartegy
|
|
23
|
+
module Generators
|
|
24
|
+
|
|
25
|
+
class Generator < Rails::Generator::NamedBase
|
|
26
|
+
|
|
27
|
+
def initialize ( runtime_args, runtime_options={} )
|
|
28
|
+
@fullname = ENV['FULLNAME'] || raise('The FULLNAME environement variable is not set')
|
|
29
|
+
@email = ENV['EMAIL'] || raise('The EMAIL environement variable is not set')
|
|
30
|
+
@root = __FILE__.to_path.dirname.parent.parent.parent.expand_path.cleanpath
|
|
31
|
+
@year = Time.now.year
|
|
32
|
+
super(runtime_args,
|
|
33
|
+
{ :destination => @root.to_s }.merge!(runtime_options))
|
|
34
|
+
@root = '.'.to_path
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
%w[ lib uttk test unit functional
|
|
38
|
+
strategies loaders filters dumpers generators ].each do |name|
|
|
39
|
+
define_method(name) { name }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
attr_reader :root, :fullname, :email, :year
|
|
43
|
+
|
|
44
|
+
def dir_name
|
|
45
|
+
module_name.to_s.underscore
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class DirSource < Rails::Generator::Source
|
|
49
|
+
|
|
50
|
+
def initialize ( label, *dirs )
|
|
51
|
+
super label
|
|
52
|
+
@specs = []
|
|
53
|
+
dirs.flatten.each do |dir|
|
|
54
|
+
PathList[dir/'(*)_generator.rb'].each do |file, name|
|
|
55
|
+
@specs << Rails::Generator::Spec.new(name, file.dirname, label)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The each method must be implemented in subclasses.
|
|
61
|
+
# The base implementation raises an error.
|
|
62
|
+
def each ( &block )
|
|
63
|
+
@specs.each(&block)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end # class DirSource
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class Rails::Generator::Manifest
|
|
70
|
+
alias_method :method_missing_without_stringify, :method_missing
|
|
71
|
+
def method_missing ( action, *args, &block )
|
|
72
|
+
method_missing_without_stringify(action, *args.map {|x|x.to_s}, &block)
|
|
73
|
+
end
|
|
74
|
+
end # class Rails::Generator::Manifest
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Rails::Generator::Base.class_eval do
|
|
78
|
+
reset_sources
|
|
79
|
+
prepend_sources DirSource.new(:uttk, __FILE__.to_path.dirname)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end # class Generator
|
|
83
|
+
|
|
84
|
+
end # module Generators
|
|
85
|
+
|
|
86
|
+
end # module Uttk
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/generator_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::GeneratorGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name,
|
|
13
|
+
"Uttk::Generators::#{class_name}Generator"
|
|
14
|
+
|
|
15
|
+
m.directory root/lib/uttk/generators
|
|
16
|
+
|
|
17
|
+
m.template 'generator.rb',
|
|
18
|
+
root/lib/uttk/generators/"#{file_name}_generator.rb"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def module_name
|
|
23
|
+
class_name.pluralize
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end # class Uttk::Generators::GeneratorGenerator
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/loader_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::LoaderGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::Loaders::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/loaders
|
|
16
|
+
m.directory root/test/unit/loaders
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template 'loader.rb', root/lib/uttk/loaders/"#{class_name}.rb"
|
|
20
|
+
m.template 'unit_test.rb', root/test/unit/loaders/"#{file_name}_test.rb"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:Loaders
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::LoaderGenerator
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/path_filter_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::PathFilterGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::PathFilters::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/path_filters
|
|
16
|
+
m.directory root/test/runit/path_filters
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template 'path_filter.rb', root/lib/uttk/path_filters/"#{class_name}.rb"
|
|
20
|
+
m.template 'unit_test.rb', root/test/runit/path_filters/"#{file_name}_test.rb"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:PathFilters
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::PathFilterGenerator
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/strategy_generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::StrategyGenerator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::Strategies::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/strategies
|
|
16
|
+
m.directory root/test/unit/strategies
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template 'strategy.rb', root/lib/uttk/strategies/"#{class_name}.rb"
|
|
20
|
+
m.template 'strategy.yml', root/test/functional/"#{file_name}.yml"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:Strategies
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::StrategyGenerator
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/templates/dumper.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
|
5
|
+
|
|
6
|
+
module Uttk
|
|
7
|
+
|
|
8
|
+
module Dumpers
|
|
9
|
+
|
|
10
|
+
class <%= class_name %> < Dumper
|
|
11
|
+
include Concrete
|
|
12
|
+
|
|
13
|
+
def initialize ( *a, &b )
|
|
14
|
+
super
|
|
15
|
+
# ...
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def new_node ( path, node )
|
|
20
|
+
super
|
|
21
|
+
# ...
|
|
22
|
+
end
|
|
23
|
+
protected :new_node
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def new_leaf ( path, leaf )
|
|
27
|
+
super
|
|
28
|
+
# ...
|
|
29
|
+
end
|
|
30
|
+
protected :new_leaf
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def up ( path )
|
|
34
|
+
super
|
|
35
|
+
# ...
|
|
36
|
+
end
|
|
37
|
+
protected :up
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def close
|
|
41
|
+
# ...
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
protected :close
|
|
45
|
+
|
|
46
|
+
end # class <%= class_name %>
|
|
47
|
+
|
|
48
|
+
end # module Dumpers
|
|
49
|
+
|
|
50
|
+
end # module Uttk
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/templates/filter.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
|
5
|
+
|
|
6
|
+
module Uttk
|
|
7
|
+
|
|
8
|
+
module Filters
|
|
9
|
+
|
|
10
|
+
class <%= class_name %> < Filter
|
|
11
|
+
include Concrete
|
|
12
|
+
|
|
13
|
+
def initialize ( *a, &b )
|
|
14
|
+
super
|
|
15
|
+
# ...
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def new_node ( path, node )
|
|
20
|
+
super
|
|
21
|
+
# ...
|
|
22
|
+
end
|
|
23
|
+
protected :new_node
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def new_leaf ( path, leaf )
|
|
27
|
+
super
|
|
28
|
+
# ...
|
|
29
|
+
end
|
|
30
|
+
protected :new_leaf
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def up ( path )
|
|
34
|
+
super
|
|
35
|
+
# ...
|
|
36
|
+
end
|
|
37
|
+
protected :up
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def close
|
|
41
|
+
# ...
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
protected :close
|
|
45
|
+
|
|
46
|
+
end # class <%= class_name %>
|
|
47
|
+
|
|
48
|
+
end # module Filters
|
|
49
|
+
|
|
50
|
+
end # module Uttk
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/templates/generator.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
|
5
|
+
|
|
6
|
+
class Uttk::Generators::<%= class_name %>Generator < Uttk::Generators::Generator
|
|
7
|
+
|
|
8
|
+
def manifest
|
|
9
|
+
# FIXME do not ignore class_path
|
|
10
|
+
record do |m|
|
|
11
|
+
# Check for class naming collisions.
|
|
12
|
+
m.class_collisions class_path, class_name, "Uttk::<%= module_name %>::#{class_name}"
|
|
13
|
+
|
|
14
|
+
# Source and test directories.
|
|
15
|
+
m.directory root/lib/uttk/<%= dir_name %>
|
|
16
|
+
m.directory root/test/unit/<%= dir_name %>
|
|
17
|
+
|
|
18
|
+
# Source and test templates.
|
|
19
|
+
m.template '<%= file_name %>.rb', root/lib/uttk/<%= dir_name %>/"#{class_name}.rb"
|
|
20
|
+
m.template 'unit_test.rb', root/test/unit/<%= dir_name %>/"#{file_name}_test.rb"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def module_name
|
|
25
|
+
:<%= module_name %>
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # class Uttk::Generators::<%= class_name %>Generator
|