@@ -111,15 +111,21 @@ module Delete
111111 # Field `c` is retained because `usenull: true` is not used. If that argument were given, only Field `a` would be returned.
112112 #
113113 class EmptyFields
114- # @param usenull [Boolean] whether to treat `Kiba::Extend.nullvalue` as empty/blank value
115- # @param consider_blank [Hash{Symbol=>Array<String>}] specifies field-specific value(s) that should be treated
116- # as blank/empty. **If multiple values should be considered blank for one field, join them using
117- # `Kiba::Extend.delimiter`**
118- def initialize ( usenull : false , consider_blank : nil )
114+ # @param usenull [Boolean] whether to treat `Kiba::Extend.nullvalue`
115+ # as empty/blank value
116+ # @param consider_blank [Hash{Symbol=>Array<String>}] specifies
117+ # field-specific value(s) that should be treated as blank/empty.
118+ # **If multiple values should be considered blank for one field,
119+ # join them using `Kiba::Extend.delimiter`**
120+ # @param report [Boolean] whether to print the names of empty fields
121+ # to STDOUT when job runs; Useful if you need to indicate
122+ # non-migrating-because-blank fields
123+ def initialize ( usenull : false , consider_blank : nil , report : false )
119124 @usenull = usenull
120125 @consider_blank = consider_blank &.transform_values do |val |
121126 val . split ( Kiba ::Extend . delim )
122127 end
128+ @report = report
123129 @pop_fields = { }
124130 @rows = [ ]
125131 end
@@ -134,6 +140,8 @@ def close
134140 return if rows . empty?
135141
136142 to_delete = rows . first . keys - pop_fields . keys
143+ to_delete . each { |f | puts "DELETED EMPTY FIELD: #{ f } " } if report
144+
137145 rows . each do |row |
138146 to_delete . each { |field | row . delete ( field ) }
139147 yield row
@@ -142,7 +150,7 @@ def close
142150
143151 private
144152
145- attr_reader :pop_fields , :rows , :usenull , :consider_blank
153+ attr_reader :usenull , :consider_blank , :report , :pop_fields , :rows
146154
147155 def populate_tracker ( row )
148156 prepare ( row ) . each do |field , val |
0 commit comments