@@ -25,20 +25,20 @@ def self.from_string_array(sections)
2525 end
2626 end
2727
28- def uniq ( )
28+ def uniq
2929 trim_contents = contents . map { |x | x . strip }
30- Inf . new ( name , trim_contents . uniq { |text | text . split ( '=' ) [ 0 ] . downcase + text . split ( '=' ) [ 1 ..-1 ] . join ( '' ) } )
30+ Inf . new ( name , trim_contents . uniq { |text | text . split ( '=' ) [ 0 ] . downcase + text . split ( '=' ) [ 1 ..-1 ] . join ( '' ) } )
3131 end
3232
33- def sort ( )
33+ def sort
3434 Inf . new ( name , contents . sort )
3535 end
3636
37- def size ( )
37+ def size
3838 @contents . size
3939 end
4040
41- def summary ( )
41+ def summary
4242 "section: #{ @name } size: #{ size } "
4343 end
4444end
@@ -55,16 +55,16 @@ def convert_to_utf8(name)
5555end
5656
5757def merge ( a , b )
58- a_no_comment = a . split ( "\r \n " ) . reject { |x | x . strip . gsub ( /^;.*/ , '' ) . empty? } . join ( "\r \n " ) . strip
59- b_no_comment = b . split ( "\r \n " ) . reject { |x | x . strip . gsub ( /^;.*/ , '' ) . empty? } . join ( "\r \n " ) . strip
58+ a_no_comment = a . split ( "\r \n " ) . reject { |x | x . strip . gsub ( /^;.*/ , '' ) . empty? } . join ( "\r \n " ) . strip
59+ b_no_comment = b . split ( "\r \n " ) . reject { |x | x . strip . gsub ( /^;.*/ , '' ) . empty? } . join ( "\r \n " ) . strip
6060
6161 a_normalize_equals = a_no_comment . gsub ( ' = ' , '=' ) . gsub ( " =\r \n " , "=\r \n " )
6262 b_normalize_equals = b_no_comment . gsub ( ' = ' , '=' ) . gsub ( " =\r \n " , "=\r \n " )
6363
6464 a_infs = Infs . from_string ( a_normalize_equals )
6565 b_infs = Infs . from_string ( b_normalize_equals )
6666
67- ( a_infs + b_infs ) . group_by { |x | x . name } . map { |section_name , infs | Inf . new ( section_name , infs . map { |x | x . contents } . flatten ) }
67+ ( a_infs + b_infs ) . group_by { |x | x . name } . map { |section_name , infs | Inf . new ( section_name , infs . map { |x | x . contents } . flatten ) }
6868end
6969
7070a_contents = convert_to_utf8 ( 'GptTmpl-ms-baseline.inf' )
@@ -92,17 +92,17 @@ def merge(a, b)
9292 elements = section . contents
9393 title = section . name
9494
95- grouped = elements . group_by { |x | x . split ( "=" ) [ 0 ] }
96- dups = grouped . keys . select { |k | grouped [ k ] . size > 1 }
95+ grouped = elements . group_by { |x | x . split ( "=" ) [ 0 ] }
96+ dups = grouped . keys . select { |k | grouped [ k ] . size > 1 }
9797
98- if ( dups . nil? )
98+ if dups . nil?
9999 puts "found 0 conflicts in section #{ title } "
100100 else
101101 puts "found #{ dups . size } conflicts in section #{ title } "
102- dups . each { |x | puts x }
102+ dups . each { |x | puts x }
103103 end
104104end
105105
106106new_file = 'GptTmpl-merged.inf'
107- File . write new_file , sorted . map { |section | section . name + "\n " + section . contents . join ( "\n " ) } . join ( "\n " )
107+ File . write new_file , sorted . map { |section | section . name + "\n " + section . contents . join ( "\n " ) } . join ( "\n " )
108108puts "merged files with uniques removed outputted to #{ new_file } "
0 commit comments