Class: Fontisan::Pipeline::TransformationPipeline
- Inherits:
-
Object
- Object
- Fontisan::Pipeline::TransformationPipeline
- Defined in:
- lib/fontisan/pipeline/transformation_pipeline.rb
Overview
Orchestrates universal font transformation pipeline
This is the main entry point for font conversion operations. It coordinates:
-
Format detection (via FormatDetector)
-
Font loading (via FontLoader)
-
Variation resolution (via VariationResolver)
-
Format conversion (via FormatConverter)
-
Output writing (via OutputWriter)
-
Validation (optional, via Validation::Validator)
The pipeline follows a clear MECE architecture where each phase has a single responsibility and produces well-defined outputs.
Instance Attribute Summary collapse
-
#input_path ⇒ String
readonly
Input file path.
-
#options ⇒ Hash
readonly
Transformation options.
-
#output_path ⇒ String
readonly
Output file path.
Instance Method Summary collapse
-
#initialize(input_path, output_path, options = {}) ⇒ TransformationPipeline
constructor
Initialize transformation pipeline.
-
#transform ⇒ Hash
Execute transformation pipeline.
Constructor Details
#initialize(input_path, output_path, options = {}) ⇒ TransformationPipeline
Initialize transformation pipeline
58 59 60 61 62 63 64 65 |
# File 'lib/fontisan/pipeline/transformation_pipeline.rb', line 58 def initialize(input_path, output_path, = {}) @input_path = input_path @output_path = output_path @options = .merge() @variation_strategy = nil validate_paths! end |
Instance Attribute Details
#input_path ⇒ String (readonly)
Returns Input file path.
39 40 41 |
# File 'lib/fontisan/pipeline/transformation_pipeline.rb', line 39 def input_path @input_path end |
#options ⇒ Hash (readonly)
Returns Transformation options.
45 46 47 |
# File 'lib/fontisan/pipeline/transformation_pipeline.rb', line 45 def @options end |
#output_path ⇒ String (readonly)
Returns Output file path.
42 43 44 |
# File 'lib/fontisan/pipeline/transformation_pipeline.rb', line 42 def output_path @output_path end |
Instance Method Details
#transform ⇒ Hash
Execute transformation pipeline
This is the main entry point. It orchestrates:
-
Format detection
-
Font loading
-
Variation resolution
-
Format conversion
-
Output writing
-
Validation (optional)
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fontisan/pipeline/transformation_pipeline.rb', line 79 def transform log "Starting transformation: #{@input_path} → #{@output_path}" # Phase 1: Detect input format detection = detect_input_format log "Detected: #{detection[:format]} (#{detection[:variation_type]})" # Phase 2: Load font font = load_font(detection) log "Loaded: #{font.class.name}" # Phase 3: Resolve variation tables = resolve_variation(font, detection) log "Resolved variation using #{@variation_strategy} strategy" # Phase 4: Convert format tables = convert_format(tables, detection) log "Converted to #{target_format}" # Phase 5: Write output write_output(tables, detection) log "Written to #{@output_path}" # Phase 6: Validate (optional) validate_output if @options[:validate] && !same_format_conversion? && !export_only_format? log "Validation passed" if @options[:validate] && !export_only_format? { success: true, output_path: @output_path, details: build_details(detection), } rescue StandardError => e handle_error(e) end |