<commit_before>module PortReservation
  extend Chef::DSL::DataQuery

  class << self
    def for(type)
      reservations[type]
    end

    def reservations
      @reservations ||= data_bag_item('ports', 'reservations')['mapping']
    end
  end
end<commit_msg>Raise if no reservation is configured in data bag<commit_after>module PortReservation
  extend Chef::DSL::DataQuery

  class MissingReservation < StandardError; end

  class << self
    def for(type)
      reservations[type].tap do |reservation|
        raise MissingReservation.new("No port reservation found for #{type}") if reservation.nil?
      end
    end

    def reservations
      @reservations ||= data_bag_item('ports', 'reservations')['mapping']
    end
  end
end
{'fraction_non_alphanumeric': 0.09646739130434782, 'fraction_numerical': 0.0, 'mean_word_length': 3.7243589743589745, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640494', 'n_tokens_mistral': 227, 'n_tokens_neox': 214, 'n_words': 59}