Sha256: 24577003de7ec9460659c66376ddb05c01d4dec877f01a546ffe43cf7bf5b920

Contents?: true

Size: 659 Bytes

Versions: 35

Compression:

Stored size: 659 Bytes

Contents

require 'digest'

module Ecoportal
  module API
    module Common
      module Content
        module StringDigest
          MAX_HASH_LABEL = 64

          def indexable_label(str)
            return nil unless str
            lbl = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL)
            return nil unless lbl.length >= 3
            lbl
          end

          # Calculates the Hash of the field based on label
          def hash_label(str)
            return nil unless lbl = indexable_label(str)
            "z" +  Digest::MD5.hexdigest(lbl).slice(0, 8);
          end

        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
ecoportal-api-v2-0.8.29 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.28 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.27 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.26 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.25 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.24 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.23 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.22 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.21 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.20 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.19 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.18 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.17 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.16 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.15 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.14 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.13 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.12 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.11 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-v2-0.8.10 lib/ecoportal/api/common/content/string_digest.rb