Class: MooTool::Commands::IMG4

Inherits:
Thor
  • Object
show all
Defined in:
lib/mootool/commands/img4.rb

Overview

IMG4 parsing and related commands

Instance Method Summary collapse

Instance Method Details

#indexObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/mootool/commands/img4.rb', line 21

def index
  indexer = Models::FileIndex.new
  indexer.perform

  indexer.generate_hashes if options[:generate_hashes]

  File.write options[:save_file], JSON.pretty_generate(indexer.index) if options[:save_file]

  ap indexer.index
end

#manifestObject



58
59
60
# File 'lib/mootool/commands/img4.rb', line 58

def manifest
  ap Models::IOReg.create(options[:path]).manifests
end


10
11
12
13
14
# File 'lib/mootool/commands/img4.rb', line 10

def print(filename)
  Models::Digest.load_manifests(options[:manifest]) if options[:manifest]
  file = Models::IMG4::File.load(filename)
  file.print(options[:friendly])
end

#typesObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mootool/commands/img4.rb', line 33

def types
  indexer = Models::FileIndex.new
  indexer.perform

  results = {}

  indexer.index.select(&:img4?).flat_map do |file|
    loaded = Models::IMG4::File.load(file)
    loaded.types.compact.map do |type|
      results[type] ||= []
      results[type] << file.fullname
    end
  end

  results = results.to_h do |key, value|
    info = Models::IMG4.mappings[key] || {}
    info[:examples] = value
    [key, info]
  end

  ap({ unique_payload_types: results })
end