<commit_before>define :multipackage do # ~FC015
  multipackage_definition_impl(params)
end

define :multipackage_install do # ~FC015
  Chef::Log.deprecation(
    "The `multipackage_install` definition is deprecated, just use `multipackage` from now on"
  )
  params[:action] = :install
  multipackage_definition_impl(params)
end

define :multipackage_remove do # ~FC015
  Chef::Log.deprecation(
    "The `multipackage_remove` definition is deprecated, just use `multipackage` from now on"
  )
  params[:action] = :remove
  multipackage_definition_impl(params)
end

module MultipackageDefinitionImpl
  def multipackage_definition_impl(params)
    # @todo make sure package_names and versions have the same # of items
    # (unless verison is omitted)
    package_names = []
    if params[:package_name] || params[:name]
      package_names = [params[:package_name] || params[:name]].flatten
    end
    versions = [params[:version]].flatten if params[:version]
    options = params[:options]
    timeout = params[:per_package_timeout]
    action = params[:action] || :install

    t = begin
          run_context.resource_collection.find_local(:multipackage_internal => "collected packages #{action}")
        rescue Chef::Exceptions::ResourceNotFound
          multipackage_internal "collected packages #{action}" do
            package_name Array.new
            version Array.new
            action action
          end
        end

    package_names.each_with_index do |package_name, i|
      if t.package_name.include?(package_name)
        # supress CHEF-3694 errors and be more useful about warning if there's only a reason
        if options
          Chef::Log.warn "ignoring options #{options} set on duplicated package #{package_name}"
        end
        if timeout<commit_msg>add a comment since this is non-obvious<commit_after>define :multipackage do # ~FC015
  multipackage_definition_impl(params)
end

define :multipackage_install do # ~FC015
  Chef::Log.deprecation(
    "The `multipackage_install` definition is deprecated, just use `multipackage` from now on"
  )
  params[:action] = :install
  multipackage_definition_impl(params)
end

define :multipackage_remove do # ~FC015
  Chef::Log.deprecation(
    "The `multipackage_remove` definition is deprecated, just use `multipackage` from now on"
  )
  params[:action] = :remove
  multipackage_definition_impl(params)
end

module MultipackageDefinitionImpl
  def multipackage_definition_impl(params)
    # @todo make sure package_names and versions have the same # of items
    # (unless verison is omitted)
    package_names = []
    if params[:package_name] || params[:name]
      package_names = [params[:package_name] || params[:name]].flatten
    end
    versions = [params[:version]].flatten if params[:version]
    options = params[:options]
    timeout = params[:per_package_timeout]
    action = params[:action] || :install

    t = begin
          # non-delayed eager accumulators like this cannot use recursive search
          run_context.resource_collection.find_local(:multipackage_internal => "collected packages #{action}")
        rescue Chef::Exceptions::ResourceNotFound
          multipackage_internal "collected packages #{action}" do
            package_name Array.new
            version Array.new
            action action
          end
        end

    package_names.each_with_index do |package_name, i|
      if t.package_name.include?(package_name)
        # supress CHEF-3694 errors and be more useful about warning if there's only a reason
        if options
          Chef::Log.warn "ignoring options #{options} set on duplicated package #{package_name}"
        end
        if timeout
{'fraction_non_alphanumeric': 0.08498506652185718, 'fraction_numerical': 0.0070594623947868584, 'mean_word_length': 3.587795765877958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3269378', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1033, 'n_words': 293}