mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Fix .pm extension
This commit is contained in:
@@ -9,8 +9,6 @@ module MIME
|
|||||||
def binary?
|
def binary?
|
||||||
if defined? @binary
|
if defined? @binary
|
||||||
@binary
|
@binary
|
||||||
elsif media_type == 'text'
|
|
||||||
false
|
|
||||||
else
|
else
|
||||||
@encoding == 'base64'
|
@encoding == 'base64'
|
||||||
end
|
end
|
||||||
@@ -25,7 +23,17 @@ mime_extensions.each do |mime_type, options|
|
|||||||
|
|
||||||
(options['extensions'] || []).each { |ext| mime.extensions << ext }
|
(options['extensions'] || []).each { |ext| mime.extensions << ext }
|
||||||
|
|
||||||
mime.binary = options['binary'] if options.key?('binary')
|
(options['exclude_extensions'] || []).each do |ext|
|
||||||
|
mime.extensions.delete(ext)
|
||||||
|
|
||||||
|
MIME::Types.instance_eval do
|
||||||
|
@__types__.instance_eval do
|
||||||
|
@extension_index[ext].delete(mime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mime.binary = options['binary'] if options.key?('binary')
|
||||||
|
|
||||||
MIME::Types.add_type_variant(mime)
|
MIME::Types.add_type_variant(mime)
|
||||||
MIME::Types.index_extensions(mime)
|
MIME::Types.index_extensions(mime)
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ application/x-troff-ms:
|
|||||||
application/netcdf:
|
application/netcdf:
|
||||||
binary: false
|
binary: false
|
||||||
|
|
||||||
|
application/x-pagemaker:
|
||||||
|
exclude_extensions:
|
||||||
|
- pm
|
||||||
|
|
||||||
application/x-perl:
|
application/x-perl:
|
||||||
binary: false
|
binary: false
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ class TestMime < Test::Unit::TestCase
|
|||||||
assert_equal 'text/plain', Mime.mime_for(nil)
|
assert_equal 'text/plain', Mime.mime_for(nil)
|
||||||
assert_equal 'text/plain', Mime.mime_for("")
|
assert_equal 'text/plain', Mime.mime_for("")
|
||||||
|
|
||||||
assert_equal 'application/ruby', Mime.mime_for(".rb")
|
|
||||||
assert_equal 'application/javascript', Mime.mime_for(".js")
|
assert_equal 'application/javascript', Mime.mime_for(".js")
|
||||||
|
assert_equal 'application/perl', Mime.mime_for(".pl")
|
||||||
|
assert_equal 'application/perl', Mime.mime_for(".pm")
|
||||||
assert_equal 'application/python', Mime.mime_for(".py")
|
assert_equal 'application/python', Mime.mime_for(".py")
|
||||||
|
assert_equal 'application/ruby', Mime.mime_for(".rb")
|
||||||
|
|
||||||
assert_equal 'text/plain', Mime.mime_for(".kt")
|
assert_equal 'text/plain', Mime.mime_for(".kt")
|
||||||
assert_equal 'text/html', Mime.mime_for(".html")
|
assert_equal 'text/html', Mime.mime_for(".html")
|
||||||
@@ -108,6 +110,7 @@ class TestMime < Test::Unit::TestCase
|
|||||||
assert !Mime.binary?("application/atom+xml")
|
assert !Mime.binary?("application/atom+xml")
|
||||||
assert !Mime.binary?("application/javascript")
|
assert !Mime.binary?("application/javascript")
|
||||||
assert !Mime.binary?("application/json")
|
assert !Mime.binary?("application/json")
|
||||||
|
assert !Mime.binary?("application/perl")
|
||||||
assert !Mime.binary?("application/rdf+xml")
|
assert !Mime.binary?("application/rdf+xml")
|
||||||
assert !Mime.binary?("application/sh")
|
assert !Mime.binary?("application/sh")
|
||||||
assert !Mime.binary?("application/x-ms-xbap")
|
assert !Mime.binary?("application/x-ms-xbap")
|
||||||
@@ -128,6 +131,7 @@ class TestMime < Test::Unit::TestCase
|
|||||||
assert !Mime.binary?(".ms")
|
assert !Mime.binary?(".ms")
|
||||||
assert !Mime.binary?(".nc")
|
assert !Mime.binary?(".nc")
|
||||||
assert !Mime.binary?(".pl")
|
assert !Mime.binary?(".pl")
|
||||||
|
assert !Mime.binary?(".pm")
|
||||||
assert !Mime.binary?(".py")
|
assert !Mime.binary?(".py")
|
||||||
assert !Mime.binary?(".rb")
|
assert !Mime.binary?(".rb")
|
||||||
assert !Mime.binary?(".sh")
|
assert !Mime.binary?(".sh")
|
||||||
|
|||||||
Reference in New Issue
Block a user