Sha256: cb0f1c70b3b28fed03831fbcf2e05e48afc2834ddf3bc50519e337f8e766feed
Contents?: true
Size: 884 Bytes
Versions: 13
Compression:
Stored size: 884 Bytes
Contents
require 'tempfile' require 'uri' require 'rack' module Dragonfly module Utils module_function def blank?(obj) obj.respond_to?(:empty?) ? obj.empty? : !obj end def new_tempfile(ext=nil, content=nil) tempfile = ext ? Tempfile.new(['dragonfly', ".#{ext}"]) : Tempfile.new('dragonfly') tempfile.binmode tempfile.write(content) if content tempfile.close tempfile end def symbolize_keys(hash) hash.inject({}) do |new_hash, (key, value)| new_hash[key.to_sym] = value new_hash end end def stringify_keys(hash) hash.inject({}) do |new_hash, (key, value)| new_hash[key.to_s] = value new_hash end end def uri_escape_segment(string) Rack::Utils.escape_path(string) end def uri_unescape(string) URI.unescape(string) end end end
Version data entries
13 entries across 13 versions & 1 rubygems