class Halite::Berkshelf::Source

Berkshelf global source to find all Halite cookbooks in the current gems environment.

@since 1.0.0 @api private

Public Class Methods

new(berksfile) click to toggle source
Calls superclass method
# File lib/halite/berkshelf/source.rb, line 30
def initialize(berksfile)
    # 6.1+ mode.
  super(berksfile, {halite: 'halite://'})
rescue ArgumentError
  # Legacy mode.
  super('halite://')
end

Public Instance Methods

build_universe() click to toggle source
# File lib/halite/berkshelf/source.rb, line 38
def build_universe
  # Scan all gems
  ::Gem::Specification.stubs.map do |spec|
    Gem.new(spec)
  end.select do |cook|
    # Make sure this is a cookbook, and that it isn't a pre-release.
    cook.is_halite_cookbook? && cook.version == cook.cookbook_version
  end.map do |cook|
    # Build a fake "remote" cookbook
    ::Berkshelf::APIClient::RemoteCookbook.new(
      cook.cookbook_name,
      cook.cookbook_version,
      {
        location_type: 'halite',
        location_path: cook.name,
        dependencies: cook.cookbook_dependencies.inject({}) {|memo, dep| memo[dep.name] = dep.requirement; memo },
      },
    )
  end
end
to_s() click to toggle source

Show “… from Halite gems” when installing.

# File lib/halite/berkshelf/source.rb, line 60
def to_s
  "Halite gems"
end
Also aliased as: uri
uri()
Alias for: to_s