asciidoctor 1.5.8 → 2.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.adoc +628 -45
- data/LICENSE +2 -1
- data/README-de.adoc +28 -38
- data/README-fr.adoc +30 -43
- data/README-jp.adoc +255 -201
- data/README-zh_CN.adoc +40 -44
- data/README.adoc +170 -143
- data/asciidoctor.gemspec +22 -34
- data/bin/asciidoctor +5 -4
- data/data/locale/attributes-ar.adoc +4 -3
- data/data/locale/attributes-be.adoc +23 -0
- data/data/locale/attributes-bg.adoc +4 -3
- data/data/locale/attributes-ca.adoc +6 -5
- data/data/locale/attributes-cs.adoc +4 -3
- data/data/locale/attributes-da.adoc +6 -5
- data/data/locale/attributes-de.adoc +6 -5
- data/data/locale/attributes-en.adoc +4 -4
- data/data/locale/attributes-es.adoc +6 -5
- data/data/locale/attributes-fa.adoc +4 -3
- data/data/locale/attributes-fi.adoc +4 -3
- data/data/locale/attributes-fr.adoc +8 -7
- data/data/locale/attributes-hu.adoc +4 -3
- data/data/locale/attributes-id.adoc +4 -3
- data/data/locale/attributes-it.adoc +6 -5
- data/data/locale/attributes-ja.adoc +4 -3
- data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
- data/data/locale/attributes-nb.adoc +4 -3
- data/data/locale/attributes-nl.adoc +6 -5
- data/data/locale/attributes-nn.adoc +4 -3
- data/data/locale/attributes-pl.adoc +8 -7
- data/data/locale/attributes-pt.adoc +6 -5
- data/data/locale/attributes-pt_BR.adoc +6 -5
- data/data/locale/attributes-ro.adoc +4 -3
- data/data/locale/attributes-ru.adoc +6 -5
- data/data/locale/attributes-sr.adoc +4 -4
- data/data/locale/attributes-sr_Latn.adoc +4 -4
- data/data/locale/attributes-sv.adoc +4 -4
- data/data/locale/attributes-th.adoc +23 -0
- data/data/locale/attributes-tr.adoc +4 -3
- data/data/locale/attributes-uk.adoc +6 -5
- data/data/locale/attributes-vi.adoc +23 -0
- data/data/locale/attributes-zh_CN.adoc +4 -3
- data/data/locale/attributes-zh_TW.adoc +4 -3
- data/data/reference/syntax.adoc +296 -0
- data/data/stylesheets/asciidoctor-default.css +120 -114
- data/data/stylesheets/coderay-asciidoctor.css +15 -17
- data/lib/asciidoctor/abstract_block.rb +146 -140
- data/lib/asciidoctor/abstract_node.rb +152 -170
- data/lib/asciidoctor/attribute_list.rb +77 -89
- data/lib/asciidoctor/block.rb +29 -28
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli/invoker.rb +20 -24
- data/lib/asciidoctor/cli/options.rb +107 -96
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/convert.rb +199 -0
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +627 -644
- data/lib/asciidoctor/converter/html5.rb +1053 -951
- data/lib/asciidoctor/converter/manpage.rb +581 -532
- data/lib/asciidoctor/converter/template.rb +232 -271
- data/lib/asciidoctor/converter.rb +370 -185
- data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
- data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
- data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
- data/lib/asciidoctor/core_ext.rb +8 -17
- data/lib/asciidoctor/document.rb +503 -461
- data/lib/asciidoctor/extensions.rb +127 -174
- data/lib/asciidoctor/helpers.rb +184 -107
- data/lib/asciidoctor/inline.rb +9 -12
- data/lib/asciidoctor/list.rb +11 -29
- data/lib/asciidoctor/load.rb +119 -0
- data/lib/asciidoctor/logging.rb +22 -17
- data/lib/asciidoctor/parser.rb +673 -719
- data/lib/asciidoctor/path_resolver.rb +48 -33
- data/lib/asciidoctor/reader.rb +383 -338
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/rx.rb +723 -0
- data/lib/asciidoctor/section.rb +17 -16
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +926 -1022
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
- data/lib/asciidoctor/syntax_highlighter.rb +253 -0
- data/lib/asciidoctor/table.rb +152 -114
- data/lib/asciidoctor/timings.rb +7 -5
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/lib/asciidoctor.rb +266 -1340
- data/man/asciidoctor.1 +49 -47
- data/man/asciidoctor.adoc +54 -45
- metadata +50 -245
- data/CONTRIBUTING.adoc +0 -185
- data/Gemfile +0 -60
- data/Rakefile +0 -129
- data/bin/asciidoctor-safe +0 -15
- data/features/open_block.feature +0 -92
- data/features/pass_block.feature +0 -66
- data/features/step_definitions.rb +0 -49
- data/features/text_formatting.feature +0 -57
- data/features/xref.feature +0 -1039
- data/lib/asciidoctor/converter/base.rb +0 -59
- data/lib/asciidoctor/converter/docbook45.rb +0 -93
- data/lib/asciidoctor/converter/factory.rb +0 -226
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
- data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
- data/test/api_test.rb +0 -1240
- data/test/attribute_list_test.rb +0 -242
- data/test/attributes_test.rb +0 -1623
- data/test/blocks_test.rb +0 -3870
- data/test/converter_test.rb +0 -470
- data/test/document_test.rb +0 -1853
- data/test/extensions_test.rb +0 -1560
- data/test/fixtures/asciidoc_index.txt +0 -521
- data/test/fixtures/basic-docinfo-footer.html +0 -6
- data/test/fixtures/basic-docinfo-footer.xml +0 -8
- data/test/fixtures/basic-docinfo.html +0 -1
- data/test/fixtures/basic-docinfo.xml +0 -4
- data/test/fixtures/basic.asciidoc +0 -5
- data/test/fixtures/chapter-a.adoc +0 -3
- data/test/fixtures/child-include.adoc +0 -5
- data/test/fixtures/circle.svg +0 -9
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
- data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
- data/test/fixtures/docinfo-footer.html +0 -1
- data/test/fixtures/docinfo-footer.xml +0 -9
- data/test/fixtures/docinfo.html +0 -1
- data/test/fixtures/docinfo.xml +0 -3
- data/test/fixtures/doctime-localtime.adoc +0 -2
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/file-with-missing-include.adoc +0 -1
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -69
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.jsx +0 -8
- data/test/fixtures/include-file.ml +0 -3
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/lists.adoc +0 -96
- data/test/fixtures/master.adoc +0 -5
- data/test/fixtures/mismatched-end-tag.adoc +0 -7
- data/test/fixtures/other-chapters.adoc +0 -11
- data/test/fixtures/outer-include.adoc +0 -5
- data/test/fixtures/parent-include-restricted.adoc +0 -5
- data/test/fixtures/parent-include.adoc +0 -5
- data/test/fixtures/sample.asciidoc +0 -30
- data/test/fixtures/section-a.adoc +0 -4
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subdir/index.adoc +0 -3
- data/test/fixtures/subdir/inner-include.adoc +0 -3
- data/test/fixtures/subdir/middle-include.adoc +0 -5
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -6
- data/test/fixtures/tagged-class-enclosed.rb +0 -25
- data/test/fixtures/tagged-class.rb +0 -23
- data/test/fixtures/tip.gif +0 -0
- data/test/fixtures/unclosed-tag.adoc +0 -3
- data/test/fixtures/unexpected-end-tag.adoc +0 -4
- data/test/invoker_test.rb +0 -745
- data/test/links_test.rb +0 -855
- data/test/lists_test.rb +0 -5151
- data/test/logger_test.rb +0 -211
- data/test/manpage_test.rb +0 -660
- data/test/options_test.rb +0 -262
- data/test/paragraphs_test.rb +0 -562
- data/test/parser_test.rb +0 -742
- data/test/paths_test.rb +0 -395
- data/test/preamble_test.rb +0 -173
- data/test/reader_test.rb +0 -2161
- data/test/sections_test.rb +0 -3575
- data/test/substitutions_test.rb +0 -2066
- data/test/tables_test.rb +0 -2036
- data/test/test_helper.rb +0 -447
- data/test/text_test.rb +0 -309
data/test/options_test.rb
DELETED
@@ -1,262 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
unless defined? ASCIIDOCTOR_PROJECT_DIR
|
3
|
-
$: << File.dirname(__FILE__); $:.uniq!
|
4
|
-
require 'test_helper'
|
5
|
-
end
|
6
|
-
require 'asciidoctor/cli/options'
|
7
|
-
|
8
|
-
context 'Options' do
|
9
|
-
test 'should print usage and return error code 0 when help flag is present' do
|
10
|
-
redirect_streams do |stdout, stderr|
|
11
|
-
exitval = Asciidoctor::Cli::Options.parse!(%w(-h))
|
12
|
-
assert_equal 0, exitval
|
13
|
-
assert_match(/^Usage:/, stdout.string)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'should print usage and return error code 0 when help flag is unknown' do
|
18
|
-
exitval, output = redirect_streams do |out, _|
|
19
|
-
[Asciidoctor::Cli::Options.parse!(%w(-h unknown)), out.string]
|
20
|
-
end
|
21
|
-
assert_equal 0, exitval
|
22
|
-
assert_match(/^Usage:/, output)
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'should dump man page and return error code 0 when help topic is manpage' do
|
26
|
-
exitval, output = redirect_streams do |out, _|
|
27
|
-
[Asciidoctor::Cli::Options.parse!(%w(-h manpage)), out.string]
|
28
|
-
end
|
29
|
-
assert_equal 0, exitval
|
30
|
-
assert_includes output, 'Manual: Asciidoctor Manual'
|
31
|
-
assert_includes output, '.TH "ASCIIDOCTOR"'
|
32
|
-
end
|
33
|
-
|
34
|
-
test 'should print message and return error code 1 when manpage is not found' do
|
35
|
-
old_manpage_path = ENV['ASCIIDOCTOR_MANPAGE_PATH']
|
36
|
-
begin
|
37
|
-
ENV['ASCIIDOCTOR_MANPAGE_PATH'] = (manpage_path = fixture_path 'no-such-file.1')
|
38
|
-
redirect_streams do |out, stderr|
|
39
|
-
exitval = Asciidoctor::Cli::Options.parse!(%w(-h manpage))
|
40
|
-
assert_equal 1, exitval
|
41
|
-
assert_equal %(asciidoctor: FAILED: manual page not found: #{manpage_path}), stderr.string.chomp
|
42
|
-
end
|
43
|
-
ensure
|
44
|
-
if old_manpage_path
|
45
|
-
ENV['ASCIIDOCTOR_MANPAGE_PATH'] = old_manpage_path
|
46
|
-
else
|
47
|
-
ENV.delete 'ASCIIDOCTOR_MANPAGE_PATH'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
test 'should return error code 1 when invalid option present' do
|
53
|
-
redirect_streams do |stdout, stderr|
|
54
|
-
exitval = Asciidoctor::Cli::Options.parse!(%w(--foobar))
|
55
|
-
assert_equal 1, exitval
|
56
|
-
assert_equal 'asciidoctor: invalid option: --foobar', stderr.string.chomp
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
test 'should return error code 1 when option has invalid argument' do
|
61
|
-
redirect_streams do |stdout, stderr|
|
62
|
-
exitval = Asciidoctor::Cli::Options.parse!(%w(-d chapter input.ad)) # had to change for #320
|
63
|
-
assert_equal 1, exitval
|
64
|
-
assert_equal 'asciidoctor: invalid argument: -d chapter', stderr.string.chomp
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
test 'should return error code 1 when option is missing required argument' do
|
69
|
-
redirect_streams do |stdout, stderr|
|
70
|
-
exitval = Asciidoctor::Cli::Options.parse!(%w(-b))
|
71
|
-
assert_equal 1, exitval
|
72
|
-
assert_equal 'asciidoctor: option missing argument: -b', stderr.string.chomp
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test 'should emit warning when unparsed options remain' do
|
77
|
-
redirect_streams do |stdout, stderr|
|
78
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-b docbook - -))
|
79
|
-
assert_kind_of Hash, options
|
80
|
-
assert_match(/asciidoctor: WARNING: extra arguments .*/, stderr.string.chomp)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
test 'basic argument assignment' do
|
85
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-v -s -d book test/fixtures/sample.asciidoc))
|
86
|
-
|
87
|
-
assert_equal 2, options[:verbose]
|
88
|
-
assert_equal false, options[:header_footer]
|
89
|
-
assert_equal 'book', options[:attributes]['doctype']
|
90
|
-
assert_equal 1, options[:input_files].size
|
91
|
-
assert_equal 'test/fixtures/sample.asciidoc', options[:input_files][0]
|
92
|
-
end
|
93
|
-
|
94
|
-
test 'standard attribute assignment' do
|
95
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-a docinfosubs=attributes,replacements -a icons test/fixtures/sample.asciidoc))
|
96
|
-
|
97
|
-
assert_equal 'attributes,replacements', options[:attributes]['docinfosubs']
|
98
|
-
assert_equal '', options[:attributes]['icons']
|
99
|
-
end
|
100
|
-
|
101
|
-
test 'multiple attribute arguments' do
|
102
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-a imagesdir=images -a icons test/fixtures/sample.asciidoc))
|
103
|
-
|
104
|
-
assert_equal 'images', options[:attributes]['imagesdir']
|
105
|
-
assert_equal '', options[:attributes]['icons']
|
106
|
-
end
|
107
|
-
|
108
|
-
test 'should only split attribute key/value pairs on first equal sign' do
|
109
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-a name=value=value test/fixtures/sample.asciidoc))
|
110
|
-
|
111
|
-
assert_equal 'value=value', options[:attributes]['name']
|
112
|
-
end
|
113
|
-
|
114
|
-
test 'should allow safe mode to be specified' do
|
115
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-S safe test/fixtures/sample.asciidoc))
|
116
|
-
assert_equal Asciidoctor::SafeMode::SAFE, options[:safe]
|
117
|
-
end
|
118
|
-
|
119
|
-
test 'should allow any backend to be specified' do
|
120
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-b my_custom_backend test/fixtures/sample.asciidoc))
|
121
|
-
|
122
|
-
assert_equal 'my_custom_backend', options[:attributes]['backend']
|
123
|
-
end
|
124
|
-
|
125
|
-
test 'article doctype assignment' do
|
126
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-d article test/fixtures/sample.asciidoc))
|
127
|
-
assert_equal 'article', options[:attributes]['doctype']
|
128
|
-
end
|
129
|
-
|
130
|
-
test 'book doctype assignment' do
|
131
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-d book test/fixtures/sample.asciidoc))
|
132
|
-
assert_equal 'book', options[:attributes]['doctype']
|
133
|
-
end
|
134
|
-
|
135
|
-
test 'inline doctype assignment' do
|
136
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-d inline test/fixtures/sample.asciidoc))
|
137
|
-
assert_equal 'inline', options[:attributes]['doctype']
|
138
|
-
end
|
139
|
-
|
140
|
-
test 'template engine assignment' do
|
141
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-E haml test/fixtures/sample.asciidoc))
|
142
|
-
assert_equal 'haml', options[:template_engine]
|
143
|
-
end
|
144
|
-
|
145
|
-
test 'template directory assignment' do
|
146
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-T custom-backend test/fixtures/sample.asciidoc))
|
147
|
-
assert_equal ['custom-backend'], options[:template_dirs]
|
148
|
-
end
|
149
|
-
|
150
|
-
test 'multiple template directory assignments' do
|
151
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-T custom-backend -T custom-backend-hacks test/fixtures/sample.asciidoc))
|
152
|
-
assert_equal ['custom-backend', 'custom-backend-hacks'], options[:template_dirs]
|
153
|
-
end
|
154
|
-
|
155
|
-
test 'multiple -r flags requires specified libraries' do
|
156
|
-
options = Asciidoctor::Cli::Options.new
|
157
|
-
redirect_streams do |stdout, stderr|
|
158
|
-
exitval = options.parse! %w(-r foobar -r foobaz test/fixtures/sample.asciidoc)
|
159
|
-
assert_match(%(asciidoctor: FAILED: 'foobar' could not be loaded), stderr.string)
|
160
|
-
assert_equal 1, exitval
|
161
|
-
assert_equal ['foobar', 'foobaz'], options[:requires]
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
test '-r flag with multiple values requires specified libraries' do
|
166
|
-
options = Asciidoctor::Cli::Options.new
|
167
|
-
redirect_streams do |stdout, stderr|
|
168
|
-
exitval = options.parse! %w(-r foobar,foobaz test/fixtures/sample.asciidoc)
|
169
|
-
assert_match(%(asciidoctor: FAILED: 'foobar' could not be loaded), stderr.string)
|
170
|
-
assert_equal 1, exitval
|
171
|
-
assert_equal ['foobar', 'foobaz'], options[:requires]
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
test '-I option appends paths to $LOAD_PATH' do
|
176
|
-
options = Asciidoctor::Cli::Options.new
|
177
|
-
old_load_path = $LOAD_PATH.dup
|
178
|
-
begin
|
179
|
-
exitval = options.parse! %w(-I foobar -I foobaz test/fixtures/sample.asciidoc)
|
180
|
-
refute_equal 1, exitval
|
181
|
-
assert_equal old_load_path.size + 2, $LOAD_PATH.size
|
182
|
-
assert_equal File.expand_path('foobar'), $LOAD_PATH[0]
|
183
|
-
assert_equal File.expand_path('foobaz'), $LOAD_PATH[1]
|
184
|
-
assert_equal ['foobar', 'foobaz'], options[:load_paths]
|
185
|
-
ensure
|
186
|
-
($LOAD_PATH.size - old_load_path.size).times { $LOAD_PATH.shift }
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
test '-I option appends multiple paths to $LOAD_PATH' do
|
191
|
-
options = Asciidoctor::Cli::Options.new
|
192
|
-
old_load_path = $LOAD_PATH.dup
|
193
|
-
begin
|
194
|
-
exitval = options.parse! %W(-I foobar#{File::PATH_SEPARATOR}foobaz test/fixtures/sample.asciidoc)
|
195
|
-
refute_equal 1, exitval
|
196
|
-
assert_equal old_load_path.size + 2, $LOAD_PATH.size
|
197
|
-
assert_equal File.expand_path('foobar'), $LOAD_PATH[0]
|
198
|
-
assert_equal File.expand_path('foobaz'), $LOAD_PATH[1]
|
199
|
-
assert_equal ['foobar', 'foobaz'], options[:load_paths]
|
200
|
-
ensure
|
201
|
-
($LOAD_PATH.size - old_load_path.size).times { $LOAD_PATH.shift }
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
test 'should set failure level to FATAL by default' do
|
206
|
-
options = Asciidoctor::Cli::Options.parse! %W(test/fixtures/sample.asciidoc)
|
207
|
-
assert_equal ::Logger::Severity::FATAL, options[:failure_level]
|
208
|
-
end
|
209
|
-
|
210
|
-
test 'should allow failure level to be set to WARN' do
|
211
|
-
%w(w warn WARN warning WARNING).each do |val|
|
212
|
-
options = Asciidoctor::Cli::Options.parse!(%W(--failure-level=#{val} test/fixtures/sample.asciidoc))
|
213
|
-
assert_equal ::Logger::Severity::WARN, options[:failure_level]
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
test 'should allow failure level to be set to ERROR' do
|
218
|
-
%w(e err ERR error ERROR).each do |val|
|
219
|
-
options = Asciidoctor::Cli::Options.parse!(%W(--failure-level=#{val} test/fixtures/sample.asciidoc))
|
220
|
-
assert_equal ::Logger::Severity::ERROR, options[:failure_level]
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
test 'should not allow failure level to be set to unknown value' do
|
225
|
-
exit_code, messages = redirect_streams do |_, err|
|
226
|
-
[(Asciidoctor::Cli::Options.parse! %W(--failure-level=foobar test/fixtures/sample.asciidoc)), err.string]
|
227
|
-
end
|
228
|
-
assert_equal 1, exit_code
|
229
|
-
assert_includes messages, 'invalid argument: --failure-level=foobar'
|
230
|
-
end
|
231
|
-
|
232
|
-
test 'should set verbose to 2 when -v flag is specified' do
|
233
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-v test/fixtures/sample.asciidoc))
|
234
|
-
assert_equal 2, options[:verbose]
|
235
|
-
end
|
236
|
-
|
237
|
-
test 'should set verbose to 0 when -q flag is specified' do
|
238
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-q test/fixtures/sample.asciidoc))
|
239
|
-
assert_equal 0, options[:verbose]
|
240
|
-
end
|
241
|
-
|
242
|
-
test 'should set verbose to 2 when -v flag is specified after -q flag' do
|
243
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-q -v test/fixtures/sample.asciidoc))
|
244
|
-
assert_equal 2, options[:verbose]
|
245
|
-
end
|
246
|
-
|
247
|
-
test 'should set verbose to 0 when -q flag is specified after -v flag' do
|
248
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-v -q test/fixtures/sample.asciidoc))
|
249
|
-
assert_equal 0, options[:verbose]
|
250
|
-
end
|
251
|
-
|
252
|
-
test 'should enable timings when -t flag is specified' do
|
253
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-t test/fixtures/sample.asciidoc))
|
254
|
-
assert_equal true, options[:timings]
|
255
|
-
end
|
256
|
-
|
257
|
-
test 'timings option is disable by default' do
|
258
|
-
options = Asciidoctor::Cli::Options.parse!(%w(test/fixtures/sample.asciidoc))
|
259
|
-
assert_equal false, options[:timings]
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|