Sha256: a2d1728db33572dc77f4eccf4691a254cf2f5a8321ad4b24f065d2a0ca3b863a
Contents?: true
Size: 1.06 KB
Versions: 55
Compression:
Stored size: 1.06 KB
Contents
module PactBroker module StringRefinements refine String do def not_blank? !blank? end def blank? self.strip.size == 0 end # ripped from rubyworks/facets, thank you def snakecase gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr('-', '_') .gsub(/\s/, '_') .gsub(/__+/, '_') .downcase end # ripped from rubyworks/facets, thank you def camelcase(*separators) case separators.first when Symbol, TrueClass, FalseClass, NilClass first_letter = separators.shift end separators = ['_', '\s'] if separators.empty? str = self.dup separators.each do |s| str = str.gsub(/(?:#{s}+)([a-z])/){ $1.upcase } end case first_letter when :upper, true str = str.gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase } when :lower, false str = str.gsub(/(\A|\s)([A-Z])/){ $1 + $2.downcase } end str end end end end
Version data entries
55 entries across 55 versions & 1 rubygems