mime-types 1.15 → 1.16
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -0
- data/{ChangeLog → History.txt} +21 -15
- data/Install.txt +17 -0
- data/{LICENCE → Licence.txt} +0 -3
- data/Manifest.txt +12 -0
- data/README.txt +28 -0
- data/Rakefile +268 -160
- data/lib/mime/types.rb +109 -916
- data/lib/mime/types.rb.data +1324 -0
- data/mime-types.gemspec +43 -0
- data/setup.rb +799 -580
- data/test/test_mime_type.rb +356 -0
- data/test/test_mime_types.rb +122 -0
- metadata +120 -51
- metadata.gz.sig +0 -0
- data/Install +0 -16
- data/README +0 -30
- data/pre-setup.rb +0 -46
- data/tests/tc_mime_type.rb +0 -275
- data/tests/tc_mime_types.rb +0 -77
- data/tests/testall.rb +0 -18
metadata
CHANGED
@@ -1,61 +1,130 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: mime-types
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- lib
|
11
|
-
email: austin@rubyforge.org
|
12
|
-
homepage: http://mime-types.rubyforge.org/
|
13
|
-
rubyforge_project: mime-types
|
14
|
-
description: "This library allows for the identification of a file's likely MIME content type.
|
15
|
-
This is release 1.15. The identification of MIME content type is based on a
|
16
|
-
file's filename extensions."
|
4
|
+
version: "1.16"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austin Ziegler
|
17
8
|
autorequire:
|
18
|
-
default_executable:
|
19
9
|
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZhdXN0
|
14
|
+
aW4xGTAXBgoJkiaJk/IsZAEZFglydWJ5Zm9yZ2UxEzARBgoJkiaJk/IsZAEZFgNv
|
15
|
+
cmcwHhcNMDcxMTMwMDE0OTAwWhcNMDgxMTI5MDE0OTAwWjBBMQ8wDQYDVQQDDAZh
|
16
|
+
dXN0aW4xGTAXBgoJkiaJk/IsZAEZFglydWJ5Zm9yZ2UxEzARBgoJkiaJk/IsZAEZ
|
17
|
+
FgNvcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDOSg1riVV22ord
|
18
|
+
q0t4YVx57GDPMqdjlnQ5M7D9iBnnW0c8pifegbb0dm+mC9hJSuPtcJS53+YPTy9F
|
19
|
+
wlZbjI2cN+P0QLUUTOlZus2sHq7Pr9jz2nJf8hCT7t5Vlopv1N/xlKtXqpcyEkhJ
|
20
|
+
JHTrxe1avGwuq8DIAIN01moQJ+hJlgrnR2eRJRazTGiXKBLGAFXDl/Agn78MHx6w
|
21
|
+
pzZ2APydo6Nuk7Ktq1MvCHzLzCACbOlYawFk3/9dbsmHhVjsi6YW+CpEJ2BnTy8X
|
22
|
+
JBXlyNTk1JxDmcs3RzNr+9AmDQh3u4LcmJnWxtLJo9e7UBxH/bwVORJyf8dAOmOm
|
23
|
+
HO6bFTLvAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
24
|
+
BBT9e1+pFfcV1LxVxILANqLtZzI/XTANBgkqhkiG9w0BAQUFAAOCAQEAhg42pvrL
|
25
|
+
uVlqAaHqV88KqgnW2ymCWm0ePohicFTcyiS5Yj5cN3OXLsPV2x12zqvLCFsfpA4u
|
26
|
+
D/85rngKFHITSW0h9e/CIT/pwQA6Uuqkbr0ypkoU6mlNIDS10PlK7aXXFTCP9X3f
|
27
|
+
IndAajiNRgKwb67nj+zpQwHa6dmooyRQIRRijrMKTgY6ebaCCrm7J3BLLTJAyxOW
|
28
|
+
+1nD0cuTkBEKIuSVK06E19Ml+xWt2bdtS9Wz/8jHivJ0SvUpbmhKVzh1rBslwm65
|
29
|
+
JpQgg3SsV23vF4qkCa2dt1FL+FeWJyCdj23DV3598X72RYiK3D6muWURck16jqeA
|
30
|
+
BRvUFuFHOwa/yA==
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2009-03-02 00:00:00 -05:00
|
34
|
+
default_executable:
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: archive-tar-minitar
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0.5"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: nokogiri
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "1.2"
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rcov
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0.8"
|
65
|
+
version:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: hoe
|
68
|
+
type: :development
|
69
|
+
version_requirement:
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.8.3
|
75
|
+
version:
|
76
|
+
description: MIME::Types for Ruby originally based on and synchronized with MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. As of version 1.15, the data format for the MIME::Type list has changed and the synchronization will no longer happen.
|
77
|
+
email:
|
78
|
+
- austin@rubyforge.org
|
79
|
+
executables: []
|
80
|
+
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files:
|
84
|
+
- History.txt
|
85
|
+
- Install.txt
|
86
|
+
- Licence.txt
|
87
|
+
- README.txt
|
88
|
+
files:
|
89
|
+
- History.txt
|
90
|
+
- Install.txt
|
91
|
+
- Licence.txt
|
92
|
+
- Manifest.txt
|
93
|
+
- README.txt
|
94
|
+
- Rakefile
|
95
|
+
- lib/mime/types.rb
|
96
|
+
- lib/mime/types.rb.data
|
97
|
+
- mime-types.gemspec
|
98
|
+
- setup.rb
|
99
|
+
- test/test_mime_type.rb
|
100
|
+
- test/test_mime_types.rb
|
20
101
|
has_rdoc: true
|
21
|
-
|
102
|
+
homepage: http://mime-types.rubyforge.org/
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options:
|
105
|
+
- --main
|
106
|
+
- README.txt
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
22
110
|
requirements:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
version: 0.0.0
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "0"
|
27
114
|
version:
|
28
|
-
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: "0"
|
120
|
+
version:
|
121
|
+
requirements: []
|
122
|
+
|
123
|
+
rubyforge_project: mime-types
|
124
|
+
rubygems_version: 1.3.1
|
29
125
|
signing_key:
|
30
|
-
|
31
|
-
|
32
|
-
- Austin Ziegler
|
33
|
-
files:
|
34
|
-
- lib/mime
|
35
|
-
- lib/mime/types.rb
|
36
|
-
- tests/tc_mime_type.rb
|
37
|
-
- tests/tc_mime_types.rb
|
38
|
-
- tests/testall.rb
|
39
|
-
- ChangeLog
|
40
|
-
- README
|
41
|
-
- LICENCE
|
42
|
-
- setup.rb
|
43
|
-
- Rakefile
|
44
|
-
- pre-setup.rb
|
45
|
-
- Install
|
126
|
+
specification_version: 2
|
127
|
+
summary: Manages a MIME Content-Type database that will return the Content-Type for a given filename.
|
46
128
|
test_files:
|
47
|
-
|
48
|
-
|
49
|
-
- "--title"
|
50
|
-
- MIME::Types
|
51
|
-
- "--main"
|
52
|
-
- README
|
53
|
-
- "--line-numbers"
|
54
|
-
extra_rdoc_files:
|
55
|
-
- README
|
56
|
-
- ChangeLog
|
57
|
-
- Install
|
58
|
-
executables: []
|
59
|
-
extensions: []
|
60
|
-
requirements: []
|
61
|
-
dependencies: []
|
129
|
+
- test/test_mime_type.rb
|
130
|
+
- test/test_mime_types.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/Install
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
Installing this package is as simple as:
|
2
|
-
|
3
|
-
% ruby setup.rb
|
4
|
-
|
5
|
-
Alternatively, you can use the RubyGem version of MIME::Types available as
|
6
|
-
mime-types-1.15.gem from the usual sources.
|
7
|
-
|
8
|
-
#--
|
9
|
-
# MIME::Types for Ruby
|
10
|
-
# http://rubyforge.org/projects/mime-types/
|
11
|
-
# Copyright 2003 - 2006 Austin Ziegler.
|
12
|
-
# Licensed under a MIT-style licence.
|
13
|
-
#
|
14
|
-
# $Id: Install,v 1.3 2006/02/12 21:27:21 austin Exp $
|
15
|
-
#++
|
16
|
-
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/README
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
= README: Mime::Types for Ruby
|
2
|
-
This library allows for the identification of a file's likely MIME content
|
3
|
-
type. This is release 1.15. The identification of MIME content type is based
|
4
|
-
on a file's filename extensions.
|
5
|
-
|
6
|
-
MIME::Types for Ruby originally based on and synchronized with MIME::Types
|
7
|
-
for Perl by Mark Overmeer, copyright 2001 - 2005. As of version 1.15, the
|
8
|
-
data format for the MIME::Type list has changed and the synchronization will
|
9
|
-
no longer happen.
|
10
|
-
|
11
|
-
Homepage:: http://mime-types.rubyforge.org/
|
12
|
-
Copyright:: 2002 - 2006, Austin Ziegler
|
13
|
-
Based on prior work copyright Mark Overmeer
|
14
|
-
|
15
|
-
== Licensing
|
16
|
-
MIME::Types is available under three disjunctive licences, as detailed in the
|
17
|
-
LICENCE file.
|
18
|
-
|
19
|
-
== Requirements
|
20
|
-
MIME::Types requires Ruby 1.8.2 or better.
|
21
|
-
|
22
|
-
#--
|
23
|
-
# MIME::Types for Ruby
|
24
|
-
# http://rubyforge.org/projects/mime-types/
|
25
|
-
# Copyright 2003 - 2005 Austin Ziegler.
|
26
|
-
# Licensed under a MIT-style licence.
|
27
|
-
#
|
28
|
-
# $Id: Readme,v 1.3 2006/02/12 21:27:21 austin Exp $
|
29
|
-
#++
|
30
|
-
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/pre-setup.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'rdoc/rdoc'
|
2
|
-
##
|
3
|
-
# Build the rdoc documentation. Also, try to build the RI documentation.
|
4
|
-
#
|
5
|
-
def build_rdoc(options)
|
6
|
-
RDoc::RDoc.new.document(options)
|
7
|
-
rescue RDoc::RDocError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
rescue Exception => e
|
10
|
-
$stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def build_ri(files)
|
14
|
-
RDoc::RDoc.new(["--ri-site", "--merge"] + files)
|
15
|
-
rescue RDoc::RDocError => e
|
16
|
-
$stderr.puts e.message
|
17
|
-
rescue Exception => e
|
18
|
-
$stderr.puts "Couldn't build Ri documentation\n#{e.message}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def run_tests(test_list)
|
22
|
-
return if test_list.empty?
|
23
|
-
|
24
|
-
require 'test/unit/ui/console/testrunner'
|
25
|
-
$:.unshift "lib"
|
26
|
-
test_list.each do |test|
|
27
|
-
next if File.directory?(test)
|
28
|
-
require test
|
29
|
-
end
|
30
|
-
|
31
|
-
tests = []
|
32
|
-
ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
|
33
|
-
tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
|
34
|
-
tests.delete_if { |o| o == Test::Unit::TestCase }
|
35
|
-
|
36
|
-
tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
|
37
|
-
$:.shift
|
38
|
-
end
|
39
|
-
|
40
|
-
rdoc = %w(--main README --line-numbers
|
41
|
-
--title MIME::Types)
|
42
|
-
ri = %w(--ri-site --merge)
|
43
|
-
dox = %w(README ChangeLog lib)
|
44
|
-
build_rdoc rdoc + dox
|
45
|
-
build_ri ri + dox
|
46
|
-
run_tests Dir["tests/**/*"]
|
data/tests/tc_mime_type.rb
DELETED
@@ -1,275 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#--
|
3
|
-
# MIME::Types for Ruby
|
4
|
-
# http://rubyforge.org/projects/mime-types/
|
5
|
-
# Copyright 2003 - 2005 Austin Ziegler.
|
6
|
-
# Licensed under a MIT-style licence.
|
7
|
-
#
|
8
|
-
# $Id: tc_mime_type.rb,v 1.2 2006/02/12 21:27:22 austin Exp $
|
9
|
-
#++
|
10
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
11
|
-
|
12
|
-
require 'mime/types'
|
13
|
-
require 'test/unit'
|
14
|
-
|
15
|
-
class Test_MIME__Type < Test::Unit::TestCase #:nodoc:
|
16
|
-
def setup
|
17
|
-
@zip = MIME::Type.new('x-appl/x-zip') { |t| t.extensions = ['zip', 'zp'] }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_CMP # '<=>'
|
21
|
-
assert(MIME::Type.new('text/plain') == MIME::Type.new('text/plain'))
|
22
|
-
assert(MIME::Type.new('text/plain') != MIME::Type.new('image/jpeg'))
|
23
|
-
assert(MIME::Type.new('text/plain') == 'text/plain')
|
24
|
-
assert(MIME::Type.new('text/plain') != 'image/jpeg')
|
25
|
-
assert(MIME::Type.new('text/plain') > MIME::Type.new('text/html'))
|
26
|
-
assert(MIME::Type.new('text/plain') > 'text/html')
|
27
|
-
assert(MIME::Type.new('text/html') < MIME::Type.new('text/plain'))
|
28
|
-
assert(MIME::Type.new('text/html') < 'text/plain')
|
29
|
-
assert('text/html' == MIME::Type.new('text/html'))
|
30
|
-
assert('text/html' < MIME::Type.new('text/plain'))
|
31
|
-
assert('text/plain' > MIME::Type.new('text/html'))
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_ascii?
|
35
|
-
assert(MIME::Type.new('text/plain').ascii?)
|
36
|
-
assert(!MIME::Type.new('image/jpeg').ascii?)
|
37
|
-
assert(!MIME::Type.new('application/x-msword').ascii?)
|
38
|
-
assert(MIME::Type.new('text/vCard').ascii?)
|
39
|
-
assert(!MIME::Type.new('application/pkcs7-mime').ascii?)
|
40
|
-
assert(!@zip.ascii?)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_binary?
|
44
|
-
assert(!MIME::Type.new('text/plain').binary?)
|
45
|
-
assert(MIME::Type.new('image/jpeg').binary?)
|
46
|
-
assert(MIME::Type.new('application/x-msword').binary?)
|
47
|
-
assert(!MIME::Type.new('text/vCard').binary?)
|
48
|
-
assert(MIME::Type.new('application/pkcs7-mime').binary?)
|
49
|
-
assert(@zip.binary?)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_complete?
|
53
|
-
assert_nothing_raised do
|
54
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
55
|
-
'linux')
|
56
|
-
end
|
57
|
-
assert(@yaml.complete?)
|
58
|
-
assert_nothing_raised { @yaml.extensions = nil }
|
59
|
-
assert(!@yaml.complete?)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_content_type
|
63
|
-
assert_equal(MIME::Type.new('text/plain').content_type, 'text/plain')
|
64
|
-
assert_equal(MIME::Type.new('image/jpeg').content_type, 'image/jpeg')
|
65
|
-
assert_equal(MIME::Type.new('application/x-msword').content_type, 'application/x-msword')
|
66
|
-
assert_equal(MIME::Type.new('text/vCard').content_type, 'text/vCard')
|
67
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').content_type, 'application/pkcs7-mime')
|
68
|
-
assert_equal(@zip.content_type, 'x-appl/x-zip');
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_encoding
|
72
|
-
assert_equal(MIME::Type.new('text/plain').encoding, 'quoted-printable')
|
73
|
-
assert_equal(MIME::Type.new('image/jpeg').encoding, 'base64')
|
74
|
-
assert_equal(MIME::Type.new('application/x-msword').encoding, 'base64')
|
75
|
-
assert_equal(MIME::Type.new('text/vCard').encoding, 'quoted-printable')
|
76
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').encoding, 'base64')
|
77
|
-
assert_nothing_raised do
|
78
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
79
|
-
'linux')
|
80
|
-
end
|
81
|
-
assert_equal(@yaml.encoding, '8bit')
|
82
|
-
assert_nothing_raised { @yaml.encoding = 'base64' }
|
83
|
-
assert_equal(@yaml.encoding, 'base64')
|
84
|
-
assert_nothing_raised { @yaml.encoding = :default }
|
85
|
-
assert_equal(@yaml.encoding, 'quoted-printable')
|
86
|
-
assert_raises(ArgumentError) { @yaml.encoding = 'binary' }
|
87
|
-
assert_equal(@zip.encoding, 'base64')
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_eql?
|
91
|
-
assert(MIME::Type.new('text/plain').eql?(MIME::Type.new('text/plain')))
|
92
|
-
assert(!MIME::Type.new('text/plain').eql?(MIME::Type.new('image/jpeg')))
|
93
|
-
assert(!MIME::Type.new('text/plain').eql?('text/plain'))
|
94
|
-
assert(!MIME::Type.new('text/plain').eql?('image/jpeg'))
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_extensions
|
98
|
-
assert_nothing_raised do
|
99
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
100
|
-
'linux')
|
101
|
-
end
|
102
|
-
assert_equal(@yaml.extensions, ['yaml', 'yml'])
|
103
|
-
assert_nothing_raised { @yaml.extensions = 'yaml' }
|
104
|
-
assert_equal(@yaml.extensions, ['yaml'])
|
105
|
-
assert_equal(@zip.extensions.size, 2)
|
106
|
-
assert_equal(@zip.extensions, ['zip', 'zp'])
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_like?
|
110
|
-
assert(MIME::Type.new('text/plain').like?(MIME::Type.new('text/plain')))
|
111
|
-
assert(MIME::Type.new('text/plain').like?(MIME::Type.new('text/x-plain')))
|
112
|
-
assert(!MIME::Type.new('text/plain').like?(MIME::Type.new('image/jpeg')))
|
113
|
-
assert(MIME::Type.new('text/plain').like?('text/plain'))
|
114
|
-
assert(MIME::Type.new('text/plain').like?('text/x-plain'))
|
115
|
-
assert(!MIME::Type.new('text/plain').like?('image/jpeg'))
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_media_type
|
119
|
-
assert_equal(MIME::Type.new('text/plain').media_type, 'text')
|
120
|
-
assert_equal(MIME::Type.new('image/jpeg').media_type, 'image')
|
121
|
-
assert_equal(MIME::Type.new('application/x-msword').media_type, 'application')
|
122
|
-
assert_equal(MIME::Type.new('text/vCard').media_type, 'text')
|
123
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').media_type, 'application')
|
124
|
-
assert_equal(MIME::Type.new('x-chemical/x-pdb').media_type, 'chemical')
|
125
|
-
assert_equal(@zip.media_type, 'appl')
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_platform?
|
129
|
-
assert_nothing_raised do
|
130
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
131
|
-
'oddbox')
|
132
|
-
end
|
133
|
-
assert(!@yaml.platform?)
|
134
|
-
assert_nothing_raised { @yaml.system = nil }
|
135
|
-
assert(!@yaml.platform?)
|
136
|
-
assert_nothing_raised { @yaml.system = /#{RUBY_PLATFORM}/ }
|
137
|
-
assert(@yaml.platform?)
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_raw_media_type
|
141
|
-
assert_equal(MIME::Type.new('text/plain').raw_media_type, 'text')
|
142
|
-
assert_equal(MIME::Type.new('image/jpeg').raw_media_type, 'image')
|
143
|
-
assert_equal(MIME::Type.new('application/x-msword').raw_media_type, 'application')
|
144
|
-
assert_equal(MIME::Type.new('text/vCard').raw_media_type, 'text')
|
145
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').raw_media_type, 'application')
|
146
|
-
|
147
|
-
assert_equal(MIME::Type.new('x-chemical/x-pdb').raw_media_type, 'x-chemical')
|
148
|
-
assert_equal(@zip.raw_media_type, 'x-appl')
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_raw_sub_type
|
152
|
-
assert_equal(MIME::Type.new('text/plain').raw_sub_type, 'plain')
|
153
|
-
assert_equal(MIME::Type.new('image/jpeg').raw_sub_type, 'jpeg')
|
154
|
-
assert_equal(MIME::Type.new('application/x-msword').raw_sub_type, 'x-msword')
|
155
|
-
assert_equal(MIME::Type.new('text/vCard').raw_sub_type, 'vCard')
|
156
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').raw_sub_type, 'pkcs7-mime')
|
157
|
-
assert_equal(@zip.raw_sub_type, 'x-zip')
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_registered?
|
161
|
-
assert(MIME::Type.new('text/plain').registered?)
|
162
|
-
assert(MIME::Type.new('image/jpeg').registered?)
|
163
|
-
assert(!MIME::Type.new('application/x-msword').registered?)
|
164
|
-
assert(MIME::Type.new('text/vCard').registered?)
|
165
|
-
assert(MIME::Type.new('application/pkcs7-mime').registered?)
|
166
|
-
assert(!@zip.registered?)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_signature?
|
170
|
-
assert(!MIME::Type.new('text/plain').signature?)
|
171
|
-
assert(!MIME::Type.new('image/jpeg').signature?)
|
172
|
-
assert(!MIME::Type.new('application/x-msword').signature?)
|
173
|
-
assert(MIME::Type.new('text/vCard').signature?)
|
174
|
-
assert(MIME::Type.new('application/pkcs7-mime').signature?)
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_simplified
|
178
|
-
assert_equal(MIME::Type.new('text/plain').simplified, 'text/plain')
|
179
|
-
assert_equal(MIME::Type.new('image/jpeg').simplified, 'image/jpeg')
|
180
|
-
assert_equal(MIME::Type.new('application/x-msword').simplified, 'application/msword')
|
181
|
-
assert_equal(MIME::Type.new('text/vCard').simplified, 'text/vcard')
|
182
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').simplified, 'application/pkcs7-mime')
|
183
|
-
assert_equal(MIME::Type.new('x-chemical/x-pdb').simplified, 'chemical/pdb')
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_sub_type
|
187
|
-
assert_equal(MIME::Type.new('text/plain').sub_type, 'plain')
|
188
|
-
assert_equal(MIME::Type.new('image/jpeg').sub_type, 'jpeg')
|
189
|
-
assert_equal(MIME::Type.new('application/x-msword').sub_type, 'msword')
|
190
|
-
assert_equal(MIME::Type.new('text/vCard').sub_type, 'vcard')
|
191
|
-
assert_equal(MIME::Type.new('application/pkcs7-mime').sub_type, 'pkcs7-mime')
|
192
|
-
assert_equal(@zip.sub_type, 'zip')
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_system
|
196
|
-
assert_nothing_raised do
|
197
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
198
|
-
'linux')
|
199
|
-
end
|
200
|
-
assert_equal(@yaml.system, %r{linux})
|
201
|
-
assert_nothing_raised { @yaml.system = /win32/ }
|
202
|
-
assert_equal(@yaml.system, %r{win32})
|
203
|
-
assert_nothing_raised { @yaml.system = nil }
|
204
|
-
assert_nil(@yaml.system)
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_system?
|
208
|
-
assert_nothing_raised do
|
209
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
210
|
-
'linux')
|
211
|
-
end
|
212
|
-
assert(@yaml.system?)
|
213
|
-
assert_nothing_raised { @yaml.system = nil }
|
214
|
-
assert(!@yaml.system?)
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_to_a
|
218
|
-
assert_nothing_raised do
|
219
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
220
|
-
'linux')
|
221
|
-
end
|
222
|
-
assert_equal(@yaml.to_a, ['text/x-yaml', ['yaml', 'yml'], '8bit',
|
223
|
-
/linux/, nil, nil, nil, false])
|
224
|
-
end
|
225
|
-
|
226
|
-
def test_to_hash
|
227
|
-
assert_nothing_raised do
|
228
|
-
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
229
|
-
'linux')
|
230
|
-
end
|
231
|
-
assert_equal(@yaml.to_hash,
|
232
|
-
{ 'Content-Type' => 'text/x-yaml',
|
233
|
-
'Content-Transfer-Encoding' => '8bit',
|
234
|
-
'Extensions' => ['yaml', 'yml'],
|
235
|
-
'System' => /linux/,
|
236
|
-
'Registered' => false,
|
237
|
-
'URL' => nil,
|
238
|
-
'Obsolete' => nil,
|
239
|
-
'Docs' => nil })
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_to_s
|
243
|
-
assert_equal("#{MIME::Type.new('text/plain')}", 'text/plain')
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_s_constructors
|
247
|
-
assert_not_nil(@zip)
|
248
|
-
yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
|
249
|
-
'linux')
|
250
|
-
assert_instance_of(MIME::Type, yaml)
|
251
|
-
yaml = MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
|
252
|
-
'Content-Transfer-Encoding' => '8bit',
|
253
|
-
'System' => 'linux',
|
254
|
-
'Extensions' => ['yaml', 'yml'])
|
255
|
-
assert_instance_of(MIME::Type, yaml)
|
256
|
-
yaml = MIME::Type.new('text/x-yaml') do |y|
|
257
|
-
y.extensions = ['yaml', 'yml']
|
258
|
-
y.encoding = '8bit'
|
259
|
-
y.system = 'linux'
|
260
|
-
end
|
261
|
-
assert_instance_of(MIME::Type, yaml)
|
262
|
-
assert_raises(MIME::InvalidContentType) { MIME::Type.new('apps') }
|
263
|
-
assert_raises(MIME::InvalidContentType) { MIME::Type.new(nil) }
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_s_simplified
|
267
|
-
assert_equal(MIME::Type.simplified('text/plain'), 'text/plain')
|
268
|
-
assert_equal(MIME::Type.simplified('image/jpeg'), 'image/jpeg')
|
269
|
-
assert_equal(MIME::Type.simplified('application/x-msword'), 'application/msword')
|
270
|
-
assert_equal(MIME::Type.simplified('text/vCard'), 'text/vcard')
|
271
|
-
assert_equal(MIME::Type.simplified('application/pkcs7-mime'), 'application/pkcs7-mime')
|
272
|
-
assert_equal(@zip.simplified, 'appl/zip')
|
273
|
-
assert_equal(MIME::Type.simplified('x-xyz/abc'), 'xyz/abc')
|
274
|
-
end
|
275
|
-
end
|