Sha256: cb51042da036af4c08165e1da480059fe42211decbe4f49fe11531b07429b5a3
Contents?: true
Size: 810 Bytes
Versions: 4
Compression:
Stored size: 810 Bytes
Contents
module Daigaku module Storeable LEADING_NUMBERS = /^\d+[\_\-\s]+/ PART_JOINTS = /[\_\-\s]+/ class << self def key(text, options = {}) separator = QuickStore.config.key_separator prefix = options[:prefix] suffix = clean(options[:suffix]) suffixes = options[:suffixes] suffixes_items = suffixes ? suffixes.map { |s| clean(s) }.compact : nil [prefix, clean(text), suffix || suffixes_items].compact.join(separator) end private def clean(text) if text parts = text.to_s.split(QuickStore.config.key_separator).map do |key| key.gsub(LEADING_NUMBERS, '').gsub(PART_JOINTS, '_').downcase end parts.join(QuickStore.config.key_separator) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
daigaku-0.3.0 | lib/daigaku/storeable.rb |
daigaku-0.2.0 | lib/daigaku/storeable.rb |
daigaku-0.1.1 | lib/daigaku/storeable.rb |
daigaku-0.1.0 | lib/daigaku/storeable.rb |