Sha256: 9b1b70487a32fc368d4a5fe5a28523e760c52efcb2b688185ba3b6514f673c03

Contents?: true

Size: 578 Bytes

Versions: 17

Compression:

Stored size: 578 Bytes

Contents

# encoding: utf-8

module Nanoc::StringExtensions

  # Transforms string into an actual identifier
  #
  # @return [String] The identifier generated from the receiver
  def cleaned_identifier
    "/#{self}/".gsub(/^\/+|\/+$/, '/')
  end

  # Calculates the checksum for this string. Any change to this string will
  # result in a different checksum.
  #
  # @return [String] The checksum for this string
  #
  # @api private
  def checksum
    digest = Digest::SHA1.new
    digest.update(self)
    digest.hexdigest
  end

end

class String
  include Nanoc::StringExtensions
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
nanoc-3.6.9 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.8 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.7 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.6 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.5 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.4 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.3 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.2 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.1 lib/nanoc/base/core_ext/string.rb
nanoc-3.6.0 lib/nanoc/base/core_ext/string.rb
nanoc-3.5.0 lib/nanoc/base/core_ext/string.rb
nanoc-3.5.0b2 lib/nanoc/base/core_ext/string.rb
nanoc-3.5.0b1 lib/nanoc/base/core_ext/string.rb
nanoc-3.4.3 lib/nanoc/base/core_ext/string.rb
nanoc-3.4.2 lib/nanoc/base/core_ext/string.rb
nanoc-3.4.1 lib/nanoc/base/core_ext/string.rb
nanoc-3.4.0 lib/nanoc/base/core_ext/string.rb