module TingYun::Support::LibraryDetection

Public Instance Methods

defer(&block) click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 17
def defer(&block)
  item = Dependent.new
  item.instance_eval(&block)

  if item.name
    seen_names = @items.map { |i| i.name }.compact
    if seen_names.include?(item.name)
      TingYun::Agent.logger.warn("Refusing to re-register LibraryDetection block with name '#{item.name}'")
      return @items
    end
  end

  @items << item
end
dependency_by_name(name) click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 40
def dependency_by_name(name)
  @items.find {|i| i.name == name }
end
detect!() click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 32
def detect!
  @items.each do |item|
    if item.dependencies_satisfied?
      item.execute
    end
  end
end
installed?(name) click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 44
def installed?(name)
  item = dependency_by_name(name)
  item && item.executed
end
items() click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 49
def items
  @items
end
items=(new_items) click to toggle source
# File lib/ting_yun/support/library_detection.rb, line 53
def items=(new_items)
  @items = new_items
end