From 88ed8a0c1376fbe6d45059694ce31db597fde3e9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Apr 2020 11:10:59 -0400 Subject: ruby 2.7 fix --- lib/sisu/ao_doc_str.rb | 85 ++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 38 deletions(-) (limited to 'lib/sisu/ao_doc_str.rb') diff --git a/lib/sisu/ao_doc_str.rb b/lib/sisu/ao_doc_str.rb index 40f5a045..31fd62ec 100644 --- a/lib/sisu/ao_doc_str.rb +++ b/lib/sisu/ao_doc_str.rb @@ -296,15 +296,17 @@ module SiSU_AO_DocumentStructureExtract else nil end end - if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?(?:\(.+?\))?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\(.+?\)\{|\{table\()|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?(?:\(.+?\))?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \ - and @per.code==:off \ - and @per.poem==:off \ - and @per.group==:off \ - and @per.block==:off \ - and @per.alt==:off \ - and @per.box==:off \ - and @per.table==:off + if (t_o.is_a?(String) \ + && t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?(?:\(.+?\))?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\(.+?\)\{|\{table\()|^(?:table\{|\{table)[ ~]/ \ + && t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?(?:\(.+?\))?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \ + and @per.code==:off \ + and @per.poem==:off \ + and @per.group==:off \ + and @per.block==:off \ + and @per.alt==:off \ + and @per.box==:off \ + and @per.table==:off + ) t_o=case t_o when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m @@ -962,9 +964,9 @@ module SiSU_AO_DocumentStructureExtract end if @per.table==:curls or @per.table==:tics if (@per.table==:curls \ - and t_o =~/^\}table/) \ + and (t_o.is_a?(String) and t_o =~/^\}table/)) \ or (@per.table==:tics \ - and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + and (t_o.is_a?(String) and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)) @per.table=:off headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] @h={ @@ -998,9 +1000,10 @@ module SiSU_AO_DocumentStructureExtract if @per.code==:curls \ or @per.code==:tics if (@per.code==:curls \ - && t_o =~/^\}code/) \ + && (t_o.is_a?(String) && t_o =~/^\}code/)) \ or (@per.code==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m) + && (t_o.is_a?(String) && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m) \ + ) @per.code=:off if @tuned_code[-1] @tuned_code[-1]. @@ -1049,11 +1052,11 @@ module SiSU_AO_DocumentStructureExtract or (@per.alt==:curls \ || @per.alt==:tics) \ or (@per.quote==:open \ - && t_o =~/`:quote_close`/m) #not + && (t_o.is_a?(String) && t_o =~/`:quote_close`/m)) if (@per.poem==:curls \ - && t_o =~/^\}poem$/m) \ + && (t_o.is_a?(String) && t_o.to_s =~/^\}poem$/m)) \ or (@per.poem==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + && (t_o.is_a?(String) && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)) @per.poem=:off h={ is_for: :poem, @@ -1064,9 +1067,9 @@ module SiSU_AO_DocumentStructureExtract } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@per.box==:curls \ - && t_o =~/^\}box/) \ + && (t_o.is_a?(String) && t_o =~/^\}box/)) \ or (@per.box==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + && (t_o.is_a?(String) && t_o.to_s =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)) @per.box=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ @@ -1087,9 +1090,9 @@ module SiSU_AO_DocumentStructureExtract } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@per.group==:curls \ - && t_o =~/^\}group/) \ + && ( t_o.is_a?(String) && t_o.to_s =~/^\}group/)) \ or (@per.group==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + && (t_o.is_a?(String) && t_o.to_s =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)) @per.group=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ @@ -1109,9 +1112,11 @@ module SiSU_AO_DocumentStructureExtract } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@per.block==:curls \ - && t_o =~/^\}block/) \ + && t_o.to_s =~/^\}block/) \ or (@per.block==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + && (t_o.is_a?(String) \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) \ + ) @per.block=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ @@ -1131,9 +1136,11 @@ module SiSU_AO_DocumentStructureExtract } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@per.alt==:curls \ - && t_o =~/^\}alt/) \ + && (t_o.is_a?(String) && t_o =~/^\}alt/)) \ or (@per.alt==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + && t_o.is_a?(String) \ + && (t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + ) @per.alt=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ @@ -1153,7 +1160,7 @@ module SiSU_AO_DocumentStructureExtract } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif @per.quote==:open \ - and t_o =~/`:quote_close`/m + and (t_o.is_a?(String) && t_o =~/`:quote_close`/m) @per.quote=:off h={ is_for: :quote, @@ -1184,10 +1191,12 @@ module SiSU_AO_DocumentStructureExtract || @per.block==:tics) \ or (@per.alt==:curls \ || @per.alt==:tics) \ - and t_o =~/\S/ \ - and t_o !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic - sub_array=t_o.dup + and (t_o.is_a?(String) \ + and t_o.to_s =~/\S/ \ + and t_o.to_s !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \ + and t_o.to_s !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ + ) + sub_array=t_o.to_s.dup @line_mode=sub_array.scan(/.+/) type=if @per.poem==:curls or @per.poem==:tics t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join @@ -1230,7 +1239,7 @@ module SiSU_AO_DocumentStructureExtract gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") end - @tuned_block << t_o if t_o =~/\S+/ + @tuned_block << t_o if t_o.to_s =~/\S+/ else tuned_file << t_o end else tuned_file << t_o @@ -1700,7 +1709,7 @@ SKIPPED processing file: ocnh+=1 end if ln==0 \ - or ln=~@md.lv0 + or ln.to_s =~@md.lv0 @lev_occurences[:a] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1716,7 +1725,7 @@ SKIPPED processing file: collapsed_level=@collapsed_lv0 node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' elsif ln==1 \ - or ln=~@md.lv1 + or ln.to_s =~@md.lv1 @lev_occurences[:b] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1739,7 +1748,7 @@ SKIPPED processing file: collapsed_level=@collapsed_lv1 node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX elsif ln==2 \ - or ln=~@md.lv2 + or ln.to_s =~@md.lv2 @lev_occurences[:c] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1762,7 +1771,7 @@ SKIPPED processing file: collapsed_level=@collapsed_lv2 node,ocn_sp=node2,"h#{ocnh}" elsif ln==3 \ - or ln=~@md.lv3 + or ln.to_s =~@md.lv3 @lev_occurences[:d] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1793,7 +1802,7 @@ or this level should be level :B~ rather than #{dob.lv}} collapsed_level=@collapsed_lv3 node,ocn_sp=node3,"h#{ocnh}" elsif ln==4 \ - or ln=~@md.lv4 + or ln.to_s =~@md.lv4 @lev_occurences[:l1] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1827,7 +1836,7 @@ or this level should be level :B~ rather than #{dob.lv}} collapsed_level=@collapsed_lv4 node,ocn_sp=node4,"h#{ocnh}" elsif ln==5 \ - or ln=~@md.lv5 + or ln.to_s =~@md.lv5 @lev_occurences[:l2] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1864,7 +1873,7 @@ or this level should be level :B~ rather than #{dob.lv}} collapsed_level=@collapsed_lv5 node,ocn_sp=node5,"h#{ocnh}" elsif ln==6 \ - or ln=~@md.lv6 + or ln.to_s =~@md.lv6 @lev_occurences[:l3] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true @@ -1909,7 +1918,7 @@ or this level should be #5 (2~) rather ##{dob.ln} (#{dob.lv}~)" collapsed_level=@collapsed_lv6 node,ocn_sp=node6,"h#{ocnh}" elsif ln==7 \ - or ln=~@md.lv7 + or ln.to_s =~@md.lv7 @lev_occurences[:l4] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true -- cgit v1.2.3