Class: Berkshelf::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/berkshelf/location.rb

Class Method Summary collapse

Class Method Details

.init(dependency, options = {}) ⇒ ~BaseLocation?

Create a new instance of a Location class given dependency and options. The type of class is determined by the values in the given options Hash.

If you do not provide an option with a matching location id, nil is returned.

Examples:

Create a git location

Location.init(dependency, git: 'git://github.com/berkshelf/berkshelf.git')

Create a GitHub location

Location.init(dependency, github: 'berkshelf/berkshelf')

Parameters:

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

Returns:


21
22
23
24
25
26
27
# File 'lib/berkshelf/location.rb', line 21

def init(dependency, options = {})
  if klass = klass_from_options(options)
    klass.new(dependency, options)
  else
    nil
  end
end