Examples

Overview

This section provides complete, runnable examples demonstrating common Cabriolet use cases. Each example includes full code, expected output, and explanations.

Available examples

Extracting from Windows Installer

Learn how to extract files from Windows installer packages (MSI, setup.exe) that use CAB compression internally.

Topics covered: * Identifying embedded CAB files * Extracting installer resources * Handling multi-volume installers * Batch extraction workflows

Creating Software Distribution Bundle

Build a complete software distribution package using CAB compression for optimal size and compatibility.

Topics covered: * Organizing files for distribution * Choosing compression algorithms * Creating multi-volume archives * Adding digital signatures

Recovering from Corrupted Archives

Use Cabriolet’s salvage mode to recover data from damaged CAB files.

Topics covered: * Detecting corruption * Using salvage mode * Partial file recovery * Verification strategies

Batch Processing Multiple Archives

Process large numbers of archive files efficiently with automation.

Topics covered: * Recursive directory scanning * Parallel processing * Error handling and logging * Progress reporting

Custom Compression Pipeline

Build advanced compression workflows with custom I/O handlers and streaming.

Topics covered: * Memory-based compression * Custom I/O handlers * Streaming compression * Format conversion pipelines

Using these examples

Prerequisites

All examples assume you have Cabriolet installed:

gem install cabriolet

Or in your Gemfile:

gem 'cabriolet', '~> 0.1'

Running Examples

Each example provides:

  1. Complete source code - Copy and run directly

  2. Sample data - Test files or how to obtain them

  3. Expected output - What you should see

  4. Variations - How to adapt for your needs

Code Conventions

  • Ruby version: 2.7 or later

  • Error handling: Explicit exception handling shown

  • Comments: Explain key concepts

  • Style: Follow Cabriolet conventions

Example categories

Basic Operations

  • Extracting files

  • Creating archives

  • Listing contents

  • Testing integrity

Advanced Techniques

  • Custom I/O handlers

  • Salvage mode recovery

  • Multi-part archives

  • Streaming operations

Integration Patterns

  • CI/CD pipelines

  • Automated workflows

  • Batch processing

  • Format conversion

Getting help

If you encounter issues with these examples:

Contributing Examples

Have a useful example to share? We’d love to include it!

  1. Write clear, documented code

  2. Include sample input/output

  3. Test on multiple Ruby versions

  4. Submit a pull request


Table of contents