/usr/lib/ruby/vendor_ruby/berkshelf/api/cache_builder/worker.rb is in berkshelf-api 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | module Berkshelf::API
class CacheBuilder
module Worker
class Base
class << self
# @param [#to_s, nil] type
def worker_type(type = nil)
return @worker_type if @worker_type
@worker_type = type.to_s
Worker.register(@worker_type, self)
end
end
include Celluloid
include Berkshelf::API::Logging
include Berkshelf::API::Mixin::Services
attr_reader :options
attr_reader :priority
def initialize(options = {})
@priority = options[:priority]
end
# @return [String]
def to_s
friendly_name
end
# @abstract
#
# @param [RemoteCookbook] remote
#
# @return [Ridley::Chef::Cookbook::Metadata]
def metadata(remote)
raise RuntimeError, "must be implemented"
end
# @abstract
#
# @return [Array<RemoteCookbook>]
# The list of cookbooks this builder can find
def cookbooks
raise RuntimeError, "must be implemented"
end
private
# @param [String] data
# any string to append to the worker_type
# @return [String]
def friendly_name(data = nil)
string = self.class.worker_type.dup
string << ": #{data}" if data
string
end
end
class << self
# @param [#to_s] name
#
# @return [Worker::Base]
def [](name)
types[name.to_s]
end
# @param [#to_s] name
# @param [Worker::Base] klass
def register(name, klass)
name = name.to_s
if types.has_key?(name)
raise RuntimeError, "worker already registered with the name '#{name}'"
end
types[name] = klass
end
# @return [Hash]
def types
@types ||= Hash.new
end
end
end
end
end
Dir["#{File.dirname(__FILE__)}/worker/*.rb"].sort.each do |path|
require_relative "worker/#{File.basename(path, '.rb')}"
end
|