Sha256: 7f426b6eb8409b69f4a66f4c18cdf13388f63d7f95f7f270171678699fe6c833

Contents?: true

Size: 1.27 KB

Versions: 28

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true
require 'sprockets/digest_utils'
require 'sprockets/path_utils'

module Sprockets
  # Internal: Crossover of path and digest utilities functions.
  module PathDigestUtils
    include DigestUtils, PathUtils

    # Internal: Compute digest for file stat.
    #
    # path - String filename
    # stat - File::Stat
    #
    # Returns String digest bytes.
    def stat_digest(path, stat)
      if stat.directory?
        # If its a directive, digest the list of filenames
        digest_class.digest(self.entries(path).join(','.freeze))
      elsif stat.file?
        # If its a file, digest the contents
        digest_class.file(path.to_s).digest
      else
        raise TypeError, "stat was not a directory or file: #{stat.ftype}"
      end
    end

    # Internal: Compute digest for path.
    #
    # path - String filename or directory path.
    #
    # Returns String digest bytes or nil.
    def file_digest(path)
      if stat = self.stat(path)
        self.stat_digest(path, stat)
      end
    end

    # Internal: Compute digest for a set of paths.
    #
    # paths - Array of filename or directory paths.
    #
    # Returns String digest bytes.
    def files_digest(paths)
      self.digest(paths.map { |path| self.file_digest(path) })
    end
  end
end

Version data entries

28 entries across 28 versions & 9 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sprockets-4.2.1/lib/sprockets/path_digest_utils.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/path_digest_utils.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/path_digest_utils.rb
sprockets-4.2.1 lib/sprockets/path_digest_utils.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/path_digest_utils.rb
sprockets-4.2.0 lib/sprockets/path_digest_utils.rb
sprockets-4.1.1 lib/sprockets/path_digest_utils.rb
sprockets-4.1.0 lib/sprockets/path_digest_utils.rb
sprockets-4.0.3 lib/sprockets/path_digest_utils.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/path_digest_utils.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/path_digest_utils.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/path_digest_utils.rb
sprockets-4.0.2 lib/sprockets/path_digest_utils.rb
sprockets-4.0.1 lib/sprockets/path_digest_utils.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/path_digest_utils.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/path_digest_utils.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/path_digest_utils.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/path_digest_utils.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/path_digest_utils.rb
sprockets-4.0.0 lib/sprockets/path_digest_utils.rb