How pcreux/csv-importer works
Main Components
a. Core Components:
• CSV Reader Component
• Column Mapping Engine
• Runner/Processor
• Reporting System
• Model Interface Layer
b. Supporting Components:
• Configuration System
• DSL Interface
• Validation Layer
Top Layer (Input/Interface Layer):
• Show the entry points (CSV File/String/Path Input)
• DSL Interface for configuration
Middle Layer (Processing Layer):
• CSV Reader
• Column Mapper
• Runner
• Validator
Bottom Layer (Integration Layer):
• Model Interface (ActiveRecord/ORM)
• Storage Layer
Component Relationships
• Input → CSV Reader → Column Mapper
• Column Mapper → Runner
• Runner → Model Interface
• All components → Reporting System
Specific Implementation Details to Highlight
a. CSV Processing Pipeline:
Input → CSVReader → Header Validation → Column Mapping → Row Processing → Model Updates
b. Configuration Flow:
DSL Definition → Column Definitions → Mapping Rules → Transformers
Key Features to Emphasize
• Column mapping with aliases
• Transformation functions
• Error handling strategies
• Validation rules
• Callback hooks (after_build, after_save)
Technical Details
Annotations showing:
• Supported input formats
• Encoding handling
• Quote character customization
• Identifier strategies
• Error handling modes (skip/abort)
Implementation Notes
• Column.rb and ColumnDefinition.rb for mapping
• CSVReader.rb for input processing
• Runner.rb for execution
• Report.rb and ReportMessage.rb for feedback
• Row.rb for row-level processing
Integration Points
Clear interfaces for:
• ORM integration requirements (transaction, find_by, save)
• Custom model support
• External system hooks
Input → Validation → Processing → Storage → Reporting