This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
forked from brynary/webrat
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: Rakefile lib/webrat.rb
- Loading branch information
Showing
4 changed files
with
18 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
module Webrat #:nodoc: | ||
module MIME #:nodoc: | ||
MIME_TYPES = Rack::Mime::MIME_TYPES.dup.merge( | ||
".multipart_form" => "multipart/form-data", | ||
".url_encoded_form" => "application/x-www-form-urlencoded" | ||
).freeze | ||
|
||
def self.mime_type(string_or_symbol) #:nodoc: | ||
if string_or_symbol.is_a?(String) | ||
string_or_symbol | ||
else | ||
case string_or_symbol | ||
when :text then "text/plain" | ||
when :html then "text/html" | ||
when :js then "text/javascript" | ||
when :css then "text/css" | ||
when :ics then "text/calendar" | ||
when :csv then "text/csv" | ||
when :xml then "application/xml" | ||
when :rss then "application/rss+xml" | ||
when :atom then "application/atom+xml" | ||
when :yaml then "application/x-yaml" | ||
when :multipart_form then "multipart/form-data" | ||
when :url_encoded_form then "application/x-www-form-urlencoded" | ||
when :json then "application/json" | ||
else | ||
raise ArgumentError.new("Invalid Mime type: #{string_or_symbol.inspect}") | ||
end | ||
end | ||
def mime_type(type) | ||
return type if type.nil? || type.to_s.include?("/") | ||
type = ".#{type}" unless type.to_s[0] == ?. | ||
MIME_TYPES.fetch(type) { |type| | ||
raise ArgumentError.new("Invalid Mime type: #{type}") | ||
} | ||
end | ||
|
||
module_function :mime_type | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters