Module: Ronin::Platform

Public Visibility

Public Class Method Summary

add(options = {}, &block) {|overlay| ... }

Adds a new overlay to the overlay cache.

Returns: Overlay

extension(name, &block) {|ext| ... }

Loads an extension into the extension cache, if it has yet to be.

Returns: Extension

extension_names

Returns: Array

extensions

The extension cache.

Returns: ExtensionCache

has_extension?(name)

Searches for the extension with the specified name, in all.

Returns: Boolean

install(options = {}, &block) {|overlay| ... }

Installs an overlay into the OverlayCache::CACHE_DIR and adds it.

Returns: Overlay

load_overlays(path = OverlayCache::CACHE_FILE)

Load the overlay cache.

Returns: OverlayCache

overlays

Returns: OverlayCache

reload!

Reloads the overlay cache and the extension cache.

Returns: Boolean

remove(name, &block) {|overlay| ... }

Removes an overlay from the overlay cache, but leaves the contents.

uninstall(name, &block)

Uninstalls an overlay from the overlay cache, and deletes the.

update(&block)

Updates all previously installed overlays within the overlay cache.

Public Class Method Details

add

public Overlay add(options = {}, &block) {|overlay| ... }

Adds a new overlay to the overlay cache.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:path N/A [String]

A pre-existing path to the overlay.

:media N/A [Symbol]

The media type of the overlay, may be either :git, :hg, :svn or :rsync.

uri N/A [String, URI::HTTP, URI::HTTPS]

The URI of the overlay.

Yields:

[overlay]

If a block is given, it will be passed the overlay after it has been added to the cache.

Yield Parameters:

[Overlay] overlay

The newly added overlay.

Returns:

[Overlay]

The newly added overlay.

Raises:

[ArgumentError]

The :path option was not specified.

[OverlayNotFound]

The :path option did not represent a valid directory.

[View source]


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ronin/platform/platform.rb', line 92

def Platform.add(options={},&block)
  path = options[:path]

  unless path
    raise(ArgumentError,":path must be passed to Platform.add",caller)
  end

  path = path.to_s

  unless File.directory?(path)
    raise(OverlayNotFound,"overlay #{path.dump} cannot be found",caller)
  end

  media = options[:media]
  uri = options[:uri]

  overlay = Overlay.new(path,media,uri)

  Platform.overlays.add(overlay) do |overlay|
    ObjectCache.cache(overlay.objects_dir)
  end

  block.call(overlay) if block
  return overlay
end

extension

public Extension extension(name, &block) {|ext| ... }

Loads an extension into the extension cache, if it has yet to be loaded.

Meta Tags

Parameters:

[String] name

The name of the desired extension.

Yields:

[ext]

If a block is given, it will be passed the extension with the matching name.

Yield Parameters:

[Extension] ext

The desired extension.

Returns:

[Extension]

The desired extension.

Raises:

[ExtensionNotFound]

The extension with the specified name could not be found in any of the overlays or in the extension cache.

[View source]


287
288
289
290
291
292
# File 'lib/ronin/platform/platform.rb', line 287

def Platform.extension(name,&block)
  ext = Platform.extensions[name]

  block.call(ext) if block
  return ext
end

extension_names

public Array extension_names

Meta Tags

Returns:

[Array]

The names of all extensions within the overlays in the overlay cache.

[View source]


233
234
235
# File 'lib/ronin/platform/platform.rb', line 233

def Platform.extension_names
  Platform.overlays.extensions
end

extensions

public ExtensionCache extensions

The extension cache.

Meta Tags

Example:

  Platform.extensions['shellcode']
  # => #<Ronin::Platform::Extension: ...>

Returns:

[ExtensionCache]

The extension cache of all currently loaded extensions.

[View source]


262
263
264
# File 'lib/ronin/platform/platform.rb', line 262

def Platform.extensions
  @@ronin_extension_cache ||= ExtensionCache.new
end

has_extension?

public Boolean has_extension?(name)

Searches for the extension with the specified name, in all overlays within the overlay cache.

Meta Tags

Parameters:

[String] name

The name of the extension to search for.

Returns:

[Boolean]

Specifies whether the overlay cache contains the extension with the matching name.

[View source]


248
249
250
# File 'lib/ronin/platform/platform.rb', line 248

def Platform.has_extension?(name)
  Platform.overlays.has_extension?(name)
end

install

public Overlay install(options = {}, &block) {|overlay| ... }

