<commit_before>require 'set'
module Launchy
  #
  # Application is the base class of all the application types that launchy may
  # invoke. It essentially defines the public api of the launchy system.
  #
  # Every class that inherits from Application must define:
  #
  # 1. A constructor taking no parameters
  # 2. An instance method 'open' taking a string or URI as the first parameter and a
  #    hash as the second
  # 3. A class method 'schemes' that returns an array of Strings containing the
  #    schemes that the Application will handle
  class Application
    extend DescendantTracker

    class << self
      #
      # The list of all the schems all the applications now
      #
      def scheme_list
        children.collect { |a| a.schemes }.flatten.sort
      end

      #
      # if this application handles the given scheme
      #
      def handles?( scheme )
        schemes.include?( scheme )
      end

      #
      # Find the application that handles the given scheme.  May take either a
      # String or something that responds_to?( :scheme )
      #
      def for_scheme( scheme )
        if scheme.respond_to?( :scheme ) then
          scheme = scheme.scheme
        end

        klass = children.find { |klass| klass.handles?( scheme ) }

        return klass if klass
        raise SchemeNotFoundError, "No application found to handle scheme '#{scheme}'. Known schemes: #{scheme_list.join(", ")}"
      end
    end

  end
end<commit_msg>Add in some debugging for finding the right handler class<commit_after>require 'set'
module Launchy
  #
  # Application is the base class of all the application types that launchy may
  # invoke. It essentially defines the public api of the launchy system.
  #
  # Every class that inherits from Application must define:
  #
  # 1. A constructor taking no parameters
  # 2. An instance method 'open' taking a string or URI as the first parameter and a
  #    hash as the second
  # 3. A class method 'schemes' that returns an array of Strings containing the
  #    schemes that the Application will handle
  class Application
    extend DescendantTracker

    class << self
      #
      # The list of all the schems all the applications now
      #
      def scheme_list
        children.collect { |a| a.schemes }.flatten.sort
      end

      #
      # if this application handles the given scheme
      #
      def handles?( scheme )
        schemes.include?( scheme )
      end

      #
      # Find the application that handles the given scheme.  May take either a
      # String or something that responds_to?( :scheme )
      #
      def for_scheme( scheme )
        if scheme.respond_to?( :scheme ) then
          scheme = scheme.scheme
        end

        klass = children.find do |klass|
          Launchy.log( "Seeing if #{klass.name} handles scheme #{scheme}"
          klass.handles?( scheme )
        end

        if klass then
          Launchy.log( "#{klass.name} handles #{scheme}" )
          return klass
        end

        raise SchemeNotFoundError, "No application found to handle scheme '#{scheme}'. Known schemes: #{scheme_list.join(", ")}"
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.06731984829329962, 'fraction_numerical': 0.0018963337547408343, 'mean_word_length': 2.32807570977918, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5688064', 'n_tokens_mistral': 843, 'n_tokens_neox': 842, 'n_words': 363}