From 561b66275f186fcf8f3ed6e697e560f28354d38c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:05:23 -0400 Subject: v5 v6: ao_numbering, check that all auto given number based seg names are unique --- lib/sisu/v5/ao_numbering.rb | 10 +++++++++- lib/sisu/v6/ao_numbering.rb | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index d213ca4d..dc6ec4dd 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -67,6 +67,7 @@ module SiSU_AO_Numbering def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] end def number_of_segments? if @@segments_count==0 @@ -323,7 +324,7 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - if possible_seg_name =~/^[0-9]+$/m \ + chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering prefix + possible_seg_name else prefix + possible_seg_name.to_s end + @chosen_seg_names << chosen_seg_name + if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'") + exit + end end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index ef85bbd6..5b2137e7 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -67,6 +67,7 @@ module SiSU_AO_Numbering def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] end def number_of_segments? if @@segments_count==0 @@ -323,7 +324,7 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - if possible_seg_name =~/^[0-9]+$/m \ + chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering prefix + possible_seg_name else prefix + possible_seg_name.to_s end + @chosen_seg_names << chosen_seg_name + if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'") + exit + end end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules -- cgit v1.2.3