Sha256: 867d43ade661140dff5af4de628efc5ea0b05178ee6d943c103a5a943826a909

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

require 'tempfile'
require 'uri'

module Dragonfly
  module Utils

    module_function

    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 uri_escape_segment(string)
      Rack::Utils.escape_path(string)
    end

    def uri_unescape(string)
      URI.unescape(string)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dragonfly-0.9.15 lib/dragonfly/utils.rb