s33r 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/s3cli.rb +25 -16
- data/html/classes/MIME.html +120 -0
- data/html/classes/MIME/InvalidContentType.html +119 -0
- data/html/classes/MIME/Type.html +1173 -0
- data/html/classes/MIME/Types.html +566 -0
- data/html/classes/Net.html +108 -0
- data/html/classes/Net/HTTPGenericRequest.html +233 -0
- data/html/classes/Net/HTTPResponse.html +242 -0
- data/html/classes/S33r.html +743 -0
- data/html/classes/S33r/BucketListing.html +372 -0
- data/html/classes/S33r/Client.html +981 -0
- data/html/classes/S33r/NamedBucket.html +620 -0
- data/html/classes/S33r/S33rException.html +118 -0
- data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +111 -0
- data/html/classes/S33r/S33rException/InvalidBucketListing.html +111 -0
- data/html/classes/S33r/S33rException/MalformedBucketName.html +111 -0
- data/html/classes/S33r/S33rException/MethodNotAvailable.html +111 -0
- data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +111 -0
- data/html/classes/S33r/S33rException/MissingResource.html +111 -0
- data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +111 -0
- data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +111 -0
- data/html/classes/S33r/S3Object.html +307 -0
- data/html/classes/S33r/S3User.html +171 -0
- data/html/classes/S33r/Sync.html +151 -0
- data/html/classes/XML.html +200 -0
- data/html/classes/XML/Document.html +125 -0
- data/html/classes/XML/Node.html +124 -0
- data/html/created.rid +1 -0
- data/html/files/CHANGELOG.html +101 -0
- data/html/files/MIT-LICENSE.html +129 -0
- data/html/files/README_txt.html +209 -0
- data/html/files/lib/s33r/bucket_listing_rb.html +116 -0
- data/html/files/lib/s33r/client_rb.html +110 -0
- data/html/files/lib/s33r/core_rb.html +113 -0
- data/html/files/lib/s33r/libxml_extensions_rb.html +107 -0
- data/html/files/lib/s33r/mimetypes_rb.html +120 -0
- data/html/files/lib/s33r/named_bucket_rb.html +101 -0
- data/html/files/lib/s33r/s33r_exception_rb.html +101 -0
- data/html/files/lib/s33r/s33r_http_rb.html +108 -0
- data/html/files/lib/s33r/sync_rb.html +101 -0
- data/html/files/lib/s33r_rb.html +101 -0
- data/html/fr_class_index.html +52 -0
- data/html/fr_file_index.html +39 -0
- data/html/fr_method_index.html +126 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/s33r/bucket_listing.rb +69 -60
- data/lib/s33r/client.rb +150 -73
- data/lib/s33r/core.rb +56 -44
- data/lib/s33r/libxml_extensions.rb +10 -5
- data/lib/s33r/mimetypes.rb +3 -2
- data/lib/s33r/named_bucket.rb +89 -24
- data/lib/s33r/{s3_exception.rb → s33r_exception.rb} +2 -2
- data/lib/s33r/{net_http_overrides.rb → s33r_http.rb} +29 -21
- data/lib/s33r/sync.rb +4 -2
- data/test/cases/spec_bucket_listing.rb +10 -13
- data/test/cases/spec_client.rb +65 -0
- data/test/cases/spec_core.rb +16 -11
- data/test/cases/spec_namedbucket.rb +32 -0
- data/test/cases/spec_sync.rb +6 -5
- data/test/cases/spec_xml.rb +1 -1
- data/test/files/client_config.yml +6 -0
- data/test/files/namedbucket_config.yml +12 -0
- data/test/{s3_test_constants.rb → test_setup.rb} +7 -6
- metadata +63 -11
- data/LICENSE.txt +0 -22
- data/MIT-LICENSE +0 -21
- data/README.txt +0 -19
- data/bin/config.yml +0 -5
- data/test/cases/unit_client.rb +0 -40
- data/test/cases/unit_named_bucket.rb +0 -12
data/bin/s3cli.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# SIMPLE COMMAND LINE S3 CLIENT
|
2
2
|
# You need an Amazon S3 account to use this: get one at http://aws.amazon.com/
|
3
3
|
#
|
4
|
-
# Create a config. file called based on the
|
4
|
+
# Create a config. file called based on the example in test/files/namedbucket_config.yml;
|
5
5
|
# then change the config_file setting below to set the path to your config. file.
|
6
6
|
# You will be prompted to create a bucket if your setting for bucket in the config.
|
7
7
|
# file is blank.
|
@@ -16,28 +16,32 @@
|
|
16
16
|
# to_email: email address to send to (optional)
|
17
17
|
|
18
18
|
require 'yaml'
|
19
|
-
require 'rubygems'
|
20
|
-
require_gem 's33r'
|
21
19
|
require 'net/smtp'
|
22
20
|
require 'time'
|
23
21
|
require 'parsedate'
|
24
22
|
|
23
|
+
require File.join(File.dirname(__FILE__), '../lib/s33r')
|
24
|
+
|
25
25
|
filename = ARGV[0]
|
26
26
|
to_email = ARGV[1]
|
27
27
|
# set to the path to your config. file
|
28
28
|
config_file = '/home/ell/.s33r'
|
29
29
|
|
30
30
|
# load config. file
|
31
|
-
options =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
access_key, secret_key, options, custom = S33r::Client.load_config(config_file)
|
32
|
+
|
33
|
+
# bucket name to work with
|
34
|
+
bucket = options[:default_bucket]
|
35
|
+
|
36
|
+
puts "Using bucket: #{bucket}"
|
37
|
+
|
38
|
+
# email addresses
|
39
|
+
to_email = custom[:to_email]
|
40
|
+
from_email = custom[:from_email]
|
37
41
|
|
38
42
|
# expires can be a date/time string or 'forever';
|
39
43
|
# if not set, defaults to 15 minutes
|
40
|
-
expires = options[
|
44
|
+
expires = options[:default_expires]
|
41
45
|
base_expires = Time.now.to_i
|
42
46
|
if 'forever' == expires
|
43
47
|
# 20 years (same as forever in computer terms)
|
@@ -54,7 +58,7 @@ end
|
|
54
58
|
if !bucket
|
55
59
|
require 'readline'
|
56
60
|
bucket = Readline.readline('No bucket found; please enter name for new bucket: ', true)
|
57
|
-
client =
|
61
|
+
client = S33r::Client.new(access_key, secret_key)
|
58
62
|
response = client.create_bucket(bucket)
|
59
63
|
if response.ok?
|
60
64
|
puts 'Created new bucket'
|
@@ -64,6 +68,8 @@ if !bucket
|
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
71
|
+
options[:default_bucket] = bucket
|
72
|
+
|
67
73
|
# estimate upload time
|
68
74
|
filesize = FileTest.size(filename)
|
69
75
|
filesize_mb = (filesize / (1000*1000)).to_i
|
@@ -84,9 +90,11 @@ puts str
|
|
84
90
|
start_time_secs = Time.now.to_i
|
85
91
|
|
86
92
|
# a client pointing at the specified bucket
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
S33r::NamedBucket.new(access_key, secret_key, options) do |c|
|
94
|
+
|
95
|
+
response = c.put_file(filename)
|
96
|
+
|
97
|
+
url = c.authenticated_url(filename, expires)
|
90
98
|
|
91
99
|
time_taken_secs = Time.now.to_i - start_time_secs
|
92
100
|
puts "Aah, it appears to have taken %d seconds" % time_taken_secs
|
@@ -110,6 +118,7 @@ S3::NamedBucket.new(access_key, secret_key, bucket) do |c|
|
|
110
118
|
end
|
111
119
|
end
|
112
120
|
else
|
113
|
-
puts
|
121
|
+
puts "File transfer failed with response code #{response.code}"
|
114
122
|
end
|
115
|
-
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: MIME</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">MIME</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/s33r/mimetypes_rb.html">
|
59
|
+
lib/s33r/mimetypes.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
The namespace for <a href="MIME.html">MIME</a> applications, tools, and
|
78
|
+
libraries.
|
79
|
+
</p>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
<!-- if includes -->
|
91
|
+
|
92
|
+
<div id="section">
|
93
|
+
|
94
|
+
<div id="class-list">
|
95
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
96
|
+
|
97
|
+
Class <a href="MIME/InvalidContentType.html" class="link">MIME::InvalidContentType</a><br />
|
98
|
+
Class <a href="MIME/Type.html" class="link">MIME::Type</a><br />
|
99
|
+
Class <a href="MIME/Types.html" class="link">MIME::Types</a><br />
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if method_list -->
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
|
115
|
+
<div id="validator-badges">
|
116
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
</body>
|
120
|
+
</html>
|
@@ -0,0 +1,119 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: MIME::InvalidContentType</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">MIME::InvalidContentType</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/s33r/mimetypes_rb.html">
|
59
|
+
lib/s33r/mimetypes.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
RuntimeError
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
Reflects a <a href="../MIME.html">MIME</a> Content-<a
|
84
|
+
href="Type.html">Type</a> which is in invalid format (e.g., it isn’t
|
85
|
+
in the form of type/subtype).
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
<div id="validator-badges">
|
115
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
</body>
|
119
|
+
</html>
|
@@ -0,0 +1,1173 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: MIME::Type</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">MIME::Type</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/s33r/mimetypes_rb.html">
|
59
|
+
lib/s33r/mimetypes.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
The definition of one <a href="../MIME.html">MIME</a> content-type.
|
84
|
+
</p>
|
85
|
+
<h2>Usage</h2>
|
86
|
+
<pre>
|
87
|
+
require 'mime/types'
|
88
|
+
|
89
|
+
plaintext = MIME::Types['text/plain']
|
90
|
+
print plaintext.media_type # => 'text'
|
91
|
+
print plaintext.sub_type # => 'plain'
|
92
|
+
|
93
|
+
puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
|
94
|
+
|
95
|
+
puts plaintext.encoding # => 8bit
|
96
|
+
puts plaintext.binary? # => false
|
97
|
+
puts plaintext.ascii? # => true
|
98
|
+
puts plaintext == 'text/plain' # => true
|
99
|
+
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
100
|
+
</pre>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<div id="method-list">
|
108
|
+
<h3 class="section-bar">Methods</h3>
|
109
|
+
|
110
|
+
<div class="name-list">
|
111
|
+
<a href="#M000031">ascii?</a>
|
112
|
+
<a href="#M000030">binary?</a>
|
113
|
+
<a href="#M000035">complete?</a>
|
114
|
+
<a href="#M000019">default_encoding</a>
|
115
|
+
<a href="#M000022">docs=</a>
|
116
|
+
<a href="#M000025">from_array</a>
|
117
|
+
<a href="#M000026">from_hash</a>
|
118
|
+
<a href="#M000027">from_mime_type</a>
|
119
|
+
<a href="#M000018">like?</a>
|
120
|
+
<a href="#M000028">new</a>
|
121
|
+
<a href="#M000021">obsolete?</a>
|
122
|
+
<a href="#M000034">platform?</a>
|
123
|
+
<a href="#M000029">registered?</a>
|
124
|
+
<a href="#M000032">signature?</a>
|
125
|
+
<a href="#M000024">simplified</a>
|
126
|
+
<a href="#M000033">system?</a>
|
127
|
+
<a href="#M000038">to_a</a>
|
128
|
+
<a href="#M000039">to_hash</a>
|
129
|
+
<a href="#M000036">to_s</a>
|
130
|
+
<a href="#M000037">to_str</a>
|
131
|
+
<a href="#M000023">urls</a>
|
132
|
+
<a href="#M000020">use_instead</a>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
</div>
|
137
|
+
|
138
|
+
|
139
|
+
<!-- if includes -->
|
140
|
+
<div id="includes">
|
141
|
+
<h3 class="section-bar">Included Modules</h3>
|
142
|
+
|
143
|
+
<div id="includes-list">
|
144
|
+
<span class="include-name">Comparable</span>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
<div id="section">
|
149
|
+
|
150
|
+
|
151
|
+
<div id="constants-list">
|
152
|
+
<h3 class="section-bar">Constants</h3>
|
153
|
+
|
154
|
+
<div class="name-list">
|
155
|
+
<table summary="Constants">
|
156
|
+
<tr class="top-aligned-row context-row">
|
157
|
+
<td class="context-item-name">VERSION</td>
|
158
|
+
<td>=</td>
|
159
|
+
<td class="context-item-value">'1.15'</td>
|
160
|
+
</tr>
|
161
|
+
<tr class="top-aligned-row context-row">
|
162
|
+
<td class="context-item-name">IANA_URL</td>
|
163
|
+
<td>=</td>
|
164
|
+
<td class="context-item-value">"http://www.iana.org/assignments/media-types/%s/%s"</td>
|
165
|
+
</tr>
|
166
|
+
<tr class="top-aligned-row context-row">
|
167
|
+
<td class="context-item-name">RFC_URL</td>
|
168
|
+
<td>=</td>
|
169
|
+
<td class="context-item-value">"http://rfc-editor.org/rfc/rfc%s.txt"</td>
|
170
|
+
</tr>
|
171
|
+
<tr class="top-aligned-row context-row">
|
172
|
+
<td class="context-item-name">DRAFT_URL</td>
|
173
|
+
<td>=</td>
|
174
|
+
<td class="context-item-value">"http://datatracker.ietf.org/public/idindex.cgi?command=id_details&filename=%s"</td>
|
175
|
+
</tr>
|
176
|
+
<tr class="top-aligned-row context-row">
|
177
|
+
<td class="context-item-name">LTSW_URL</td>
|
178
|
+
<td>=</td>
|
179
|
+
<td class="context-item-value">"http://www.ltsw.se/knbase/internet/%s.htp"</td>
|
180
|
+
</tr>
|
181
|
+
<tr class="top-aligned-row context-row">
|
182
|
+
<td class="context-item-name">CONTACT_URL</td>
|
183
|
+
<td>=</td>
|
184
|
+
<td class="context-item-value">"http://www.iana.org/assignments/contact-people.htm#%s"</td>
|
185
|
+
</tr>
|
186
|
+
</table>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
<div id="attribute-list">
|
193
|
+
<h3 class="section-bar">Attributes</h3>
|
194
|
+
|
195
|
+
<div class="name-list">
|
196
|
+
<table>
|
197
|
+
<tr class="top-aligned-row context-row">
|
198
|
+
<td class="context-item-name">content_type</td>
|
199
|
+
<td class="context-item-value"> [R] </td>
|
200
|
+
<td class="context-item-desc">
|
201
|
+
Returns the whole <a href="../MIME.html">MIME</a> content-type string.
|
202
|
+
|
203
|
+
<pre>
|
204
|
+
text/plain => text/plain
|
205
|
+
x-chemical/x-pdb => x-chemical/x-pdb
|
206
|
+
</pre>
|
207
|
+
</td>
|
208
|
+
</tr>
|
209
|
+
<tr class="top-aligned-row context-row">
|
210
|
+
<td class="context-item-name">default_encoding</td>
|
211
|
+
<td class="context-item-value"> [R] </td>
|
212
|
+
<td class="context-item-desc">
|
213
|
+
Returns the default encoding for the <a href="Type.html">MIME::Type</a>
|
214
|
+
based on the media type.
|
215
|
+
|
216
|
+
</td>
|
217
|
+
</tr>
|
218
|
+
<tr class="top-aligned-row context-row">
|
219
|
+
<td class="context-item-name">docs</td>
|
220
|
+
<td class="context-item-value"> [RW] </td>
|
221
|
+
<td class="context-item-desc">
|
222
|
+
The documentation for this <a href="Type.html">MIME::Type</a>.
|
223
|
+
Documentation about media types will be found on a media type definition as
|
224
|
+
a comment. Documentation will be found through docs.
|
225
|
+
|
226
|
+
</td>
|
227
|
+
</tr>
|
228
|
+
<tr class="top-aligned-row context-row">
|
229
|
+
<td class="context-item-name">encoding</td>
|
230
|
+
<td class="context-item-value"> [RW] </td>
|
231
|
+
<td class="context-item-desc">
|
232
|
+
The encoding (7bit, 8bit, quoted-printable, or base64) required to
|
233
|
+
transport the data of this content type safely across a network, which
|
234
|
+
roughly corresponds to Content-Transfer-Encoding. A value of <tt>nil</tt>
|
235
|
+
or <tt>:default</tt> will reset the encoding to the <a
|
236
|
+
href="Type.html#M000019">default_encoding</a> for the <a
|
237
|
+
href="Type.html">MIME::Type</a>. Raises ArgumentError if the encoding
|
238
|
+
provided is invalid.
|
239
|
+
|
240
|
+
<p>
|
241
|
+
If the encoding is not provided on construction, this will be either
|
242
|
+
‘quoted-printable’ (for text/* media types) and
|
243
|
+
‘base64’ for eveything else.
|
244
|
+
</p>
|
245
|
+
</td>
|
246
|
+
</tr>
|
247
|
+
<tr class="top-aligned-row context-row">
|
248
|
+
<td class="context-item-name">extensions</td>
|
249
|
+
<td class="context-item-value"> [RW] </td>
|
250
|
+
<td class="context-item-desc">
|
251
|
+
The list of extensions which are known to be used for this <a
|
252
|
+
href="Type.html">MIME::Type</a>. Non-array values will be coerced into an
|
253
|
+
array with <a href="Type.html#M000038">to_a</a>. Array values will be
|
254
|
+
flattened and <tt>nil</tt> values removed.
|
255
|
+
|
256
|
+
</td>
|
257
|
+
</tr>
|
258
|
+
<tr class="top-aligned-row context-row">
|
259
|
+
<td class="context-item-name">media_type</td>
|
260
|
+
<td class="context-item-value"> [R] </td>
|
261
|
+
<td class="context-item-desc">
|
262
|
+
Returns the media type of the simplified <a href="../MIME.html">MIME</a>
|
263
|
+
type.
|
264
|
+
|
265
|
+
<pre>
|
266
|
+
text/plain => text
|
267
|
+
x-chemical/x-pdb => chemical
|
268
|
+
</pre>
|
269
|
+
</td>
|
270
|
+
</tr>
|
271
|
+
<tr class="top-aligned-row context-row">
|
272
|
+
<td class="context-item-name">obsolete</td>
|
273
|
+
<td class="context-item-value"> [W] </td>
|
274
|
+
<td class="context-item-desc">
|
275
|
+
Sets the obsolescence indicator for this media type.
|
276
|
+
|
277
|
+
</td>
|
278
|
+
</tr>
|
279
|
+
<tr class="top-aligned-row context-row">
|
280
|
+
<td class="context-item-name">raw_media_type</td>
|
281
|
+
<td class="context-item-value"> [R] </td>
|
282
|
+
<td class="context-item-desc">
|
283
|
+
Returns the media type of the unmodified <a href="../MIME.html">MIME</a>
|
284
|
+
type.
|
285
|
+
|
286
|
+
<pre>
|
287
|
+
text/plain => text
|
288
|
+
x-chemical/x-pdb => x-chemical
|
289
|
+
</pre>
|
290
|
+
</td>
|
291
|
+
</tr>
|
292
|
+
<tr class="top-aligned-row context-row">
|
293
|
+
<td class="context-item-name">raw_sub_type</td>
|
294
|
+
<td class="context-item-value"> [R] </td>
|
295
|
+
<td class="context-item-desc">
|
296
|
+
Returns the media type of the unmodified <a href="../MIME.html">MIME</a>
|
297
|
+
type.
|
298
|
+
|
299
|
+
<pre>
|
300
|
+
text/plain => plain
|
301
|
+
x-chemical/x-pdb => x-pdb
|
302
|
+
</pre>
|
303
|
+
</td>
|
304
|
+
</tr>
|
305
|
+
<tr class="top-aligned-row context-row">
|
306
|
+
<td class="context-item-name">simplified</td>
|
307
|
+
<td class="context-item-value"> [R] </td>
|
308
|
+
<td class="context-item-desc">
|
309
|
+
The <a href="../MIME.html">MIME</a> types main- and sub-label can both
|
310
|
+
start with <tt>x-</tt>, which indicates that it is a non-registered name.
|
311
|
+
Of course, after registration this flag can disappear, adds to the
|
312
|
+
confusing proliferation of <a href="../MIME.html">MIME</a> types. The
|
313
|
+
simplified string has the <tt>x-</tt> removed and are translated to
|
314
|
+
lowercase.
|
315
|
+
|
316
|
+
<pre>
|
317
|
+
text/plain => text/plain
|
318
|
+
x-chemical/x-pdb => chemical/pdb
|
319
|
+
</pre>
|
320
|
+
</td>
|
321
|
+
</tr>
|
322
|
+
<tr class="top-aligned-row context-row">
|
323
|
+
<td class="context-item-name">sub_type</td>
|
324
|
+
<td class="context-item-value"> [R] </td>
|
325
|
+
<td class="context-item-desc">
|
326
|
+
Returns the sub-type of the simplified <a href="../MIME.html">MIME</a>
|
327
|
+
type.
|
328
|
+
|
329
|
+
<pre>
|
330
|
+
text/plain => plain
|
331
|
+
x-chemical/x-pdb => pdb
|
332
|
+
</pre>
|
333
|
+
</td>
|
334
|
+
</tr>
|
335
|
+
<tr class="top-aligned-row context-row">
|
336
|
+
<td class="context-item-name">system</td>
|
337
|
+
<td class="context-item-value"> [RW] </td>
|
338
|
+
<td class="context-item-desc">
|
339
|
+
The regexp for the operating system that this <a
|
340
|
+
href="Type.html">MIME::Type</a> is specific to.
|
341
|
+
|
342
|
+
</td>
|
343
|
+
</tr>
|
344
|
+
<tr class="top-aligned-row context-row">
|
345
|
+
<td class="context-item-name">url</td>
|
346
|
+
<td class="context-item-value"> [RW] </td>
|
347
|
+
<td class="context-item-desc">
|
348
|
+
The encoded URL list for this <a href="Type.html">MIME::Type</a>. See <a
|
349
|
+
href="Type.html#M000023">urls</a> for
|
350
|
+
|
351
|
+
</td>
|
352
|
+
</tr>
|
353
|
+
<tr class="top-aligned-row context-row">
|
354
|
+
<td class="context-item-name">use_instead</td>
|
355
|
+
<td class="context-item-value"> [R] </td>
|
356
|
+
<td class="context-item-desc">
|
357
|
+
Returns the media type or types that should be used instead of this media
|
358
|
+
type, if it is obsolete. If there is no replacement media type, or it is
|
359
|
+
not obsolete, <tt>nil</tt> will be returned.
|
360
|
+
|
361
|
+
</td>
|
362
|
+
</tr>
|
363
|
+
</table>
|
364
|
+
</div>
|
365
|
+
</div>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
<!-- if method_list -->
|
370
|
+
<div id="methods">
|
371
|
+
<h3 class="section-bar">Public Class methods</h3>
|
372
|
+
|
373
|
+
<div id="method-M000025" class="method-detail">
|
374
|
+
<a name="M000025"></a>
|
375
|
+
|
376
|
+
<div class="method-heading">
|
377
|
+
<a href="#M000025" class="method-signature">
|
378
|
+
<span class="method-name">from_array</span><span class="method-args">(*args) {|m if block_given?| ...}</span>
|
379
|
+
</a>
|
380
|
+
</div>
|
381
|
+
|
382
|
+
<div class="method-description">
|
383
|
+
<p>
|
384
|
+
Creates a <a href="Type.html">MIME::Type</a> from an array in the form of:
|
385
|
+
</p>
|
386
|
+
<pre>
|
387
|
+
[type-name, [extensions], encoding, system]
|
388
|
+
</pre>
|
389
|
+
<p>
|
390
|
+
<tt>extensions</tt>, <tt>encoding</tt>, and <tt>system</tt> are optional.
|
391
|
+
</p>
|
392
|
+
<pre>
|
393
|
+
MIME::Type.from_array("application/x-ruby", ['rb'], '8bit')
|
394
|
+
MIME::Type.from_array(["application/x-ruby", ['rb'], '8bit'])
|
395
|
+
</pre>
|
396
|
+
<p>
|
397
|
+
These are equivalent to:
|
398
|
+
</p>
|
399
|
+
<pre>
|
400
|
+
MIME::Type.new('application/x-ruby') do |t|
|
401
|
+
t.extensions = %w(rb)
|
402
|
+
t.encoding = '8bit'
|
403
|
+
end
|
404
|
+
</pre>
|
405
|
+
<p><a class="source-toggle" href="#"
|
406
|
+
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
407
|
+
<div class="method-source-code" id="M000025-source">
|
408
|
+
<pre>
|
409
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 276</span>
|
410
|
+
276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_array</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-comment cmt">#:yields MIME::Type.new:</span>
|
411
|
+
277: <span class="ruby-comment cmt"># Dereferences the array one level, if necessary.</span>
|
412
|
+
278: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
|
413
|
+
279:
|
414
|
+
280: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-value">1</span>, <span class="ruby-value">8</span>)
|
415
|
+
281: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
416
|
+
282: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
417
|
+
283: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">2</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">2</span>
|
418
|
+
284: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">3</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">3</span>
|
419
|
+
285: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">obsolete</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">4</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">4</span>
|
420
|
+
286: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">docs</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">5</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">5</span>
|
421
|
+
287: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">url</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">6</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">6</span>
|
422
|
+
288: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">7</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">7</span>
|
423
|
+
289: <span class="ruby-keyword kw">end</span>
|
424
|
+
290: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
425
|
+
291: <span class="ruby-keyword kw">else</span>
|
426
|
+
292: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Array provided must contain between one and eight elements."</span>
|
427
|
+
293: <span class="ruby-keyword kw">end</span>
|
428
|
+
294: <span class="ruby-identifier">m</span>
|
429
|
+
295: <span class="ruby-keyword kw">end</span>
|
430
|
+
</pre>
|
431
|
+
</div>
|
432
|
+
</div>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
<div id="method-M000026" class="method-detail">
|
436
|
+
<a name="M000026"></a>
|
437
|
+
|
438
|
+
<div class="method-heading">
|
439
|
+
<a href="#M000026" class="method-signature">
|
440
|
+
<span class="method-name">from_hash</span><span class="method-args">(hash) {|m if block_given?| ...}</span>
|
441
|
+
</a>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div class="method-description">
|
445
|
+
<p>
|
446
|
+
Creates a <a href="Type.html">MIME::Type</a> from a hash. Keys are
|
447
|
+
case-insensitive, dashes may be replaced with underscores, and the internal
|
448
|
+
Symbol of the lowercase-underscore version can be used as well. That is,
|
449
|
+
Content-<a href="Type.html">Type</a> can be provided as content-type,
|
450
|
+
Content_Type, content_type, or :content_type.
|
451
|
+
</p>
|
452
|
+
<p>
|
453
|
+
Known keys are <tt>Content-<a href="Type.html">Type</a></tt>,
|
454
|
+
<tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
|
455
|
+
<tt>System</tt>.
|
456
|
+
</p>
|
457
|
+
<pre>
|
458
|
+
MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
|
459
|
+
'Content-Transfer-Encoding' => '8bit',
|
460
|
+
'System' => 'linux',
|
461
|
+
'Extensions' => ['yaml', 'yml'])
|
462
|
+
</pre>
|
463
|
+
<p>
|
464
|
+
This is equivalent to:
|
465
|
+
</p>
|
466
|
+
<pre>
|
467
|
+
MIME::Type.new('text/x-yaml') do |t|
|
468
|
+
t.encoding = '8bit'
|
469
|
+
t.system = 'linux'
|
470
|
+
t.extensions = ['yaml', 'yml']
|
471
|
+
end
|
472
|
+
</pre>
|
473
|
+
<p><a class="source-toggle" href="#"
|
474
|
+
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
475
|
+
<div class="method-source-code" id="M000026-source">
|
476
|
+
<pre>
|
477
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 319</span>
|
478
|
+
319: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_hash</span>(<span class="ruby-identifier">hash</span>) <span class="ruby-comment cmt">#:yields MIME::Type.new:</span>
|
479
|
+
320: <span class="ruby-identifier">type</span> = {}
|
480
|
+
321: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
481
|
+
322: <span class="ruby-identifier">type</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'-A-Z'</span>, <span class="ruby-value str">'_a-z'</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">v</span>
|
482
|
+
323: <span class="ruby-keyword kw">end</span>
|
483
|
+
324:
|
484
|
+
325: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">type</span>[<span class="ruby-identifier">:content_type</span>]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
485
|
+
326: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:extensions</span>]
|
486
|
+
327: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:content_transfer_encoding</span>]
|
487
|
+
328: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:system</span>]
|
488
|
+
329: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">obsolete</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:obsolete</span>]
|
489
|
+
330: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">docs</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:docs</span>]
|
490
|
+
331: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">url</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:url</span>]
|
491
|
+
332: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:registered</span>]
|
492
|
+
333: <span class="ruby-keyword kw">end</span>
|
493
|
+
334:
|
494
|
+
335: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
495
|
+
336: <span class="ruby-identifier">m</span>
|
496
|
+
337: <span class="ruby-keyword kw">end</span>
|
497
|
+
</pre>
|
498
|
+
</div>
|
499
|
+
</div>
|
500
|
+
</div>
|
501
|
+
|
502
|
+
<div id="method-M000027" class="method-detail">
|
503
|
+
<a name="M000027"></a>
|
504
|
+
|
505
|
+
<div class="method-heading">
|
506
|
+
<a href="#M000027" class="method-signature">
|
507
|
+
<span class="method-name">from_mime_type</span><span class="method-args">(mime_type) {|m if block_given?| ...}</span>
|
508
|
+
</a>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<div class="method-description">
|
512
|
+
<p>
|
513
|
+
Essentially a copy constructor.
|
514
|
+
</p>
|
515
|
+
<pre>
|
516
|
+
MIME::Type.from_mime_type(plaintext)
|
517
|
+
</pre>
|
518
|
+
<p>
|
519
|
+
is equivalent to:
|
520
|
+
</p>
|
521
|
+
<pre>
|
522
|
+
MIME::Type.new(plaintext.content_type.dup) do |t|
|
523
|
+
t.extensions = plaintext.extensions.dup
|
524
|
+
t.system = plaintext.system.dup
|
525
|
+
t.encoding = plaintext.encoding.dup
|
526
|
+
end
|
527
|
+
</pre>
|
528
|
+
<p><a class="source-toggle" href="#"
|
529
|
+
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
530
|
+
<div class="method-source-code" id="M000027-source">
|
531
|
+
<pre>
|
532
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 350</span>
|
533
|
+
350: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_mime_type</span>(<span class="ruby-identifier">mime_type</span>) <span class="ruby-comment cmt">#:yields the new MIME::Type:</span>
|
534
|
+
351: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">dup</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
535
|
+
352: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">extensions</span>.<span class="ruby-identifier">dup</span>
|
536
|
+
353: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">system</span>.<span class="ruby-identifier">dup</span>
|
537
|
+
354: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">encoding</span>.<span class="ruby-identifier">dup</span>
|
538
|
+
355: <span class="ruby-keyword kw">end</span>
|
539
|
+
356:
|
540
|
+
357: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
541
|
+
358: <span class="ruby-keyword kw">end</span>
|
542
|
+
</pre>
|
543
|
+
</div>
|
544
|
+
</div>
|
545
|
+
</div>
|
546
|
+
|
547
|
+
<div id="method-M000028" class="method-detail">
|
548
|
+
<a name="M000028"></a>
|
549
|
+
|
550
|
+
<div class="method-heading">
|
551
|
+
<a href="#M000028" class="method-signature">
|
552
|
+
<span class="method-name">new</span><span class="method-args">(content_type) {|self if block_given?| ...}</span>
|
553
|
+
</a>
|
554
|
+
</div>
|
555
|
+
|
556
|
+
<div class="method-description">
|
557
|
+
<p>
|
558
|
+
Builds a <a href="Type.html">MIME::Type</a> object from the provided <a
|
559
|
+
href="../MIME.html">MIME</a> Content <a href="Type.html">Type</a> value
|
560
|
+
(e.g., ‘text/plain’ or ‘applicaton/x-eruby’). The
|
561
|
+
constructed object is yielded to an optional block for additional
|
562
|
+
configuration, such as associating extensions and encoding information.
|
563
|
+
</p>
|
564
|
+
<p><a class="source-toggle" href="#"
|
565
|
+
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
566
|
+
<div class="method-source-code" id="M000028-source">
|
567
|
+
<pre>
|
568
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 365</span>
|
569
|
+
365: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">content_type</span>) <span class="ruby-comment cmt">#:yields self:</span>
|
570
|
+
366: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content_type</span>)
|
571
|
+
367:
|
572
|
+
368: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">nil?</span>
|
573
|
+
369: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidContentType</span>, <span class="ruby-node">"Invalid Content-Type provided ('#{content_type}')"</span>
|
574
|
+
370: <span class="ruby-keyword kw">end</span>
|
575
|
+
371:
|
576
|
+
372: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">content_type</span>
|
577
|
+
373: <span class="ruby-ivar">@raw_media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
|
578
|
+
374: <span class="ruby-ivar">@raw_sub_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>]
|
579
|
+
375:
|
580
|
+
376: <span class="ruby-ivar">@simplified</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">simplified</span>(<span class="ruby-ivar">@content_type</span>)
|
581
|
+
377: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@simplified</span>)
|
582
|
+
378: <span class="ruby-ivar">@media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
|
583
|
+
379: <span class="ruby-ivar">@sub_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>]
|
584
|
+
380:
|
585
|
+
381: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-keyword kw">nil</span>
|
586
|
+
382: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">:default</span>
|
587
|
+
383: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">system</span> = <span class="ruby-keyword kw">nil</span>
|
588
|
+
384: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-keyword kw">true</span>
|
589
|
+
385:
|
590
|
+
386: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
591
|
+
387: <span class="ruby-keyword kw">end</span>
|
592
|
+
</pre>
|
593
|
+
</div>
|
594
|
+
</div>
|
595
|
+
</div>
|
596
|
+
|
597
|
+
<div id="method-M000024" class="method-detail">
|
598
|
+
<a name="M000024"></a>
|
599
|
+
|
600
|
+
<div class="method-heading">
|
601
|
+
<a href="#M000024" class="method-signature">
|
602
|
+
<span class="method-name">simplified</span><span class="method-args">(content_type)</span>
|
603
|
+
</a>
|
604
|
+
</div>
|
605
|
+
|
606
|
+
<div class="method-description">
|
607
|
+
<p>
|
608
|
+
The <a href="../MIME.html">MIME</a> types main- and sub-label can both
|
609
|
+
start with <tt>x-</tt>, which indicates that it is a non-registered name.
|
610
|
+
Of course, after registration this flag can disappear, adds to the
|
611
|
+
confusing proliferation of <a href="../MIME.html">MIME</a> types. The
|
612
|
+
simplified string has the <tt>x-</tt> removed and are translated to
|
613
|
+
lowercase.
|
614
|
+
</p>
|
615
|
+
<p><a class="source-toggle" href="#"
|
616
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
617
|
+
<div class="method-source-code" id="M000024-source">
|
618
|
+
<pre>
|
619
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 249</span>
|
620
|
+
249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simplified</span>(<span class="ruby-identifier">content_type</span>)
|
621
|
+
250: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content_type</span>)
|
622
|
+
251:
|
623
|
+
252: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">nil?</span>
|
624
|
+
253: <span class="ruby-identifier">simplified</span> = <span class="ruby-keyword kw">nil</span>
|
625
|
+
254: <span class="ruby-keyword kw">else</span>
|
626
|
+
255: <span class="ruby-identifier">media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">UNREG_RE</span>, <span class="ruby-value str">''</span>)
|
627
|
+
256: <span class="ruby-identifier">subtype</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">UNREG_RE</span>, <span class="ruby-value str">''</span>)
|
628
|
+
257: <span class="ruby-identifier">simplified</span> = <span class="ruby-node">"#{media_type}/#{subtype}"</span>
|
629
|
+
258: <span class="ruby-keyword kw">end</span>
|
630
|
+
259: <span class="ruby-identifier">simplified</span>
|
631
|
+
260: <span class="ruby-keyword kw">end</span>
|
632
|
+
</pre>
|
633
|
+
</div>
|
634
|
+
</div>
|
635
|
+
</div>
|
636
|
+
|
637
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
638
|
+
|
639
|
+
<div id="method-M000031" class="method-detail">
|
640
|
+
<a name="M000031"></a>
|
641
|
+
|
642
|
+
<div class="method-heading">
|
643
|
+
<a href="#M000031" class="method-signature">
|
644
|
+
<span class="method-name">ascii?</span><span class="method-args">()</span>
|
645
|
+
</a>
|
646
|
+
</div>
|
647
|
+
|
648
|
+
<div class="method-description">
|
649
|
+
<p>
|
650
|
+
<a href="../MIME.html">MIME</a> types can be specified to be sent across a
|
651
|
+
network in particular formats. This method returns <tt>false</tt> when the
|
652
|
+
<a href="../MIME.html">MIME</a> type encoding is set to <tt>base64</tt>.
|
653
|
+
</p>
|
654
|
+
<p><a class="source-toggle" href="#"
|
655
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
656
|
+
<div class="method-source-code" id="M000031-source">
|
657
|
+
<pre>
|
658
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 413</span>
|
659
|
+
413: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ascii?</span>
|
660
|
+
414: <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">binary?</span>
|
661
|
+
415: <span class="ruby-keyword kw">end</span>
|
662
|
+
</pre>
|
663
|
+
</div>
|
664
|
+
</div>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
<div id="method-M000030" class="method-detail">
|
668
|
+
<a name="M000030"></a>
|
669
|
+
|
670
|
+
<div class="method-heading">
|
671
|
+
<a href="#M000030" class="method-signature">
|
672
|
+
<span class="method-name">binary?</span><span class="method-args">()</span>
|
673
|
+
</a>
|
674
|
+
</div>
|
675
|
+
|
676
|
+
<div class="method-description">
|
677
|
+
<p>
|
678
|
+
<a href="../MIME.html">MIME</a> types can be specified to be sent across a
|
679
|
+
network in particular formats. This method returns <tt>true</tt> when the
|
680
|
+
<a href="../MIME.html">MIME</a> type encoding is set to <tt>base64</tt>.
|
681
|
+
</p>
|
682
|
+
<p><a class="source-toggle" href="#"
|
683
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
684
|
+
<div class="method-source-code" id="M000030-source">
|
685
|
+
<pre>
|
686
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 406</span>
|
687
|
+
406: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">binary?</span>
|
688
|
+
407: <span class="ruby-ivar">@encoding</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'base64'</span>
|
689
|
+
408: <span class="ruby-keyword kw">end</span>
|
690
|
+
</pre>
|
691
|
+
</div>
|
692
|
+
</div>
|
693
|
+
</div>
|
694
|
+
|
695
|
+
<div id="method-M000035" class="method-detail">
|
696
|
+
<a name="M000035"></a>
|
697
|
+
|
698
|
+
<div class="method-heading">
|
699
|
+
<a href="#M000035" class="method-signature">
|
700
|
+
<span class="method-name">complete?</span><span class="method-args">()</span>
|
701
|
+
</a>
|
702
|
+
</div>
|
703
|
+
|
704
|
+
<div class="method-description">
|
705
|
+
<p>
|
706
|
+
Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> specifies
|
707
|
+
an extension list, indicating that it is a complete <a
|
708
|
+
href="Type.html">MIME::Type</a>.
|
709
|
+
</p>
|
710
|
+
<p><a class="source-toggle" href="#"
|
711
|
+
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
712
|
+
<div class="method-source-code" id="M000035-source">
|
713
|
+
<pre>
|
714
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 436</span>
|
715
|
+
436: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">complete?</span>
|
716
|
+
437: <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@extensions</span>.<span class="ruby-identifier">empty?</span>
|
717
|
+
438: <span class="ruby-keyword kw">end</span>
|
718
|
+
</pre>
|
719
|
+
</div>
|
720
|
+
</div>
|
721
|
+
</div>
|
722
|
+
|
723
|
+
<div id="method-M000019" class="method-detail">
|
724
|
+
<a name="M000019"></a>
|
725
|
+
|
726
|
+
<div class="method-heading">
|
727
|
+
<a href="#M000019" class="method-signature">
|
728
|
+
<span class="method-name">default_encoding</span><span class="method-args">()</span>
|
729
|
+
</a>
|
730
|
+
</div>
|
731
|
+
|
732
|
+
<div class="method-description">
|
733
|
+
<p><a class="source-toggle" href="#"
|
734
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
735
|
+
<div class="method-source-code" id="M000019-source">
|
736
|
+
<pre>
|
737
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 165</span>
|
738
|
+
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_encoding</span>
|
739
|
+
166: (<span class="ruby-ivar">@media_type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'text'</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">'quoted-printable'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'base64'</span>
|
740
|
+
167: <span class="ruby-keyword kw">end</span>
|
741
|
+
</pre>
|
742
|
+
</div>
|
743
|
+
</div>
|
744
|
+
</div>
|
745
|
+
|
746
|
+
<div id="method-M000022" class="method-detail">
|
747
|
+
<a name="M000022"></a>
|
748
|
+
|
749
|
+
<div class="method-heading">
|
750
|
+
<a href="#M000022" class="method-signature">
|
751
|
+
<span class="method-name">docs=</span><span class="method-args">(d)</span>
|
752
|
+
</a>
|
753
|
+
</div>
|
754
|
+
|
755
|
+
<div class="method-description">
|
756
|
+
<p><a class="source-toggle" href="#"
|
757
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
758
|
+
<div class="method-source-code" id="M000022-source">
|
759
|
+
<pre>
|
760
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 191</span>
|
761
|
+
191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">docs=</span>(<span class="ruby-identifier">d</span>)
|
762
|
+
192: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">d</span>
|
763
|
+
193: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-node">%r{use-instead:#{MEDIA_TYPE_RE}}</span>)
|
764
|
+
194:
|
765
|
+
195: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">empty?</span>
|
766
|
+
196: <span class="ruby-ivar">@use_instead</span> = <span class="ruby-keyword kw">nil</span>
|
767
|
+
197: <span class="ruby-keyword kw">else</span>
|
768
|
+
198: <span class="ruby-ivar">@use_instead</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">el</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{el[0]}/#{el[1]}"</span> }
|
769
|
+
199: <span class="ruby-keyword kw">end</span>
|
770
|
+
200: <span class="ruby-keyword kw">end</span>
|
771
|
+
201: <span class="ruby-keyword kw">end</span>
|
772
|
+
</pre>
|
773
|
+
</div>
|
774
|
+
</div>
|
775
|
+
</div>
|
776
|
+
|
777
|
+
<div id="method-M000018" class="method-detail">
|
778
|
+
<a name="M000018"></a>
|
779
|
+
|
780
|
+
<div class="method-heading">
|
781
|
+
<a href="#M000018" class="method-signature">
|
782
|
+
<span class="method-name">like?</span><span class="method-args">(other)</span>
|
783
|
+
</a>
|
784
|
+
</div>
|
785
|
+
|
786
|
+
<div class="method-description">
|
787
|
+
<p>
|
788
|
+
Returns <tt>true</tt> if the simplified type matches the current
|
789
|
+
</p>
|
790
|
+
<p><a class="source-toggle" href="#"
|
791
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
792
|
+
<div class="method-source-code" id="M000018-source">
|
793
|
+
<pre>
|
794
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 58</span>
|
795
|
+
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">like?</span>(<span class="ruby-identifier">other</span>)
|
796
|
+
59: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:simplified</span>)
|
797
|
+
60: <span class="ruby-ivar">@simplified</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">simplified</span>
|
798
|
+
61: <span class="ruby-keyword kw">else</span>
|
799
|
+
62: <span class="ruby-ivar">@simplified</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">simplified</span>(<span class="ruby-identifier">other</span>)
|
800
|
+
63: <span class="ruby-keyword kw">end</span>
|
801
|
+
64: <span class="ruby-keyword kw">end</span>
|
802
|
+
</pre>
|
803
|
+
</div>
|
804
|
+
</div>
|
805
|
+
</div>
|
806
|
+
|
807
|
+
<div id="method-M000021" class="method-detail">
|
808
|
+
<a name="M000021"></a>
|
809
|
+
|
810
|
+
<div class="method-heading">
|
811
|
+
<a href="#M000021" class="method-signature">
|
812
|
+
<span class="method-name">obsolete?</span><span class="method-args">()</span>
|
813
|
+
</a>
|
814
|
+
</div>
|
815
|
+
|
816
|
+
<div class="method-description">
|
817
|
+
<p>
|
818
|
+
Returns <tt>true</tt> if the media type is obsolete.
|
819
|
+
</p>
|
820
|
+
<p><a class="source-toggle" href="#"
|
821
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
822
|
+
<div class="method-source-code" id="M000021-source">
|
823
|
+
<pre>
|
824
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 180</span>
|
825
|
+
180: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">obsolete?</span>
|
826
|
+
181: <span class="ruby-ivar">@obsolete</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
827
|
+
182: <span class="ruby-keyword kw">end</span>
|
828
|
+
</pre>
|
829
|
+
</div>
|
830
|
+
</div>
|
831
|
+
</div>
|
832
|
+
|
833
|
+
<div id="method-M000034" class="method-detail">
|
834
|
+
<a name="M000034"></a>
|
835
|
+
|
836
|
+
<div class="method-heading">
|
837
|
+
<a href="#M000034" class="method-signature">
|
838
|
+
<span class="method-name">platform?</span><span class="method-args">()</span>
|
839
|
+
</a>
|
840
|
+
</div>
|
841
|
+
|
842
|
+
<div class="method-description">
|
843
|
+
<p>
|
844
|
+
Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> is specific
|
845
|
+
to the current operating system as represented by RUBY_PLATFORM.
|
846
|
+
</p>
|
847
|
+
<p><a class="source-toggle" href="#"
|
848
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
849
|
+
<div class="method-source-code" id="M000034-source">
|
850
|
+
<pre>
|
851
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 430</span>
|
852
|
+
430: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">platform?</span>
|
853
|
+
431: <span class="ruby-identifier">system?</span> <span class="ruby-keyword kw">and</span> (<span class="ruby-constant">RUBY_PLATFORM</span> <span class="ruby-operator">=~</span> <span class="ruby-ivar">@system</span>)
|
854
|
+
432: <span class="ruby-keyword kw">end</span>
|
855
|
+
</pre>
|
856
|
+
</div>
|
857
|
+
</div>
|
858
|
+
</div>
|
859
|
+
|
860
|
+
<div id="method-M000029" class="method-detail">
|
861
|
+
<a name="M000029"></a>
|
862
|
+
|
863
|
+
<div class="method-heading">
|
864
|
+
<a href="#M000029" class="method-signature">
|
865
|
+
<span class="method-name">registered?</span><span class="method-args">()</span>
|
866
|
+
</a>
|
867
|
+
</div>
|
868
|
+
|
869
|
+
<div class="method-description">
|
870
|
+
<p>
|
871
|
+
<a href="../MIME.html">MIME</a> content-types which are not regestered by
|
872
|
+
IANA nor defined in RFCs are required to start with <tt>x-</tt>. This
|
873
|
+
counts as well for a new media type as well as a new sub-type of an
|
874
|
+
existing media type. If either the media-type or the content-type begins
|
875
|
+
with <tt>x-</tt>, this method will return <tt>false</tt>.
|
876
|
+
</p>
|
877
|
+
<p><a class="source-toggle" href="#"
|
878
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
879
|
+
<div class="method-source-code" id="M000029-source">
|
880
|
+
<pre>
|
881
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 394</span>
|
882
|
+
394: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">registered?</span>
|
883
|
+
395: <span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@raw_media_type</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">UNREG_RE</span>) <span class="ruby-operator">||</span> (<span class="ruby-ivar">@raw_sub_type</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">UNREG_RE</span>)
|
884
|
+
396: <span class="ruby-keyword kw">false</span>
|
885
|
+
397: <span class="ruby-keyword kw">else</span>
|
886
|
+
398: <span class="ruby-ivar">@registered</span>
|
887
|
+
399: <span class="ruby-keyword kw">end</span>
|
888
|
+
400: <span class="ruby-keyword kw">end</span>
|
889
|
+
</pre>
|
890
|
+
</div>
|
891
|
+
</div>
|
892
|
+
</div>
|
893
|
+
|
894
|
+
<div id="method-M000032" class="method-detail">
|
895
|
+
<a name="M000032"></a>
|
896
|
+
|
897
|
+
<div class="method-heading">
|
898
|
+
<a href="#M000032" class="method-signature">
|
899
|
+
<span class="method-name">signature?</span><span class="method-args">()</span>
|
900
|
+
</a>
|
901
|
+
</div>
|
902
|
+
|
903
|
+
<div class="method-description">
|
904
|
+
<p>
|
905
|
+
Returns <tt>true</tt> when the simplified <a href="../MIME.html">MIME</a>
|
906
|
+
type is in the list of known digital signatures.
|
907
|
+
</p>
|
908
|
+
<p><a class="source-toggle" href="#"
|
909
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
910
|
+
<div class="method-source-code" id="M000032-source">
|
911
|
+
<pre>
|
912
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 419</span>
|
913
|
+
419: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">signature?</span>
|
914
|
+
420: <span class="ruby-constant">SIGNATURES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@simplified</span>.<span class="ruby-identifier">downcase</span>)
|
915
|
+
421: <span class="ruby-keyword kw">end</span>
|
916
|
+
</pre>
|
917
|
+
</div>
|
918
|
+
</div>
|
919
|
+
</div>
|
920
|
+
|
921
|
+
<div id="method-M000033" class="method-detail">
|
922
|
+
<a name="M000033"></a>
|
923
|
+
|
924
|
+
<div class="method-heading">
|
925
|
+
<a href="#M000033" class="method-signature">
|
926
|
+
<span class="method-name">system?</span><span class="method-args">()</span>
|
927
|
+
</a>
|
928
|
+
</div>
|
929
|
+
|
930
|
+
<div class="method-description">
|
931
|
+
<p>
|
932
|
+
Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> is specific
|
933
|
+
to an operating system.
|
934
|
+
</p>
|
935
|
+
<p><a class="source-toggle" href="#"
|
936
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
937
|
+
<div class="method-source-code" id="M000033-source">
|
938
|
+
<pre>
|
939
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 424</span>
|
940
|
+
424: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">system?</span>
|
941
|
+
425: <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@system</span>.<span class="ruby-identifier">nil?</span>
|
942
|
+
426: <span class="ruby-keyword kw">end</span>
|
943
|
+
</pre>
|
944
|
+
</div>
|
945
|
+
</div>
|
946
|
+
</div>
|
947
|
+
|
948
|
+
<div id="method-M000038" class="method-detail">
|
949
|
+
<a name="M000038"></a>
|
950
|
+
|
951
|
+
<div class="method-heading">
|
952
|
+
<a href="#M000038" class="method-signature">
|
953
|
+
<span class="method-name">to_a</span><span class="method-args">()</span>
|
954
|
+
</a>
|
955
|
+
</div>
|
956
|
+
|
957
|
+
<div class="method-description">
|
958
|
+
<p>
|
959
|
+
Returns the <a href="../MIME.html">MIME</a> type as an array suitable for
|
960
|
+
use with <a href="Type.html#M000025">MIME::Type.from_array</a>.
|
961
|
+
</p>
|
962
|
+
<p><a class="source-toggle" href="#"
|
963
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
964
|
+
<div class="method-source-code" id="M000038-source">
|
965
|
+
<pre>
|
966
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 452</span>
|
967
|
+
452: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_a</span>
|
968
|
+
453: [ <span class="ruby-ivar">@content_type</span>, <span class="ruby-ivar">@extensions</span>, <span class="ruby-ivar">@encoding</span>, <span class="ruby-ivar">@system</span>, <span class="ruby-ivar">@obsolete</span>, <span class="ruby-ivar">@docs</span>,
|
969
|
+
454: <span class="ruby-ivar">@url</span>, <span class="ruby-identifier">registered?</span> ]
|
970
|
+
455: <span class="ruby-keyword kw">end</span>
|
971
|
+
</pre>
|
972
|
+
</div>
|
973
|
+
</div>
|
974
|
+
</div>
|
975
|
+
|
976
|
+
<div id="method-M000039" class="method-detail">
|
977
|
+
<a name="M000039"></a>
|
978
|
+
|
979
|
+
<div class="method-heading">
|
980
|
+
<a href="#M000039" class="method-signature">
|
981
|
+
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
982
|
+
</a>
|
983
|
+
</div>
|
984
|
+
|
985
|
+
<div class="method-description">
|
986
|
+
<p>
|
987
|
+
Returns the <a href="../MIME.html">MIME</a> type as an array suitable for
|
988
|
+
use with <a href="Type.html#M000026">MIME::Type.from_hash</a>.
|
989
|
+
</p>
|
990
|
+
<p><a class="source-toggle" href="#"
|
991
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
992
|
+
<div class="method-source-code" id="M000039-source">
|
993
|
+
<pre>
|
994
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 459</span>
|
995
|
+
459: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
996
|
+
460: { <span class="ruby-value str">'Content-Type'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@content_type</span>,
|
997
|
+
461: <span class="ruby-value str">'Content-Transfer-Encoding'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@encoding</span>,
|
998
|
+
462: <span class="ruby-value str">'Extensions'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@extensions</span>,
|
999
|
+
463: <span class="ruby-value str">'System'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@system</span>,
|
1000
|
+
464: <span class="ruby-value str">'Obsolete'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@obsolete</span>,
|
1001
|
+
465: <span class="ruby-value str">'Docs'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@docs</span>,
|
1002
|
+
466: <span class="ruby-value str">'URL'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@url</span>,
|
1003
|
+
467: <span class="ruby-value str">'Registered'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">registered?</span>,
|
1004
|
+
468: }
|
1005
|
+
469: <span class="ruby-keyword kw">end</span>
|
1006
|
+
</pre>
|
1007
|
+
</div>
|
1008
|
+
</div>
|
1009
|
+
</div>
|
1010
|
+
|
1011
|
+
<div id="method-M000036" class="method-detail">
|
1012
|
+
<a name="M000036"></a>
|
1013
|
+
|
1014
|
+
<div class="method-heading">
|
1015
|
+
<a href="#M000036" class="method-signature">
|
1016
|
+
<span class="method-name">to_s</span><span class="method-args">()</span>
|
1017
|
+
</a>
|
1018
|
+
</div>
|
1019
|
+
|
1020
|
+
<div class="method-description">
|
1021
|
+
<p>
|
1022
|
+
Returns the <a href="../MIME.html">MIME</a> type as a string.
|
1023
|
+
</p>
|
1024
|
+
<p><a class="source-toggle" href="#"
|
1025
|
+
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
1026
|
+
<div class="method-source-code" id="M000036-source">
|
1027
|
+
<pre>
|
1028
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 441</span>
|
1029
|
+
441: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
1030
|
+
442: <span class="ruby-ivar">@content_type</span>
|
1031
|
+
443: <span class="ruby-keyword kw">end</span>
|
1032
|
+
</pre>
|
1033
|
+
</div>
|
1034
|
+
</div>
|
1035
|
+
</div>
|
1036
|
+
|
1037
|
+
<div id="method-M000037" class="method-detail">
|
1038
|
+
<a name="M000037"></a>
|
1039
|
+
|
1040
|
+
<div class="method-heading">
|
1041
|
+
<a href="#M000037" class="method-signature">
|
1042
|
+
<span class="method-name">to_str</span><span class="method-args">()</span>
|
1043
|
+
</a>
|
1044
|
+
</div>
|
1045
|
+
|
1046
|
+
<div class="method-description">
|
1047
|
+
<p>
|
1048
|
+
Returns the <a href="../MIME.html">MIME</a> type as a string for implicit
|
1049
|
+
conversions.
|
1050
|
+
</p>
|
1051
|
+
<p><a class="source-toggle" href="#"
|
1052
|
+
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
1053
|
+
<div class="method-source-code" id="M000037-source">
|
1054
|
+
<pre>
|
1055
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 446</span>
|
1056
|
+
446: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_str</span>
|
1057
|
+
447: <span class="ruby-ivar">@content_type</span>
|
1058
|
+
448: <span class="ruby-keyword kw">end</span>
|
1059
|
+
</pre>
|
1060
|
+
</div>
|
1061
|
+
</div>
|
1062
|
+
</div>
|
1063
|
+
|
1064
|
+
<div id="method-M000023" class="method-detail">
|
1065
|
+
<a name="M000023"></a>
|
1066
|
+
|
1067
|
+
<div class="method-heading">
|
1068
|
+
<a href="#M000023" class="method-signature">
|
1069
|
+
<span class="method-name">urls</span><span class="method-args">()</span>
|
1070
|
+
</a>
|
1071
|
+
</div>
|
1072
|
+
|
1073
|
+
<div class="method-description">
|
1074
|
+
<p>
|
1075
|
+
The decoded URL list for this <a href="Type.html">MIME::Type</a>. The
|
1076
|
+
special URL value IANA will be translated into:
|
1077
|
+
</p>
|
1078
|
+
<pre>
|
1079
|
+
http://www.iana.org/assignments/media-types/<mediatype>/<subtype>
|
1080
|
+
</pre>
|
1081
|
+
<p>
|
1082
|
+
The special URL value RFC### will be translated into:
|
1083
|
+
</p>
|
1084
|
+
<pre>
|
1085
|
+
http://www.rfc-editor.org/rfc/rfc###.txt
|
1086
|
+
</pre>
|
1087
|
+
<p>
|
1088
|
+
The special URL value DRAFT:name will be translated into:
|
1089
|
+
</p>
|
1090
|
+
<pre>
|
1091
|
+
https://datatracker.ietf.org/public/idindex.cgi?
|
1092
|
+
command=id_detail&filename=<name>
|
1093
|
+
</pre>
|
1094
|
+
<p>
|
1095
|
+
The special URL value LTSW will be translated into:
|
1096
|
+
</p>
|
1097
|
+
<pre>
|
1098
|
+
http://www.ltsw.se/knbase/internet/<mediatype>.htp
|
1099
|
+
</pre>
|
1100
|
+
<p>
|
1101
|
+
The special URL value [token] will be translated into:
|
1102
|
+
</p>
|
1103
|
+
<pre>
|
1104
|
+
http://www.iana.org/assignments/contact-people.htm#<token>
|
1105
|
+
</pre>
|
1106
|
+
<p>
|
1107
|
+
These values will be accessible through url, which always returns an array.
|
1108
|
+
</p>
|
1109
|
+
<p><a class="source-toggle" href="#"
|
1110
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
1111
|
+
<div class="method-source-code" id="M000023-source">
|
1112
|
+
<pre>
|
1113
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 224</span>
|
1114
|
+
224: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">urls</span>
|
1115
|
+
225: <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">el</span><span class="ruby-operator">|</span>
|
1116
|
+
226: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">el</span>
|
1117
|
+
227: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^IANA$}</span>
|
1118
|
+
228: <span class="ruby-constant">IANA_URL</span> <span class="ruby-operator">%</span> [ <span class="ruby-ivar">@media_type</span>, <span class="ruby-ivar">@sub_type</span> ]
|
1119
|
+
229: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^RFC(\d+)$}</span>
|
1120
|
+
230: <span class="ruby-constant">RFC_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
|
1121
|
+
231: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^DRAFT:(.+)$}</span>
|
1122
|
+
232: <span class="ruby-constant">DRAFT_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
|
1123
|
+
233: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^LTSW$}</span>
|
1124
|
+
234: <span class="ruby-constant">LTSW_URL</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@media_type</span>
|
1125
|
+
235: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^\[([^\]]+)\]}</span>
|
1126
|
+
236: <span class="ruby-constant">CONTACT_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
|
1127
|
+
237: <span class="ruby-keyword kw">else</span>
|
1128
|
+
238: <span class="ruby-identifier">el</span>
|
1129
|
+
239: <span class="ruby-keyword kw">end</span>
|
1130
|
+
240: }
|
1131
|
+
241: <span class="ruby-keyword kw">end</span>
|
1132
|
+
</pre>
|
1133
|
+
</div>
|
1134
|
+
</div>
|
1135
|
+
</div>
|
1136
|
+
|
1137
|
+
<div id="method-M000020" class="method-detail">
|
1138
|
+
<a name="M000020"></a>
|
1139
|
+
|
1140
|
+
<div class="method-heading">
|
1141
|
+
<a href="#M000020" class="method-signature">
|
1142
|
+
<span class="method-name">use_instead</span><span class="method-args">()</span>
|
1143
|
+
</a>
|
1144
|
+
</div>
|
1145
|
+
|
1146
|
+
<div class="method-description">
|
1147
|
+
<p><a class="source-toggle" href="#"
|
1148
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
1149
|
+
<div class="method-source-code" id="M000020-source">
|
1150
|
+
<pre>
|
1151
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 174</span>
|
1152
|
+
174: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_instead</span>
|
1153
|
+
175: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@obsolete</span>
|
1154
|
+
176: <span class="ruby-ivar">@use_instead</span>
|
1155
|
+
177: <span class="ruby-keyword kw">end</span>
|
1156
|
+
</pre>
|
1157
|
+
</div>
|
1158
|
+
</div>
|
1159
|
+
</div>
|
1160
|
+
|
1161
|
+
|
1162
|
+
</div>
|
1163
|
+
|
1164
|
+
|
1165
|
+
</div>
|
1166
|
+
|
1167
|
+
|
1168
|
+
<div id="validator-badges">
|
1169
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
1170
|
+
</div>
|
1171
|
+
|
1172
|
+
</body>
|
1173
|
+
</html>
|