Class: MooTool::Models::IOReg

Inherits:
Object
  • Object
show all
Defined in:
lib/mootool/models/io_reg.rb

Defined Under Namespace

Classes: Node

Constant Summary collapse

MANIFEST_ROOTS =
%i[asmb manifest-properties secure-boot-hashes].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_tree_data) ⇒ IOReg

Returns a new instance of IOReg.



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/mootool/models/io_reg.rb', line 72

def initialize(device_tree_data)
  data = CFPropertyList.native_types CFPropertyList::List.new(data: device_tree_data).value
  data = data.deep_symbolize_keys

  @data = transform_node(data)
  @data.delete :IOConsoleUsers
  @data.delete :IOKitDiagnostics

  @entries = @data[:'device-tree'][:chosen]
  @manifests = @entries[:'manifest-properties'].to_h.merge(@entries[:'secure-boot-hashes'].to_h).merge(@entries[:asmb].to_h).transform_values do |v|
    v.is_a?(String) ? v.unpack1('H*').upcase : v
  end
end

Instance Attribute Details

#manifestsObject (readonly)

Returns the value of attribute manifests.



68
69
70
# File 'lib/mootool/models/io_reg.rb', line 68

def manifests
  @manifests
end

Class Method Details

.create(path = nil) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/mootool/models/io_reg.rb', line 60

def self.create(path = nil)
  if path
    IOReg.new File.read(path)
  else
    IOReg.new `ioreg -a -p IODeviceTree -l`
  end
end

Instance Method Details

#properties_with_hash(hash) ⇒ Object



86
87
88
# File 'lib/mootool/models/io_reg.rb', line 86

def properties_with_hash(hash)
  @manifests.select { |_key, value| value == hash }.map { |k, _v| k }
end

#transform_node(node) ⇒ Object



56
57
58
# File 'lib/mootool/models/io_reg.rb', line 56

def transform_node(node)
  Node.new node
end