<commit_before># Dispatches EDCAT JSON requests in parallel
#
# The requests for each node are sent assuming the nodes are the base path
# for EDCAT instances.
class Dispatchers::EdcatDispatcher < Dispatcher
  include Dispatchers::ParallelDispatcherMixin

  def url_for_kitten( node )
    # strip off edcat/ for the request
    "#{node.url}#{plugin.request.path[6..-1]}"
  end

  def url_for_friend( node )
    "#{node.url}#{plugin.request.path}"
  end

  def get_json( url )
    begin
      HTTParty.get url , query: plugin.request.query_parameters
    rescue
      []
    end
  end

  def dispatch_friend( friend )
    get_json url_for_friend( friend )
  end

  def dispatch_kitten( kitten )
    get_json url_for_kitten( kitten )
  end

end<commit_msg>Inlining url_for_kitten and url_for_friend for better readability and adding comments for the contained functionality.<commit_after># Dispatches EDCAT JSON requests in parallel
#
# The requests for each node are sent assuming the nodes are the base path
# for EDCAT instances.
class Dispatchers::EdcatDispatcher < Dispatcher
  include Dispatchers::ParallelDispatcherMixin

  # Send the search query to the supplied URL of the resource.
  #
  # Passes on all parameters from the currently active plugin
  # and returns the resulting HTTParty response.  If anything
  # fails in this process, an empty array is returned.
  def get_json( url )
    begin
      HTTParty.get url , query: plugin.request.query_parameters
    rescue
      []
    end
  end

  # Dispatches to a friend by forwarding the request without
  # changing much of anything.
  def dispatch_friend( friend )
    path = plugin.request.path
    get_json "#{friend.url}#{path}"
  end

  # Dispatches to a kitten by removing the extra edcat/ which
  # is available both in the request path as in the kitten's
  # url.
  def dispatch_kitten( kitten )
    path = plugin.request.path[6..-1] # strip off edcat/
    get_json "#{kitten.url}#{path}"
  end

end
{'fraction_non_alphanumeric': 0.07059421025901473, 'fraction_numerical': 0.002031488065007618, 'mean_word_length': 3.5080091533180777, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3219065', 'n_tokens_mistral': 604, 'n_tokens_neox': 592, 'n_words': 215}