Method: MotherBrain::PluginManager#latest

Defined in:
lib/mb/plugin_manager.rb

#latest(name, options = {}) ⇒ MB::Plugin?

Return most current version of the plugin of the given name

Parameters:

  • name (String)

    name of the plugin

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

    a customizable set of options

Options Hash (options):

  • :remote (Boolean) — default: false

    include plugins on the remote Chef server which haven’t been cached or installed

Returns:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/mb/plugin_manager.rb', line 256

def latest(name, options = {})
  options = options.reverse_merge(remote: false)

  potentials = list(name: name, remote: false).map(&:version)
  potentials += remote_cookbook_versions(name) if options[:remote]
  potentials = potentials.collect { |version| Semverse::Version.new(version) }.uniq.sort.reverse

  potentials.find do |version|
    found = find(name, version.to_s, options.slice(:remote))
    return found if found
  end

  nil
end