File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ class Column
66
77 attribute :name , String
88 attribute :definition , ColumnDefinition
9+ attribute :rank , Integer , default : 0
910 end
1011end
Original file line number Diff line number Diff line change @@ -8,13 +8,17 @@ class Header
88 attribute :column_names , Array [ String ]
99
1010 def columns
11+ max_column = column_names . size
12+
1113 column_names . map do |column_name |
1214 # ensure column name escapes invisible characters
1315 column_name = column_name . gsub ( /\P {Print}|\p {Cf}/ , '' )
16+ rank = column_definitions . index { |definition | definition . match? ( column_name ) }
1417
1518 Column . new (
1619 name : column_name ,
17- definition : find_column_definition ( column_name )
20+ definition : find_column_definition ( column_name ) ,
21+ rank : rank || max_column
1822 )
1923 end
2024 end
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def csv_attributes
3333
3434 # Set attributes
3535 def set_attributes ( model )
36- header . columns . each do |column |
36+ header . columns . sort_by ( & :rank ) . each do |column |
3737 value = csv_attributes [ column . name ]
3838 begin
3939 value = value . dup if value
You can’t perform that action at this time.
0 commit comments