Installs an overlay into the OverlayCache::CACHE_DIR and adds it to the overlay cache.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:uri N/A [String, URI::HTTP, URI::HTTPS]

The URI to the overlay.

:media N/A [Symbol]

The media type of the overlay, may be either :git, :hg, :svn or :rsync.

Yields:

[overlay]

If a block is given, it will be passed the overlay, after it has been installed.

Yield Parameters:

[Overlay] overlay

The newly installed overlay.

Returns:

[Overlay]

The newly installed overlay.

Raises:

[ArgumentError]

The :uri option must be specified.

[View source]


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/ronin/platform/platform.rb', line 145

def Platform.install(options={},&block)
  unless options[:uri]
    raise(ArgumentError,":uri must be passed to Platform.install",caller)
  end

  uri = options[:uri].to_s
  host = (URI(uri).host || 'localhost')
  host_dir = File.join(OverlayCache::CACHE_DIR,host)
  options = options.merge(:into => host_dir)

  Repertoire.checkout(options) do |repo|
    return Platform.add(
      :path => repo.path,
      :media => repo.media_name,
      :uri => uri,
      &block
    )
  end
end

load_overlays

public OverlayCache load_overlays(path = OverlayCache::CACHE_FILE)

Load the overlay cache.

Meta Tags

Examples

  Overlay.load_overlays
  # => #<Ronin::Platform::OverlayCache: ...>
  Overlay.load_overlays('/custom/overlays/cache.yaml')
  # => #<Ronin::Platform::OverlayCache: ...>

Parameters:

[String] path

The optional path to the overlay cache file.

Returns:

[OverlayCache]

The newly loaded overlay cache.

[View source]


47
48
49
# File 'lib/ronin/platform/platform.rb', line 47

def Platform.load_overlays(path=OverlayCache::CACHE_FILE)
  @@ronin_overlay_cache = OverlayCache.new(path)
end

overlays

public OverlayCache overlays

Meta Tags

Returns:

[OverlayCache]

The current overlay cache. If no overlay cache is present, the default overlay will be loaded.

[View source]


56
57
58
# File 'lib/ronin/platform/platform.rb', line 56

def Platform.overlays
  @@ronin_overlay_cache ||= OverlayCache.new
end

reload!

public Boolean reload!

Reloads the overlay cache and the extension cache.

Meta Tags

Returns:

[Boolean]

Specifies whether the reload was successful or not.

[View source]


300
301
302
# File 'lib/ronin/platform/platform.rb', line 300

def Platform.reload!
  Platform.overlays.reload! && Platform.extensions.reload!
end

remove

public remove(name, &block) {|overlay| ... }

Removes an overlay from the overlay cache, but leaves the contents of the overlay intact.

Meta Tags

Parameters:

[String] name

The name of the overlay to remove.

Yields:

[overlay]

If a block is given, it will be passed the overlay after it has been removed.

Yield Parameters:

[Overlay] overlay

The removed overlay.

Raises:

[OverlayNotFound]

The overlay with the specified name could not be found in the overlay cache.

[View source]


199
200
201
202
# File 'lib/ronin/platform/platform.rb', line 199

def Platform.remove(name,&block)
  Platform.overlays.remove(name,&block)
  return nil
end

uninstall

public uninstall(name, &block)

Uninstalls an overlay from the overlay cache, and deletes the contents of the overlay.

Meta Tags

Parameters:

[String] name

The name of the overlay to uninstall.

Yields:

[Object]
If a block is given, it will be called after the overlay has been uninstalled.

Raises:

[OverlayNotFound]

The overlay with the specified name could not be found in the overlay cache.

[View source]


219
220
221
222
223
224
225
226
# File 'lib/ronin/platform/platform.rb', line 219

def Platform.uninstall(name,&block)
  Platform.overlays.uninstall(name) do |overlay|
    ObjectCache.clean(overlay.objects_dir)
  end

  block.call() if block
  return nil
end

update

public update(&block)

Updates all previously installed overlays within the overlay cache.

Meta Tags

Yields:

[Object]
If a block is given, it will be called after all overlays have been updated within the cache.
[View source]


172
173
174
175
176
177
178
179
# File 'lib/ronin/platform/platform.rb', line 172

def Platform.update(&block)
  Platform.overlays.update do |overlay|
    ObjectCache.mirror(overlay.objects_dir)
  end

  block.call if block
  return nil
end
Generated on Friday, September 25 2009 at 02:57:43 PM by YARD 0.2.3.5 (ruby-1.8.6).