public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
dsutedja (author)
Mon Aug 18 05:31:41 -0700 2008
commit  c48498d7606d3484506fc0d9ef5382c561d421c5
tree    944118836ae8dd7764696c9df7f938753312cfe5
parent  afc26c3570fb97c4509caf7c25ef923d8a46f8d0
mack / lib / mack / testing / file.rb
100644 29 lines (26 sloc) 0.745 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'base64'
module Mack
  module Testing
    class FileWrapper # :nodoc:
      
      attr_reader :path
      attr_reader :file_name
      attr_reader :content
      attr_reader :size
      attr_reader :mime
      
      def initialize(path)
        @path = path
        @file_name = File.basename(path)
        extension = File.extname(path)
        extension = extension.gsub!(".", "")
        if extension and !extension.empty?
          @mime = Mack::Utils::MimeTypes.instance.get(extension) if extension
        else
          @mime = "application/octet-stream"
        end
        raw_content = File.read(path)
        @content = Base64.encode64(raw_content).strip
        @size = @content.size
      end
    end
  end
end