diff options
Diffstat (limited to 'test/reader_test.rb')
| -rw-r--r-- | test/reader_test.rb | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/test/reader_test.rb b/test/reader_test.rb index ed03084e..a1419556 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -24,7 +24,7 @@ third line test 'should remove UTF-8 BOM from first line of String data' do ['UTF-8', 'ASCII-8BIT'].each do |start_encoding| data = "\xef\xbb\xbf#{SAMPLE_DATA.join ::Asciidoctor::LF}".force_encoding start_encoding - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -35,7 +35,7 @@ third line ['UTF-8', 'ASCII-8BIT'].each do |start_encoding| data = SAMPLE_DATA.dup data[0] = "\xef\xbb\xbf#{data.first}".force_encoding start_encoding - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -45,7 +45,7 @@ third line test 'should encode UTF-16LE string to UTF-8 when BOM is found' do ['UTF-8', 'ASCII-8BIT'].each do |start_encoding| data = "\ufeff#{SAMPLE_DATA.join ::Asciidoctor::LF}".encode('UTF-16LE').force_encoding(start_encoding) - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -58,7 +58,7 @@ third line data = SAMPLE_DATA.dup data.unshift %(\ufeff#{data.shift}) data.each {|line| (line.encode 'UTF-16LE').force_encoding start_encoding } - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -68,7 +68,7 @@ third line test 'should encode UTF-16BE string to UTF-8 when BOM is found' do ['UTF-8', 'ASCII-8BIT'].each do |start_encoding| data = "\ufeff#{SAMPLE_DATA.join ::Asciidoctor::LF}".encode('UTF-16BE').force_encoding(start_encoding) - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -80,7 +80,7 @@ third line data = SAMPLE_DATA.dup data.unshift %(\ufeff#{data.shift}) data = data.map {|line| (line.encode 'UTF-16BE').force_encoding start_encoding } - reader = Asciidoctor::Reader.new data, nil, :normalize => true + reader = Asciidoctor::Reader.new data, nil, normalize: true assert_equal Encoding::UTF_8, reader.lines[0].encoding assert_equal 'f', reader.lines[0].chr assert_equal SAMPLE_DATA, reader.lines @@ -223,7 +223,7 @@ third line end test 'unshift puts line onto Reader as next line to read' do - reader = Asciidoctor::Reader.new SAMPLE_DATA, nil, :normalize => true + reader = Asciidoctor::Reader.new SAMPLE_DATA, nil, normalize: true reader.unshift 'line zero' assert_equal 'line zero', reader.peek_line assert_equal 'line zero', reader.read_line @@ -292,7 +292,7 @@ This is one paragraph. This is another paragraph. EOS - reader = Asciidoctor::Reader.new lines, nil, :normalize => true + reader = Asciidoctor::Reader.new lines, nil, normalize: true result = reader.read_lines_until assert_equal 3, result.size assert_equal lines.map {|l| l.chomp }, result @@ -307,8 +307,8 @@ This is one paragraph. This is another paragraph. EOS - reader = Asciidoctor::Reader.new lines, nil, :normalize => true - result = reader.read_lines_until :break_on_blank_lines => true + reader = Asciidoctor::Reader.new lines, nil, normalize: true + result = reader.read_lines_until break_on_blank_lines: true assert_equal 1, result.size assert_equal lines.first.chomp, result.first assert_equal lines.last.chomp, reader.peek_line @@ -322,7 +322,7 @@ This is another paragraph. EOS reader = Asciidoctor::Reader.new lines - result = reader.read_lines_until :break_on_blank_lines => true, :preserve_last_line => true + result = reader.read_lines_until break_on_blank_lines: true, preserve_last_line: true assert_equal 1, result.size assert_equal lines.first.chomp, result.first assert reader.next_line_empty? @@ -360,7 +360,7 @@ This is a paragraph outside the block. reader = Asciidoctor::Reader.new lines reader.read_line - result = reader.read_lines_until(:read_last_line => true) {|line| line == '--' } + result = reader.read_lines_until(read_last_line: true) {|line| line == '--' } assert_equal 4, result.size assert_equal lines[1, 4], result assert reader.next_line_empty? @@ -379,7 +379,7 @@ This is a paragraph outside the block. reader = Asciidoctor::Reader.new lines reader.read_line - result = reader.read_lines_until(:read_last_line => true, :preserve_last_line => true) {|line| line == '--' } + result = reader.read_lines_until(read_last_line: true, preserve_last_line: true) {|line| line == '--' } assert_equal 4, result.size assert_equal lines[1, 4], result assert_equal '--', reader.peek_line @@ -398,10 +398,10 @@ not captured expected = ['captured', '', 'also captured'] - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true terminator = reader.read_line - result = reader.read_lines_until :terminator => terminator, :skip_processing => true + result = reader.read_lines_until terminator: terminator, skip_processing: true assert_equal expected, result refute reader.unterminated end @@ -419,10 +419,10 @@ captured yet again expected = lines[1..-1].map {|l| l.chomp } using_memory_logger do |logger| - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true terminator = reader.peek_line - result = reader.read_lines_until :terminator => terminator, :skip_first_line => true, :skip_processing => true + result = reader.read_lines_until terminator: terminator, skip_first_line: true, skip_processing: true assert_equal expected, result assert reader.unterminated assert_message logger, :WARN, '<stdin>: line 1: unterminated **** block', Hash @@ -520,7 +520,7 @@ Author Name preamble EOS - doc = Asciidoctor::Document.new input, :attributes => {'skip-front-matter' => ''} + doc = Asciidoctor::Document.new input, attributes: { 'skip-front-matter' => '' } reader = doc.reader assert_equal '= Document Title', reader.peek_line assert_equal front_matter, doc.attributes['front-matter'] @@ -603,7 +603,7 @@ include::include-file.asciidoc[] include::fixtures/include-file.asciidoc[] EOS - doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME output = doc.convert assert_match(/included content/, output) assert doc.catalog[:includes]['fixtures/include-file'] @@ -616,7 +616,7 @@ include::fixtures/circle.svg[] ---- EOS - doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME assert doc.catalog[:includes].empty? end @@ -629,7 +629,7 @@ include::fixtures/include file.asciidoc[] include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc' begin FileUtils.cp include_file, include_file_with_sp - doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME output = doc.convert assert_match(/included content/, output) ensure @@ -646,7 +646,7 @@ include::fixtures/include{sp}file.asciidoc[] include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc' begin FileUtils.cp include_file, include_file_with_sp - doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME output = doc.convert assert_match(/included content/, output) ensure @@ -665,8 +665,8 @@ include::fixtures/parent-include.adoc[] child_include_docfile = File.join fixtures_dir, 'child-include.adoc' grandchild_include_docfile = File.join fixtures_dir, 'grandchild-include.adoc' - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, input, pseudo_docfile, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, input, pseudo_docfile, normalize: true assert_equal pseudo_docfile, reader.file assert_equal DIRNAME, reader.dir @@ -724,7 +724,7 @@ trailing content begin using_memory_logger do |logger| - doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, base_dir: DIRNAME assert_equal 1, doc.blocks.size assert_equal ['trailing content'], doc.blocks[0].lines assert logger.empty? @@ -743,7 +743,7 @@ trailing content begin using_memory_logger do |logger| - doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, base_dir: DIRNAME assert_equal 2, doc.blocks.size assert_equal ['Unresolved directive in <stdin> - include::fixtures/no-such-file.adoc[]'], doc.blocks[0].lines assert_equal ['trailing content'], doc.blocks[1].lines @@ -765,7 +765,7 @@ trailing content begin using_memory_logger do |logger| - doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, base_dir: DIRNAME assert_equal 2, doc.blocks.size assert_equal ['Unresolved directive in <stdin> - include::fixtures/chapter-a.adoc[]'], doc.blocks[0].lines assert_equal ['trailing content'], doc.blocks[1].lines @@ -784,10 +784,10 @@ trailing content input = <<-EOS include::#{include_path}[] EOS - result = document_from_string input, :safe => :safe + result = document_from_string input, safe: :safe assert_equal 'Chapter A', result.doctitle - result = document_from_string input, :safe => :unsafe, :base_dir => ::Dir.tmpdir + result = document_from_string input, safe: :unsafe, base_dir: ::Dir.tmpdir assert_equal 'Chapter A', result.doctitle end @@ -800,7 +800,7 @@ include::#{url}[] EOS expect = /\{"name": "asciidoctor"\}/ output = using_test_webserver do - convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''} + convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' } end refute_nil output @@ -814,7 +814,7 @@ include::fixtures/outer-include.adoc[] .... EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = 'first line of outer first line of middle @@ -837,7 +837,7 @@ include::#{url}[] .... EOS output = using_test_webserver do - convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''} + convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' } end expected = 'first line of outer @@ -865,7 +865,7 @@ include::#{include_url}[] begin using_memory_logger do |logger| result = using_test_webserver do - convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''} + convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' } end assert_includes result, %(Unresolved directive in #{include_url} - include::#{nested_include_url}[]) assert_message logger, :ERROR, %(#{include_url}: line 1: include uri not readable: http://#{resolve_localhost}:9876/fixtures/#{nested_include_url}), Hash @@ -884,7 +884,7 @@ include::#{url}[tag=init,indent=0] ---- EOS output = using_test_webserver do - convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''} + convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' } end expected = '<code class="language-ruby" data-lang="ruby">def initialize breed @@ -904,7 +904,7 @@ include::#{url}[] begin using_memory_logger do |logger| output = using_test_webserver do - convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''} + convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' } end refute_nil output assert_match(/Unresolved directive/, output) @@ -920,7 +920,7 @@ include::#{url}[] include::fixtures/include-file.asciidoc[lines=1;3..4;6..-1] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/first line/, output) refute_match(/second line/, output) assert_match(/third line/, output) @@ -937,7 +937,7 @@ include::fixtures/include-file.asciidoc[lines=1;3..4;6..-1] include::fixtures/include-file.asciidoc[lines="1, 3..4 , 6 .. -1"] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/first line/, output) refute_match(/second line/, output) assert_match(/third line/, output) @@ -954,7 +954,7 @@ include::fixtures/include-file.asciidoc[lines="1, 3..4 , 6 .. -1"] include::fixtures/include-file.asciidoc[lines=6..] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME refute_match(/first line/, output) refute_match(/second line/, output) refute_match(/third line/, output) @@ -973,7 +973,7 @@ include::fixtures/include-file.asciidoc[lines=] ++++ EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_includes output, 'first line of included content' assert_includes output, 'last line of included content' end @@ -983,7 +983,7 @@ include::fixtures/include-file.asciidoc[lines=] include::fixtures/include-file.asciidoc[tag=snippetA] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/snippetA content/, output) refute_match(/snippetB content/, output) refute_match(/non-tagged content/, output) @@ -995,7 +995,7 @@ include::fixtures/include-file.asciidoc[tag=snippetA] include::fixtures/include-file.asciidoc[tags=snippetA;snippetB] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/snippetA content/, output) assert_match(/snippetB content/, output) refute_match(/non-tagged content/, output) @@ -1006,7 +1006,7 @@ include::fixtures/include-file.asciidoc[tags=snippetA;snippetB] { 'include-file.xml' => '<snippet>content</snippet>', 'include-file.ml' => 'let s = SS.empty;;', - 'include-file.jsx' => '<p>Welcome to the club.</p>' + 'include-file.jsx' => '<p>Welcome to the club.</p>', }.each do |filename, expect| input = <<-EOS [source,xml] @@ -1015,7 +1015,7 @@ include::fixtures/#{filename}[tag=snippet,indent=0] ---- EOS - doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, base_dir: DIRNAME assert_equal expect, doc.blocks[0].source end end @@ -1029,12 +1029,12 @@ include::fixtures/#{filename}[tag=snippet,indent=0] input = <<-EOS include::#{tmp_include_path}[tag=include-me] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => tmp_include_dir + output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir assert_includes output, 'included line' refute_includes output, 'do not include' ensure tmp_include.close! - end + end end test 'include directive finds closing tag on last line of file without a trailing newline' do @@ -1047,14 +1047,14 @@ include::#{tmp_include_path}[tag=include-me] include::#{tmp_include_path}[tag=include-me] EOS using_memory_logger do |logger| - output = convert_string_to_embedded input, :safe => :safe, :base_dir => tmp_include_dir + output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir assert_empty logger.messages assert_includes output, 'line included' refute_includes output, 'line not included' end ensure tmp_include.close! - end + end end test 'include directive does not select lines with tag directives within selected tag region' do @@ -1064,7 +1064,7 @@ include::fixtures/include-file.asciidoc[tags=snippet] ++++ EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expect = %(snippetA content non-tagged content @@ -1080,7 +1080,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=all;!bark] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog def initialize breed @breed = breed @@ -1096,7 +1096,7 @@ include::fixtures/tagged-class.rb[tags=**] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog def initialize breed @breed = breed @@ -1120,7 +1120,7 @@ include::fixtures/tagged-class.rb[tags=**;!bark] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog def initialize breed @breed = breed @@ -1136,7 +1136,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=*] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog def initialize breed @breed = breed @@ -1160,7 +1160,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=*;!init] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog def bark @@ -1181,7 +1181,7 @@ include::fixtures/tagged-class.rb[tags=!*] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(class Dog end) assert_includes output, expected @@ -1195,7 +1195,7 @@ include::fixtures/tagged-class.rb[tags=bark;!bark-other] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected = %(def bark if @breed == 'beagle' 'woof woof woof woof woof' @@ -1210,7 +1210,7 @@ include::fixtures/include-file.asciidoc[tag=no-such-tag] EOS using_memory_logger do |logger| - convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_message logger, :WARN, %(~<stdin>: line 1: tag 'no-such-tag' not found in include file), Hash end end @@ -1223,7 +1223,7 @@ include::fixtures/include-file.asciidoc[tags=no-such-tag-b;no-such-tag-a] EOS using_memory_logger do |logger| - convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME expected_tags = 'no-such-tag-b, no-such-tag-a' assert_message logger, :WARN, %(~<stdin>: line 2: tags '#{expected_tags}' not found in include file), Hash end @@ -1237,7 +1237,7 @@ include::fixtures/unclosed-tag.adoc[tag=a] EOS using_memory_logger do |logger| - result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_equal 'a', result assert_message logger, :WARN, %(~<stdin>: line 2: detected unclosed tag 'a' starting at line 2 of include file), Hash refute_nil logger.messages[0][:message][:include_location] @@ -1253,7 +1253,7 @@ include::fixtures/mismatched-end-tag.adoc[tags=a;b] inc_path = File.join DIRNAME, 'fixtures/mismatched-end-tag.adoc' using_memory_logger do |logger| - result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_equal %(a\nb), result assert_message logger, :WARN, %(<stdin>: line 2: mismatched end tag (expected 'b' but found 'a') at line 5 of include file: #{inc_path}), Hash refute_nil logger.messages[0][:message][:include_location] @@ -1269,7 +1269,7 @@ include::fixtures/unexpected-end-tag.adoc[tags=a] inc_path = File.join DIRNAME, 'fixtures/unexpected-end-tag.adoc' using_memory_logger do |logger| - result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_equal 'a', result assert_message logger, :WARN, %(<stdin>: line 2: unexpected end tag 'a' at line 4 of include file: #{inc_path}), Hash refute_nil logger.messages[0][:message][:include_location] @@ -1284,7 +1284,7 @@ include::fixtures/include-file.xml[#{attr_name}=] ++++ EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/(?:tag|end)::/, output, 2) end end @@ -1294,7 +1294,7 @@ include::fixtures/include-file.xml[#{attr_name}=] include::fixtures/include-file.asciidoc[lines=1, tags=snippetA;snippetB] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/first line of included content/, output) refute_match(/snippetA content/, output) refute_match(/snippetB content/, output) @@ -1308,7 +1308,7 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0] ---- EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME result = xmlnodes_at_xpath('//pre', output, 1).text assert_equal "<year>2013</year>\n<holder>Acme™, Inc.</holder>", result end @@ -1319,7 +1319,7 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0] include::fixtures/include-file.asciidoc[tag={name-of-tag}] EOS - output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME assert_match(/snippetA content/, output) refute_match(/snippetB content/, output) refute_match(/non-tagged content/, output) @@ -1344,8 +1344,8 @@ include::fixtures/include-file.asciidoc[] end } - document = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new document, input, nil, :normalize => true + document = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new document, input, nil, normalize: true reader.instance_variable_set '@include_processors', [include_processor.new(document)] lines = reader.read_lines source = lines * ::Asciidoctor::LF @@ -1371,7 +1371,7 @@ content :leveloffset!: EOS - document = Asciidoctor.load input, :safe => :safe, :base_dir => DIRNAME, :parse => false + document = Asciidoctor.load input, safe: :safe, base_dir: DIRNAME, parse: false assert_equal expected, document.reader.read_lines end @@ -1383,7 +1383,7 @@ content include::{fixturesdir}/include-file.{ext}[] EOS - doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME + doc = document_from_string input, safe: :safe, base_dir: DIRNAME output = doc.convert assert_match(/included content/, output) end @@ -1394,8 +1394,8 @@ include::{foodir}/include-file.asciidoc[] EOS using_memory_logger do |logger| - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true line = reader.read_line assert_equal 'Unresolved directive in <stdin> - include::{foodir}/include-file.asciidoc[]', line assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir' @@ -1408,8 +1408,8 @@ include::{foodir}/include-file.asciidoc[] EOS using_memory_logger do |logger| - doc = empty_safe_document :base_dir => DIRNAME, :attributes => {'attribute-missing' => 'drop'} - reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME, attributes: { 'attribute-missing' => 'drop' } + reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true line = reader.read_line assert_nil line assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir' @@ -1423,8 +1423,8 @@ yo EOS using_memory_logger do |logger| - doc = empty_safe_document :base_dir => DIRNAME, :attributes => {'attribute-missing' => 'drop'} - reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME, attributes: { 'attribute-missing' => 'drop' } + reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true line = reader.read_line assert_equal 'yo', line assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir' @@ -1436,8 +1436,8 @@ yo \\include::fixtures/include-file.asciidoc[] \\escape preserved here EOS - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true # we should be able to peek it multiple times and still have the backslash preserved # this is the test for @unescape_next_line assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line @@ -1461,7 +1461,7 @@ yo input = <<-EOS include::include-file.asciidoc[] EOS - para = block_from_string input, :safe => :safe, :attributes => { 'max-include-depth' => 0 } + para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 } assert_equal 1, para.lines.size assert_equal 'include::include-file.asciidoc[]', para.source end @@ -1472,7 +1472,7 @@ include::include-file.asciidoc[] include::include-file.asciidoc[] EOS - para = block_from_string input, :safe => :safe, :attributes => { 'max-include-depth' => 0 } + para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 } assert_equal 1, para.lines.size assert_equal 'include::include-file.asciidoc[]', para.source end @@ -1484,8 +1484,8 @@ include::fixtures/parent-include.adoc[depth=1] using_memory_logger do |logger| pseudo_docfile = File.join DIRNAME, 'include-master.adoc' - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), normalize: true lines = reader.readlines assert_includes lines, 'include::child-include.adoc[]' assert_message logger, :ERROR, 'fixtures/parent-include.adoc: line 3: maximum include depth of 1 exceeded', Hash @@ -1499,8 +1499,8 @@ include::fixtures/parent-include-restricted.adoc[depth=3] using_memory_logger do |logger| pseudo_docfile = File.join DIRNAME, 'include-master.adoc' - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), normalize: true lines = reader.readlines assert_includes lines, 'first line of child' assert_includes lines, 'include::grandchild-include.adoc[]' @@ -1515,10 +1515,10 @@ include::fixtures/no-such-file.adoc[] //// EOS - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true reader.read_line - result = reader.read_lines_until(:terminator => '////', :skip_processing => true) + result = reader.read_lines_until(terminator: '////', skip_processing: true) assert_equal lines.map {|l| l.chomp}[1..1], result end @@ -1530,8 +1530,8 @@ include::fixtures/no-such-file.adoc[] EOS using_memory_logger do |logger| - doc = empty_safe_document :base_dir => DIRNAME - reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true + doc = empty_safe_document base_dir: DIRNAME + reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true reader.skip_comment_lines assert reader.empty? assert logger.empty? @@ -1649,7 +1649,7 @@ There is a holy grail! endif::holygrail[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1665,7 +1665,7 @@ ifdef::holygrail[There is a holy grail!] There was much rejoicing. EOS - doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1679,7 +1679,7 @@ There was much rejoicing. ifdef::asciidoctor-version[include::fixtures/include-file.asciidoc[tag=snippetA]] EOS - doc = Asciidoctor::Document.new input, :safe => :safe, :base_dir => DIRNAME + doc = Asciidoctor::Document.new input, safe: :safe, base_dir: DIRNAME reader = doc.reader lines = [] while reader.has_more_lines? @@ -1695,7 +1695,7 @@ The script is shown! endif::showScript[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'showscript' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'showscript' => '' } result = doc.reader.read assert_equal 'The script is shown!', result end @@ -1707,7 +1707,7 @@ ifndef::hardships[There is a holy grail!] There was no rejoicing. EOS - doc = Asciidoctor::Document.new input, :attributes => { 'hardships' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'hardships' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1727,7 +1727,7 @@ grail endif::grail[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1745,7 +1745,7 @@ endif::grail[] endif::grail[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1765,7 +1765,7 @@ grail endif::grail[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1787,7 +1787,7 @@ endif::swallow[] gone EOS - doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1809,7 +1809,7 @@ endif::[] gone EOS - doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1825,7 +1825,7 @@ Our quest is complete! endif::holygrail,swallow[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'swallow' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'swallow' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1857,7 +1857,7 @@ Our quest is complete! endif::holygrail+swallow[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '', 'swallow' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '', 'swallow' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1873,7 +1873,7 @@ Our quest is complete! endif::holygrail+swallow[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' } + doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -1889,14 +1889,14 @@ endif::holygrail+swallow[] 'asciidoctor+' => '', '+asciidoctor' => '', 'asciidoctor,,asciidoctor-version' => 'content', - 'asciidoctor++asciidoctor-version' => '' + 'asciidoctor++asciidoctor-version' => '', }.each do |condition, expected| input = <<-EOS ifdef::#{condition}[] content endif::[] EOS - assert_equal expected, (document_from_string input, :parse => false).reader.read + assert_equal expected, (document_from_string input, parse: false).reader.read end end @@ -1923,7 +1923,7 @@ Our quest is complete! endif::holygrail,swallow[] EOS - result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }).reader.read + result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read assert_empty result end @@ -1934,7 +1934,7 @@ Our quest is complete! endif::holygrail,swallow[] EOS - result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '', 'holygrail' => '' }).reader.read + result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read assert_empty result end @@ -1967,7 +1967,7 @@ Our quest is complete! endif::holygrail+swallow[] EOS - result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '', 'holygrail' => '' }).reader.read + result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read assert_empty result end @@ -1978,7 +1978,7 @@ Our quest is complete! endif::holygrail+swallow[] EOS - result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }).reader.read + result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read assert_equal 'Our quest is complete!', result end @@ -2037,7 +2037,7 @@ Asciidoctor it is! endif::[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' } + doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -2053,7 +2053,7 @@ Asciidoctor it is! endif::[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' } + doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -2069,7 +2069,7 @@ Asciidoctor it is! endif::[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'tilt' } + doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'tilt' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -2133,7 +2133,7 @@ One ring to rule them all! endif::[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'rings' => '1' } + doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' } reader = doc.reader lines = [] while reader.has_more_lines? @@ -2149,7 +2149,7 @@ One ring to rule them all! endif::[] EOS - doc = Asciidoctor::Document.new input, :attributes => { 'rings' => '1' } + doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' } reader = doc.reader lines = [] while reader.has_more_lines? |
