<commit_before># Frozen-string-literal: true
# Copyright: 2012 - 2017 - MIT License
# Encoding: utf-8

require_relative "map/css"
require_relative "map/javascript"
require_relative "map/writer"
require "pathutil"

module Jekyll
  module Assets
    module Map
      NAME = "%s.map"
      DIR_NAME = "source-maps"
      DIR = Pathutil.new(DIR_NAME)
      EXT = ".map"

      # --
      # @return [String] the map name.
      # Take the path, and attach the map extension.
      # @note this just saves logic.
      # --
      def self.map_path(env:, asset:)
        [
          path({
            asset: asset,
            env: env,
          }),
          EXT,
        ].join
      end

      # --
      # @note this is used for anything in source-maps.
      # Strip the filename and return a relative sourcemap path.
      # @return [Pathutil] the path.
      # --
      def self.path(env:, asset:)
        DIR.join(env.strip_paths(asset.is_a?(Sprockets::Asset) ?
          asset.filename : asset))
      end

      # --
      def self.register_on(instance)
        Writer.register_on(instance)
        JavaScript.register_on(instance)
        CSS.register_on(instance)

        instance.css_compressor, instance.js_compressor =
          :source_map, :source_map
      end
    end
  end
end<commit_msg>Respect SourceMaps config, and warn on Compression+Maps.<commit_after># Frozen-string-literal: true
# Copyright: 2012 - 2017 - MIT License
# Encoding: utf-8

require_relative "map/css"
require_relative "map/javascript"
require_relative "map/writer"
require "pathutil"

module Jekyll
  module Assets
    module Map
      NAME = "%s.map"
      DIR_NAME = "source-maps"
      DIR = Pathutil.new(DIR_NAME)
      EXT = ".map"

      # --
      # @return [String] the map name.
      # Take the path, and attach the map extension.
      # @note this just saves logic.
      # --
      def self.map_path(env:, asset:)
        [
          path({
            asset: asset,
            env: env,
          }),
          EXT,
        ].join
      end

      # --
      # @note this is used for anything in source-maps.
      # Strip the filename and return a relative sourcemap path.
      # @return [Pathutil] the path.
      # --
      def self.path(env:, asset:)
        DIR.join(env.strip_paths(asset.is_a?(Sprockets::Asset) ?
          asset.filename : asset))
      end

      # --
      def self.register_on(instance)
        return unless instance.asset_config[:source_maps]
        unless instance.asset_config[:compression]
          instance.logger.warn "Compression is ignored w/ SourceMaps"
        end

        # Register everything, so we can get this party started.
        [Writer, JavaScript, CSS].map { |v| v.register_on(instance) }
        instance.css_compressor, instance.js_compressor =
          :source_map, :source_map
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10401396160558464, 'fraction_numerical': 0.0062827225130890054, 'mean_word_length': 1.9947753396029257, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1274171', 'n_tokens_mistral': 901, 'n_tokens_neox': 860, 'n_words': 232}