class Berkshelf::Dependency

def <=>(other)

def <=>(other)
  [name, version_constraint] <=> [other.name, other.version_constraint]
end

def add_group(*local_groups)

def add_group(*local_groups)
  local_groups = local_groups.first if local_groups.first.is_a?(Array)
  local_groups.each do |group|
    group = group.to_sym
    groups << group unless groups.include?(group)
  end
end

def cached_cookbook

Returns:
  • (CachedCookbook, nil) -
def cached_cookbook
  return @cached_cookbook if @cached_cookbook
  @cached_cookbook =
    if location
      cookbook = location.cached_cookbook
      # If we have a cached cookbook, tighten our constraints
      if cookbook
        self.locked_version     = cookbook.version
        self.version_constraint = cookbook.version
      end
      cookbook
    else
      if locked_version
        CookbookStore.instance.cookbook(name, locked_version)
      else
        CookbookStore.instance.satisfy(name, version_constraint)
      end
    end
  @cached_cookbook
end

def groups

Returns:
  • (Array) -
def groups
  @groups ||= []
end

def has_group?(group)

Returns:
  • (Boolean) -
def has_group?(group)
  groups.include?(group.to_sym)
end

def initialize(berksfile, name, options = {})

Options Hash: (**options)
  • :locked_version (String) --
  • :tag (String) --
  • :branch (String) --
  • :ref (String) --
  • :group (Symbol, Array) --
  • :metadata (String) --
  • :path (String) --
  • :git (String) --
  • :constraint (String, Semverse::Constraint) --

Parameters:
  • name (String) --
  • berksfile (Berkshelf::Berksfile) --
def initialize(berksfile, name, options = {})
  @options            = options
  @berksfile          = berksfile
  @name               = name
  @metadata           = options[:metadata]
  @location           = Location.init(self, options)
  if options[:locked_version]
    @locked_version = Semverse::Version.coerce(options[:locked_version])
  end
  # The coerce method automatically gives us a default constraint of
  # >= 0.0.0 if the constraint is not set.
  @version_constraint = Semverse::Constraint.coerce(options[:constraint])
  add_group(options[:group]) if options[:group]
  add_group(:default) if groups.empty?
end

def inspect

def inspect
  "#<Berkshelf::Dependency: " << [
    "#{name} (#{version_constraint})",
    "locked_version: #{locked_version.inspect}",
    "groups: #{groups}",
    "location: #{location || "default"}>",
  ].join(", ")
end

def installed?

Returns:
  • (Boolean) -
def installed?
  !cached_cookbook.nil?
end

def locked_version=(version)

Parameters:
  • version (#to_s) --
def locked_version=(version)
  @locked_version = Semverse::Version.coerce(version)
end

def metadata?

Returns:
  • (Boolean) -
def metadata?
  !!@metadata
end

def name(dependency)

Returns:
  • (String) -

Parameters:
  • dependency (Dependency, #to_s) --
def name(dependency)
  if dependency.is_a?(Dependency)
    dependency.name.to_s
  else
    dependency.to_s
  end
end

def to_lock

def to_lock
  out =
    if location || version_constraint.to_s == ">= 0.0.0"
      "  #{name}\n"
    else
      "  #{name} (#{version_constraint})\n"
    end
  out << location.to_lock if location
  out
end

def to_s

def to_s
  "#{name} (#{locked_version || version_constraint})"
end

def version_constraint=(constraint)

Parameters:
  • constraint (#to_s) --
def version_constraint=(constraint)
  @version_constraint = Semverse::Constraint.coerce(constraint)
end