Sha256: 46ffe252af1ec14caeb23d9ccd183465862f11c7ccfcfe618a5aba5d079071b6

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

module JsSpec
  class File
    MIME_TYPES = {
      '.js' => 'text/javascript',
      '.css' => 'text/css',
    }

    attr_reader :absolute_path, :relative_path
    
    def initialize(absolute_path, relative_path)
      @absolute_path = absolute_path
      @relative_path = relative_path
    end

    def get
      extension = ::File.extname(absolute_path)
      Server.response.headers['Content-Type'] = MIME_TYPES[extension] || 'text/html'
      ::File.read(absolute_path)
    end

    def ==(other)
      return false unless other.is_a?(File)
      absolute_path == other.absolute_path && relative_path == other.relative_path
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
js_spec-0.0.1 lib/js_spec/file.rb