bauxite 0.6.18 → 0.6.19
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.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +293 -293
- data/Rakefile +128 -128
- data/bin/bauxite +27 -27
- data/doc/Bauxite.html +6 -9
- data/doc/Bauxite/Action.html +298 -315
- data/doc/Bauxite/ActionModule.html +23 -26
- data/doc/Bauxite/Application.html +36 -38
- data/doc/Bauxite/Context.html +303 -303
- data/doc/Bauxite/Errors.html +6 -9
- data/doc/Bauxite/Errors/AssertionError.html +6 -9
- data/doc/Bauxite/Errors/FileNotFoundError.html +6 -9
- data/doc/Bauxite/Errors/FormatError.html +6 -9
- data/doc/Bauxite/Loggers.html +6 -9
- data/doc/Bauxite/Loggers/CompositeLogger.html +29 -32
- data/doc/Bauxite/Loggers/EchoLogger.html +10 -13
- data/doc/Bauxite/Loggers/FileLogger.html +25 -28
- data/doc/Bauxite/Loggers/HtmlLogger.html +99 -102
- data/doc/Bauxite/Loggers/NullLogger.html +16 -19
- data/doc/Bauxite/Loggers/ReportLogger.html +43 -46
- data/doc/Bauxite/Loggers/TerminalLogger.html +76 -79
- data/doc/Bauxite/Loggers/XtermLogger.html +28 -31
- data/doc/Bauxite/Parser.html +87 -89
- data/doc/Bauxite/ParserModule.html +19 -22
- data/doc/Bauxite/Selector.html +99 -105
- data/doc/Bauxite/SelectorModule.html +27 -30
- data/doc/README_md.html +117 -103
- data/doc/created.rid +58 -58
- data/doc/fonts.css +167 -167
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +117 -103
- data/doc/js/darkfish.js +32 -11
- data/doc/js/jquery.js +0 -0
- data/doc/js/navigation.js +0 -0
- data/doc/js/search.js +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/searcher.js +0 -0
- data/doc/rdoc.css +580 -580
- data/doc/table_of_contents.html +69 -72
- data/lib/bauxite.rb +28 -28
- data/lib/bauxite/actions/alias.rb +51 -51
- data/lib/bauxite/actions/assert.rb +49 -49
- data/lib/bauxite/actions/asserth.rb +60 -60
- data/lib/bauxite/actions/assertm.rb +49 -49
- data/lib/bauxite/actions/assertv.rb +40 -40
- data/lib/bauxite/actions/assertw.rb +47 -47
- data/lib/bauxite/actions/break.rb +39 -39
- data/lib/bauxite/actions/capture.rb +61 -61
- data/lib/bauxite/actions/click.rb +36 -36
- data/lib/bauxite/actions/debug.rb +103 -103
- data/lib/bauxite/actions/doif.rb +43 -43
- data/lib/bauxite/actions/dounless.rb +43 -43
- data/lib/bauxite/actions/echo.rb +36 -36
- data/lib/bauxite/actions/exec.rb +46 -46
- data/lib/bauxite/actions/exit.rb +35 -35
- data/lib/bauxite/actions/failif.rb +52 -52
- data/lib/bauxite/actions/js.rb +41 -41
- data/lib/bauxite/actions/load.rb +49 -49
- data/lib/bauxite/actions/open.rb +35 -35
- data/lib/bauxite/actions/params.rb +40 -40
- data/lib/bauxite/actions/replace.rb +37 -37
- data/lib/bauxite/actions/reset.rb +38 -38
- data/lib/bauxite/actions/return.rb +68 -68
- data/lib/bauxite/actions/ruby.rb +58 -58
- data/lib/bauxite/actions/select.rb +48 -48
- data/lib/bauxite/actions/set.rb +39 -39
- data/lib/bauxite/actions/setif.rb +44 -44
- data/lib/bauxite/actions/source.rb +44 -44
- data/lib/bauxite/actions/store.rb +38 -38
- data/lib/bauxite/actions/submit.rb +37 -37
- data/lib/bauxite/actions/test.rb +67 -67
- data/lib/bauxite/actions/tryload.rb +71 -71
- data/lib/bauxite/actions/wait.rb +38 -38
- data/lib/bauxite/actions/write.rb +44 -44
- data/lib/bauxite/application.rb +349 -349
- data/lib/bauxite/core/action.rb +199 -199
- data/lib/bauxite/core/context.rb +791 -791
- data/lib/bauxite/core/errors.rb +41 -41
- data/lib/bauxite/core/logger.rb +169 -169
- data/lib/bauxite/core/parser.rb +85 -85
- data/lib/bauxite/core/selector.rb +152 -152
- data/lib/bauxite/loggers/composite.rb +91 -91
- data/lib/bauxite/loggers/echo.rb +36 -36
- data/lib/bauxite/loggers/file.rb +68 -68
- data/lib/bauxite/loggers/html.rb +154 -154
- data/lib/bauxite/loggers/terminal.rb +134 -134
- data/lib/bauxite/loggers/xterm.rb +101 -101
- data/lib/bauxite/parsers/csv.rb +43 -43
- data/lib/bauxite/parsers/default.rb +42 -42
- data/lib/bauxite/parsers/html.rb +79 -79
- data/lib/bauxite/selectors/attr.rb +39 -39
- data/lib/bauxite/selectors/frame.rb +60 -60
- data/lib/bauxite/selectors/json.rb +88 -88
- data/lib/bauxite/selectors/sid.rb +38 -38
- data/lib/bauxite/selectors/smart.rb +80 -80
- data/lib/bauxite/selectors/window.rb +77 -77
- data/test/alert.bxt +3 -3
- data/test/alert/page.html +4 -4
- data/test/alias.bxt +9 -9
- data/test/asserth.bxt +2 -2
- data/test/assertv.bxt +1 -1
- data/test/assertw.bxt +7 -7
- data/test/broken.bxt.manual +0 -0
- data/test/bug_load_path.bxt.manual +0 -0
- data/test/bug_load_path/broken.bxt.manual +0 -0
- data/test/bug_load_path/test.bxt +0 -0
- data/test/capture.bxt.manual +20 -20
- data/test/capture/my_test.bxt +1 -1
- data/test/capture/page.html +6 -6
- data/test/capture_on_error.bxt.manual +3 -3
- data/test/capture_on_error/my_test.bxt +1 -1
- data/test/capture_on_error/page.html +2 -2
- data/test/debug.bxt.manual +0 -0
- data/test/default_selector.bxt.manual +7 -7
- data/test/default_selector/page.html +10 -10
- data/test/default_selector_var.bxt +1 -1
- data/test/delay.bxt +2 -2
- data/test/delay/page.html +4 -4
- data/test/doif.bxt +6 -6
- data/test/dounless.bxt +6 -6
- data/test/exec.bxt +6 -6
- data/test/exit.bxt +3 -3
- data/test/exit/test.bxt +3 -3
- data/test/extension.bxt.manual +4 -4
- data/test/extension/custom.rb +12 -12
- data/test/extension/page.html +4 -4
- data/test/failif.bxt +7 -7
- data/test/failif/page.html +5 -5
- data/test/format.bxt +17 -17
- data/test/format/page.html +6 -6
- data/test/frame.bxt +6 -6
- data/test/frame/child_frame.html +6 -6
- data/test/frame/grandchild_frame.html +4 -4
- data/test/frame/page.html +4 -4
- data/test/js.bxt +4 -4
- data/test/json.bxt +19 -19
- data/test/json/array.json +3 -3
- data/test/json/object.json +13 -13
- data/test/load.bxt +18 -18
- data/test/load/child.bxt +12 -12
- data/test/parsers.bxt +1 -1
- data/test/parsers.csv +7 -7
- data/test/parsers.html +32 -32
- data/test/parsers/page.html +6 -6
- data/test/return.bxt +1 -1
- data/test/return/f1.bxt +1 -1
- data/test/return/f2.bxt +1 -1
- data/test/return/f3.bxt +1 -1
- data/test/return/f4.bxt +2 -2
- data/test/ruby.bxt +1 -1
- data/test/ruby/custom.rb +5 -5
- data/test/select.bxt +9 -9
- data/test/select/page.html +8 -8
- data/test/selectors.bxt +7 -7
- data/test/selectors/page.html +6 -6
- data/test/set_builtin.bxt +5 -0
- data/test/set_builtin/page.html +5 -0
- data/test/setif.bxt +3 -3
- data/test/smart_selector.bxt +17 -17
- data/test/smart_selector/page.html +17 -17
- data/test/stdin.bxt +0 -0
- data/test/submit.bxt +4 -4
- data/test/submit/page.html +6 -6
- data/test/submit/page2.html +4 -4
- data/test/test.bxt.manual +6 -6
- data/test/test/test1.bxt +2 -2
- data/test/test/test2.bxt +3 -3
- data/test/test/test3.bxt +2 -2
- data/test/test/test4.bxt +1 -1
- data/test/test/test5.bxt +1 -1
- data/test/window.bxt +14 -14
- data/test/window/page.html +5 -5
- data/test/window/popup.html +4 -4
- metadata +5 -3
data/lib/bauxite/loggers/echo.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
# Echo logger.
|
24
|
-
#
|
25
|
-
# This logger outputs the raw action text for every action executed.
|
26
|
-
#
|
27
|
-
# Note that this logger does not include execution status information
|
28
|
-
# (i.e. action succeeded, failed or was skipped).
|
29
|
-
#
|
30
|
-
class Bauxite::Loggers::EchoLogger < Bauxite::Loggers::NullLogger
|
31
|
-
# Echoes the raw action text.
|
32
|
-
def log_cmd(action)
|
33
|
-
puts action.text
|
34
|
-
$stdout.flush
|
35
|
-
yield
|
36
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
# Echo logger.
|
24
|
+
#
|
25
|
+
# This logger outputs the raw action text for every action executed.
|
26
|
+
#
|
27
|
+
# Note that this logger does not include execution status information
|
28
|
+
# (i.e. action succeeded, failed or was skipped).
|
29
|
+
#
|
30
|
+
class Bauxite::Loggers::EchoLogger < Bauxite::Loggers::NullLogger
|
31
|
+
# Echoes the raw action text.
|
32
|
+
def log_cmd(action)
|
33
|
+
puts action.text
|
34
|
+
$stdout.flush
|
35
|
+
yield
|
36
|
+
end
|
37
37
|
end
|
data/lib/bauxite/loggers/file.rb
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
# File logger.
|
24
|
-
#
|
25
|
-
# This logger outputs the raw action text for every action executed to
|
26
|
-
# the file specified in the +file+ logger option.
|
27
|
-
#
|
28
|
-
# File logger options include:
|
29
|
-
# [<tt>file</tt>] Output file name.
|
30
|
-
# [<tt>verbose</tt>] Output all log (e.g. errors) to the file.
|
31
|
-
#
|
32
|
-
#
|
33
|
-
class Bauxite::Loggers::FileLogger < Bauxite::Loggers::NullLogger
|
34
|
-
|
35
|
-
# Constructs a new echo logger instance.
|
36
|
-
def initialize(options)
|
37
|
-
super(options)
|
38
|
-
@file = options[:file]
|
39
|
-
unless @file and @file != ''
|
40
|
-
raise ArgumentError, "FileLogger configuration error: Undefined 'file' option."
|
41
|
-
end
|
42
|
-
@verbose = options[:verbose]
|
43
|
-
@lines = []
|
44
|
-
end
|
45
|
-
|
46
|
-
# Completes the log execution.
|
47
|
-
def finalize(ctx)
|
48
|
-
File.open(ctx.output_path(@file), 'w') { |f| f.write(@lines.join("\n")) }
|
49
|
-
end
|
50
|
-
|
51
|
-
# Echoes the raw action text.
|
52
|
-
def log_cmd(action)
|
53
|
-
@lines << action.text
|
54
|
-
yield
|
55
|
-
end
|
56
|
-
|
57
|
-
# Logs the specified string.
|
58
|
-
#
|
59
|
-
# +type+, if specified, should be one of +:error+, +:warning+,
|
60
|
-
# +:info+ (default), +:debug+.
|
61
|
-
#
|
62
|
-
def log(s, type = :info)
|
63
|
-
if @verbose
|
64
|
-
@lines << s
|
65
|
-
else
|
66
|
-
super
|
67
|
-
end
|
68
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
# File logger.
|
24
|
+
#
|
25
|
+
# This logger outputs the raw action text for every action executed to
|
26
|
+
# the file specified in the +file+ logger option.
|
27
|
+
#
|
28
|
+
# File logger options include:
|
29
|
+
# [<tt>file</tt>] Output file name.
|
30
|
+
# [<tt>verbose</tt>] Output all log (e.g. errors) to the file.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
class Bauxite::Loggers::FileLogger < Bauxite::Loggers::NullLogger
|
34
|
+
|
35
|
+
# Constructs a new echo logger instance.
|
36
|
+
def initialize(options)
|
37
|
+
super(options)
|
38
|
+
@file = options[:file]
|
39
|
+
unless @file and @file != ''
|
40
|
+
raise ArgumentError, "FileLogger configuration error: Undefined 'file' option."
|
41
|
+
end
|
42
|
+
@verbose = options[:verbose]
|
43
|
+
@lines = []
|
44
|
+
end
|
45
|
+
|
46
|
+
# Completes the log execution.
|
47
|
+
def finalize(ctx)
|
48
|
+
File.open(ctx.output_path(@file), 'w') { |f| f.write(@lines.join("\n")) }
|
49
|
+
end
|
50
|
+
|
51
|
+
# Echoes the raw action text.
|
52
|
+
def log_cmd(action)
|
53
|
+
@lines << action.text
|
54
|
+
yield
|
55
|
+
end
|
56
|
+
|
57
|
+
# Logs the specified string.
|
58
|
+
#
|
59
|
+
# +type+, if specified, should be one of +:error+, +:warning+,
|
60
|
+
# +:info+ (default), +:debug+.
|
61
|
+
#
|
62
|
+
def log(s, type = :info)
|
63
|
+
if @verbose
|
64
|
+
@lines << s
|
65
|
+
else
|
66
|
+
super
|
67
|
+
end
|
68
|
+
end
|
69
69
|
end
|
data/lib/bauxite/loggers/html.rb
CHANGED
@@ -1,154 +1,154 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
require 'base64'
|
24
|
-
|
25
|
-
# Html logger.
|
26
|
-
#
|
27
|
-
# This logger creates an HTML report of the test execution, linking to the
|
28
|
-
# captures taken, if any.
|
29
|
-
#
|
30
|
-
# Html logger options include:
|
31
|
-
# [<tt>html</tt>] Name of the outpus HTML report file. If not present, defaults
|
32
|
-
# to "test.html".
|
33
|
-
# [<tt>html_package</tt>] If set, embed captures into the HTML report file
|
34
|
-
# using the data URI scheme (base64 encoded). The
|
35
|
-
# captures embedded into the report are deleted from
|
36
|
-
# the filesystem.
|
37
|
-
#
|
38
|
-
class Bauxite::Loggers::HtmlLogger < Bauxite::Loggers::ReportLogger
|
39
|
-
|
40
|
-
# Constructs a new null logger instance.
|
41
|
-
#
|
42
|
-
def initialize(options)
|
43
|
-
super(options)
|
44
|
-
@file = options[:html] || 'test.html'
|
45
|
-
@imgs = []
|
46
|
-
end
|
47
|
-
|
48
|
-
# Completes the log execution.
|
49
|
-
#
|
50
|
-
def finalize(ctx)
|
51
|
-
output = ctx.variables['__OUTPUT__'] || ''
|
52
|
-
|
53
|
-
html = "<!DOCTYPE html>
|
54
|
-
<html>
|
55
|
-
<head>
|
56
|
-
<style type='text/css'>
|
57
|
-
body { font: 10pt sans-serif; }
|
58
|
-
.action div { display: inline-block; }
|
59
|
-
.cmd { width: 100px }
|
60
|
-
.status { float: right; text-align: center; }
|
61
|
-
.status .text { width: 100px; font-weight: bold }
|
62
|
-
.test { background-color: #DFDFFF; margin-top: 20px }
|
63
|
-
.ok .status .text { background-color: #DFFFDF }
|
64
|
-
.error .status .text { background-color: #FFDFDF }
|
65
|
-
.skip .status .text { background-color: #FFDFFF }
|
66
|
-
.capture { border: 1px solid black }
|
67
|
-
.capture img { max-width: 100% }
|
68
|
-
.odd { background-color: #EEEEEE }
|
69
|
-
.summary th { background-color: #DFDFFF; text-align: left }
|
70
|
-
.summary td { cursor: pointer; }
|
71
|
-
.top { position: absolute; top: 0px; right: 0px; background-color: #DFDFFF; padding: 5px; border-radius: 0px 0px 0px 5px; }
|
72
|
-
|
73
|
-
</style>
|
74
|
-
<script type='text/javascript'>
|
75
|
-
function show(target) {
|
76
|
-
var e = document.getElementById(target+'_content');
|
77
|
-
window.location.href = '#'+target;
|
78
|
-
}
|
79
|
-
</script>
|
80
|
-
</head>
|
81
|
-
<body>"
|
82
|
-
html << _d(2, "<div class='top'>Created using <a href='https://github.com/pzavolinsky/bauxite'>bauxite</a> on #{Time.new}</div>")
|
83
|
-
if ctx.tests.any?
|
84
|
-
html << _d(2, "<h1>Test Summary</h1>")
|
85
|
-
html << _d(2, "<table class='summary'>")
|
86
|
-
html << _d(3, "<tr><th>Name</th><th>Time</th><th>Status</th><th>Error</th></tr>")
|
87
|
-
|
88
|
-
ctx.tests.each_with_index do |t,idx|
|
89
|
-
error = t[:error]
|
90
|
-
error = error ? error.message : ''
|
91
|
-
html << _d(3, "<tr class='#{t[:status].downcase} #{(idx % 2) == 1 ? 'odd' : 'even'}' onclick='show(\"#{t[:name]}\")'>")
|
92
|
-
html << _d(4, "<td>#{t[:name]}</td><td>#{t[:time].round(2)}</td><td class='status'>#{t[:status]}</td><td>#{error}</td>")
|
93
|
-
html << _d(3, "</tr>")
|
94
|
-
end
|
95
|
-
|
96
|
-
html << _d(2, "</table>")
|
97
|
-
end
|
98
|
-
|
99
|
-
html << _d(2, "<h1>Test Details</h1>")
|
100
|
-
@data.each do |test|
|
101
|
-
name = test[:name]
|
102
|
-
status = test[:actions].find { |a| a[:status] == :error } ? :error : :ok
|
103
|
-
html << _d(2, "<a name='#{name}'></a>")
|
104
|
-
html << _d(2, "<div class='test #{status}'>#{name}<div class='status'><div class='text'>#{status.upcase}</div></div></div>")
|
105
|
-
html << _d(2, "<div id='#{name}_content' class='test-content'>")
|
106
|
-
|
107
|
-
test[:actions].each_with_index do |action,idx|
|
108
|
-
html << _d(3, "<div class='action #{action[:status]} #{(idx % 2) == 1 ? 'odd' : 'even'}'>")
|
109
|
-
html << _d(4, "<div class='cmd'>#{action[:cmd]}</div>")
|
110
|
-
html << _d(4, "<div class='args'>#{action[:args].join(' ')}</div>")
|
111
|
-
html << _d(4, "<div class='status'>")
|
112
|
-
html << _d(5, "<div class='time'>(#{action[:time].round(2).to_s}s)</div>")
|
113
|
-
html << _d(5, "<div class='text'>#{action[:status].upcase}</div>")
|
114
|
-
html << _d(4, "</div>")
|
115
|
-
html << _d(3, "</div>")
|
116
|
-
capture = action[:capture]
|
117
|
-
if capture
|
118
|
-
html << _d(3, "<div class='capture'>#{_img(output, capture)}</div>")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
item = ctx.tests.find { |t| t[:name] == name }
|
123
|
-
if item and item[:error]
|
124
|
-
capture = item[:error].variables['__CAPTURE__']
|
125
|
-
if capture
|
126
|
-
html << _d(3, "<div class='capture'>#{_img(output, capture)}</div>")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
html << _d(2, "</div>")
|
131
|
-
end
|
132
|
-
html << "
|
133
|
-
</body>
|
134
|
-
</html>"
|
135
|
-
file = ctx.output_path(@file)
|
136
|
-
File.open(file, 'w') { |f| f.write html }
|
137
|
-
File.delete(*@imgs) if @imgs.size > 0
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
def _d(depth, s)
|
142
|
-
"\n"+depth.times.inject('') { |s,i| s + "\t" } + s
|
143
|
-
end
|
144
|
-
def _img(output, path)
|
145
|
-
if @options[:html_package]
|
146
|
-
content = Base64.encode64(File.open(path, '
|
147
|
-
@imgs << path unless @imgs.include? path
|
148
|
-
"<img src='data:image/png;base64,#{content}'/>"
|
149
|
-
else
|
150
|
-
path = path[output.size+1..-1] unless output == ''
|
151
|
-
"<img src='#{path}'/>"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'base64'
|
24
|
+
|
25
|
+
# Html logger.
|
26
|
+
#
|
27
|
+
# This logger creates an HTML report of the test execution, linking to the
|
28
|
+
# captures taken, if any.
|
29
|
+
#
|
30
|
+
# Html logger options include:
|
31
|
+
# [<tt>html</tt>] Name of the outpus HTML report file. If not present, defaults
|
32
|
+
# to "test.html".
|
33
|
+
# [<tt>html_package</tt>] If set, embed captures into the HTML report file
|
34
|
+
# using the data URI scheme (base64 encoded). The
|
35
|
+
# captures embedded into the report are deleted from
|
36
|
+
# the filesystem.
|
37
|
+
#
|
38
|
+
class Bauxite::Loggers::HtmlLogger < Bauxite::Loggers::ReportLogger
|
39
|
+
|
40
|
+
# Constructs a new null logger instance.
|
41
|
+
#
|
42
|
+
def initialize(options)
|
43
|
+
super(options)
|
44
|
+
@file = options[:html] || 'test.html'
|
45
|
+
@imgs = []
|
46
|
+
end
|
47
|
+
|
48
|
+
# Completes the log execution.
|
49
|
+
#
|
50
|
+
def finalize(ctx)
|
51
|
+
output = ctx.variables['__OUTPUT__'] || ''
|
52
|
+
|
53
|
+
html = "<!DOCTYPE html>
|
54
|
+
<html>
|
55
|
+
<head>
|
56
|
+
<style type='text/css'>
|
57
|
+
body { font: 10pt sans-serif; }
|
58
|
+
.action div { display: inline-block; }
|
59
|
+
.cmd { width: 100px }
|
60
|
+
.status { float: right; text-align: center; }
|
61
|
+
.status .text { width: 100px; font-weight: bold }
|
62
|
+
.test { background-color: #DFDFFF; margin-top: 20px }
|
63
|
+
.ok .status .text { background-color: #DFFFDF }
|
64
|
+
.error .status .text { background-color: #FFDFDF }
|
65
|
+
.skip .status .text { background-color: #FFDFFF }
|
66
|
+
.capture { border: 1px solid black }
|
67
|
+
.capture img { max-width: 100% }
|
68
|
+
.odd { background-color: #EEEEEE }
|
69
|
+
.summary th { background-color: #DFDFFF; text-align: left }
|
70
|
+
.summary td { cursor: pointer; }
|
71
|
+
.top { position: absolute; top: 0px; right: 0px; background-color: #DFDFFF; padding: 5px; border-radius: 0px 0px 0px 5px; }
|
72
|
+
|
73
|
+
</style>
|
74
|
+
<script type='text/javascript'>
|
75
|
+
function show(target) {
|
76
|
+
var e = document.getElementById(target+'_content');
|
77
|
+
window.location.href = '#'+target;
|
78
|
+
}
|
79
|
+
</script>
|
80
|
+
</head>
|
81
|
+
<body>"
|
82
|
+
html << _d(2, "<div class='top'>Created using <a href='https://github.com/pzavolinsky/bauxite'>bauxite</a> on #{Time.new}</div>")
|
83
|
+
if ctx.tests.any?
|
84
|
+
html << _d(2, "<h1>Test Summary</h1>")
|
85
|
+
html << _d(2, "<table class='summary'>")
|
86
|
+
html << _d(3, "<tr><th>Name</th><th>Time</th><th>Status</th><th>Error</th></tr>")
|
87
|
+
|
88
|
+
ctx.tests.each_with_index do |t,idx|
|
89
|
+
error = t[:error]
|
90
|
+
error = error ? error.message : ''
|
91
|
+
html << _d(3, "<tr class='#{t[:status].downcase} #{(idx % 2) == 1 ? 'odd' : 'even'}' onclick='show(\"#{t[:name]}\")'>")
|
92
|
+
html << _d(4, "<td>#{t[:name]}</td><td>#{t[:time].round(2)}</td><td class='status'>#{t[:status]}</td><td>#{error}</td>")
|
93
|
+
html << _d(3, "</tr>")
|
94
|
+
end
|
95
|
+
|
96
|
+
html << _d(2, "</table>")
|
97
|
+
end
|
98
|
+
|
99
|
+
html << _d(2, "<h1>Test Details</h1>")
|
100
|
+
@data.each do |test|
|
101
|
+
name = test[:name]
|
102
|
+
status = test[:actions].find { |a| a[:status] == :error } ? :error : :ok
|
103
|
+
html << _d(2, "<a name='#{name}'></a>")
|
104
|
+
html << _d(2, "<div class='test #{status}'>#{name}<div class='status'><div class='text'>#{status.upcase}</div></div></div>")
|
105
|
+
html << _d(2, "<div id='#{name}_content' class='test-content'>")
|
106
|
+
|
107
|
+
test[:actions].each_with_index do |action,idx|
|
108
|
+
html << _d(3, "<div class='action #{action[:status]} #{(idx % 2) == 1 ? 'odd' : 'even'}'>")
|
109
|
+
html << _d(4, "<div class='cmd'>#{action[:cmd]}</div>")
|
110
|
+
html << _d(4, "<div class='args'>#{action[:args].join(' ')}</div>")
|
111
|
+
html << _d(4, "<div class='status'>")
|
112
|
+
html << _d(5, "<div class='time'>(#{action[:time].round(2).to_s}s)</div>")
|
113
|
+
html << _d(5, "<div class='text'>#{action[:status].upcase}</div>")
|
114
|
+
html << _d(4, "</div>")
|
115
|
+
html << _d(3, "</div>")
|
116
|
+
capture = action[:capture]
|
117
|
+
if capture
|
118
|
+
html << _d(3, "<div class='capture'>#{_img(output, capture)}</div>")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
item = ctx.tests.find { |t| t[:name] == name }
|
123
|
+
if item and item[:error]
|
124
|
+
capture = item[:error].variables['__CAPTURE__']
|
125
|
+
if capture
|
126
|
+
html << _d(3, "<div class='capture'>#{_img(output, capture)}</div>")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
html << _d(2, "</div>")
|
131
|
+
end
|
132
|
+
html << "
|
133
|
+
</body>
|
134
|
+
</html>"
|
135
|
+
file = ctx.output_path(@file)
|
136
|
+
File.open(file, 'w') { |f| f.write html }
|
137
|
+
File.delete(*@imgs) if @imgs.size > 0
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
def _d(depth, s)
|
142
|
+
"\n"+depth.times.inject('') { |s,i| s + "\t" } + s
|
143
|
+
end
|
144
|
+
def _img(output, path)
|
145
|
+
if @options[:html_package]
|
146
|
+
content = Base64.encode64(File.open(path, 'rb') { |f| f.read })
|
147
|
+
@imgs << path unless @imgs.include? path
|
148
|
+
"<img src='data:image/png;base64,#{content}'/>"
|
149
|
+
else
|
150
|
+
path = path[output.size+1..-1] unless output == ''
|
151
|
+
"<img src='#{path}'/>"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|