Sha256: 9a7ee4dbe94cf8ad6c1d1bcc3b6f718dc83e729f3282d218d03e68c1b402d064
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
class Kumogata::Utils class << self def camelize(str) str.to_s.split(/[-_]/).map {|i| i[0, 1].upcase + i[1..-1].downcase }.join end def get_user_host user = `whoami`.strip rescue '' host = `hostname`.strip rescue '' user_host = [user, host].select {|i| not i.empty? }.join('-') user_host.empty? ? nil : user_host end def random_param_name(n) a_zA_Z0_9 = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a) a_zA_Z0_9.sample(n).join end def filter_backtrace(backtrace) filter_path = ['(eval)'] if defined?(Gem) filter_path.concat(Gem.path) filter_path << Gem.bindir end RbConfig::CONFIG.select {|k, v| k.to_s =~ /libdir/ }.each {|k, v| filter_path << v } filter_path = filter_path.map {|i| /\A#{Regexp.escape(i)}/ } backtrace.select do |path| path = path.split(':', 2).first not filter_path.any? {|i| i =~ path } end end end # of class methods end module Kumogata ENCRYPTION_PASSWORD = Kumogata::Utils.random_param_name(16) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kumogata-0.4.9 | lib/kumogata/utils.rb |
kumogata-0.4.8 | lib/kumogata/utils.rb |