<commit_before>require "hike"

module Sprockets
  class Environment
    class << self
      attr_accessor :engine_extensions
    end

    self.engine_extensions = %w( coffee erb less sass scss str )

    def initialize(root = ".")
      @trail = Hike::Trail.new(root)
      @trail.extensions.replace(self.class.engine_extensions)
    end

    def root
      @trail.root
    end

    def paths
      @trail.paths
    end

    def resolve(logical_path)
      if path = @trail.find(logical_path)
        Pathname.new(path)
      else
        raise FileNotFound, "couldn't find file '#{logical_path}'"
      end
    end

    def find_asset(logical_path)
      pathname = resolve(logical_path)

      if concatenatable?(pathname.format_extension)
        ConcatenatedAsset.new(self, pathname)
      else
        StaticAsset.new(self, pathname)
      end
    end

    alias_method :[], :find_asset

    def concatenatable?(format_extension)
      %w( .js .css ).include?(format_extension)
    end
  end
end<commit_msg>Clean up extension constants<commit_after>require "hike"

module Sprockets
  class Environment
    DEFAULT_ENGINE_EXTENSIONS = %w( .coffee .erb .less .sass .scss .str )
    CONCATENATABLE_EXTENSIONS = %w( .css .js )

    def initialize(root = ".")
      @trail = Hike::Trail.new(root)
      engine_extensions.replace(DEFAULT_ENGINE_EXTENSIONS)
    end

    def root
      @trail.root
    end

    def paths
      @trail.paths
    end

    def engine_extensions
      @trail.extensions
    end

    def resolve(logical_path)
      if path = @trail.find(logical_path)
        Pathname.new(path)
      else
        raise FileNotFound, "couldn't find file '#{logical_path}'"
      end
    end

    def find_asset(logical_path)
      pathname = resolve(logical_path)

      if concatenatable?(pathname.format_extension)
        ConcatenatedAsset.new(self, pathname)
      else
        StaticAsset.new(self, pathname)
      end
    end

    alias_method :[], :find_asset

    protected
      def concatenatable?(format_extension)
        CONCATENATABLE_EXTENSIONS.include?(format_extension)
      end
  end
end
{'fraction_non_alphanumeric': 0.08553875236294896, 'fraction_numerical': 0.0, 'mean_word_length': 2.569983136593592, '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': '3599754', 'n_tokens_mistral': 709, 'n_tokens_neox': 681, 'n_words': 147}