Class: Omnizip::Commands::ArchiveRepairCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/commands/archive_repair_command.rb

Overview

Archive repair command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ArchiveRepairCommand

Initialize command

Parameters:

  • options (Hash) (defaults to: {})

    Command options



12
13
14
# File 'lib/omnizip/commands/archive_repair_command.rb', line 12

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/omnizip/commands/archive_repair_command.rb', line 7

def options
  @options
end

Instance Method Details

#run(input_path, output_path) ⇒ Object

Run repair

Parameters:

  • input_path (String)

    Path to corrupted archive

  • output_path (String)

    Path for repaired archive



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omnizip/commands/archive_repair_command.rb', line 20

def run(input_path, output_path)
  raise "Archive not found: #{input_path}" unless File.exist?(input_path)

  # Detect format
  format = detect_format(input_path)

  case format
  when :rar
    repair_rar(input_path, output_path)
  else
    puts "Repair not supported for #{format} archives"
    exit 1
  end
end