Module: DumpCleaner::Cleanup::Inspection
- Included in:
- CleaningSteps::InspectContext, CleaningSteps::RandomizeFormattedNumber, DataSourceSteps::InspectContext, StepContext
- Defined in:
- lib/dump_cleaner/cleanup/inspection.rb
Instance Method Summary collapse
- #inspect_step_context(step_context, message: "Inspecting step context") ⇒ Object
- #subset(data, values: 10) ⇒ Object
- #truncate(value, to: 30, omission: "…") ⇒ Object
Instance Method Details
#inspect_step_context(step_context, message: "Inspecting step context") ⇒ Object
6 7 8 9 |
# File 'lib/dump_cleaner/cleanup/inspection.rb', line 6 def inspect_step_context(step_context, message: "Inspecting step context") Log.info { } Log.info { "\n#{step_context.pretty_inspect}" } end |
#subset(data, values: 10) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dump_cleaner/cleanup/inspection.rb', line 11 def subset(data, values: 10) case data when Array subset_data = data.take(values) subset_data << "+ #{data.size - values} more..." if data.size > values subset_data.each_with_index { |element, index| subset_data[index] = subset(element, values:) } when Hash subset_data = data.take(values).to_h subset_data["+ #{data.size - values} more..."] = nil if data.size > values subset_data.each_key { |key| subset_data[key] = subset(subset_data[key], values:) } else subset_data = data end subset_data end |
#truncate(value, to: 30, omission: "…") ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/dump_cleaner/cleanup/inspection.rb', line 28 def truncate(value, to: 30, omission: "…") return value.dup if value.length <= to length_with_room_for_omission = to - omission.length stop = length_with_room_for_omission +"#{value[0, stop]}#{omission}" end |