Class: HDIUtil::DMG

Inherits:
Object
  • Object
show all
Defined in:
lib/iesd/utility/hdiutil.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ DMG

Initialize a new DMG.

url - The String path to the DMG.



123
124
125
# File 'lib/iesd/utility/hdiutil.rb', line 123

def initialize url
  @url = File.absolute_path url
end

Instance Attribute Details

#urlObject

The String path to the DMG.



118
119
120
# File 'lib/iesd/utility/hdiutil.rb', line 118

def url
  @url
end

Instance Method Details

#editObject

Open a read-write shell in the DMG.



133
134
135
# File 'lib/iesd/utility/hdiutil.rb', line 133

def edit
  update
end

#show(&block) ⇒ Object

Perform read-only actions on the DMG.



128
129
130
# File 'lib/iesd/utility/hdiutil.rb', line 128

def show &block
  HDIUtil.read(@url, &block)
end

#update(&block) ⇒ Object

Perform read-write actions on the DMG.



138
139
140
141
142
143
144
145
# File 'lib/iesd/utility/hdiutil.rb', line 138

def update &block
  Dir.mktmpdir { |tmp|
    flags = `/usr/bin/env ls -lO #{@url.shellescape}`.split[4]
    HDIUtil.write(@url, (tmpfile = File.join(tmp, File.basename(@url))), &block)
    system("/usr/bin/env", "mv", tmpfile, @url)
    system("/usr/bin/env", "chflags", flags, @url) unless flags == "-"
  }
end

#valid?Boolean

Returns true if the DMG is a valid image, false otherwise.

Returns:

  • (Boolean)


148
149
150
# File 'lib/iesd/utility/hdiutil.rb', line 148

def valid?
  HDIUtil.validate @url
end