s33r 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,566 @@
|
|
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::Types</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::Types</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
|
+
<h1><a href="Types.html">MIME::Types</a></h1>
|
83
|
+
<p>
|
84
|
+
<a href="../MIME.html">MIME</a> types are used in <a
|
85
|
+
href="../MIME.html">MIME</a>-compliant communications, as in e-mail or HTTP
|
86
|
+
traffic, to indicate the type of content which is transmitted. <a
|
87
|
+
href="Types.html">MIME::Types</a> provides the ability for detailed
|
88
|
+
information about <a href="../MIME.html">MIME</a> entities (provided as a
|
89
|
+
set of <a href="Type.html">MIME::Type</a> objects) to be determined and
|
90
|
+
used programmatically. There are many types defined by RFCs and vendors, so
|
91
|
+
the list is long but not complete; don’t hesitate to ask to add
|
92
|
+
additional information. This library follows the IANA collection of <a
|
93
|
+
href="../MIME.html">MIME</a> types (see below for reference).
|
94
|
+
</p>
|
95
|
+
<h2>Description</h2>
|
96
|
+
<p>
|
97
|
+
<a href="../MIME.html">MIME</a> types are used in <a
|
98
|
+
href="../MIME.html">MIME</a> entities, as in email or HTTP traffic. It is
|
99
|
+
useful at times to have information available about <a
|
100
|
+
href="../MIME.html">MIME</a> types (or, inversely, about files). A <a
|
101
|
+
href="Type.html">MIME::Type</a> stores the known information about one <a
|
102
|
+
href="../MIME.html">MIME</a> type.
|
103
|
+
</p>
|
104
|
+
<h2>Usage</h2>
|
105
|
+
<pre>
|
106
|
+
require 'mime/types'
|
107
|
+
|
108
|
+
plaintext = MIME::Types['text/plain']
|
109
|
+
print plaintext.media_type # => 'text'
|
110
|
+
print plaintext.sub_type # => 'plain'
|
111
|
+
|
112
|
+
puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
|
113
|
+
|
114
|
+
puts plaintext.encoding # => 8bit
|
115
|
+
puts plaintext.binary? # => false
|
116
|
+
puts plaintext.ascii? # => true
|
117
|
+
puts plaintext.obsolete? # => false
|
118
|
+
puts plaintext.registered? # => true
|
119
|
+
puts plaintext == 'text/plain' # => true
|
120
|
+
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
121
|
+
</pre>
|
122
|
+
<p>
|
123
|
+
This module is built to conform to the <a href="../MIME.html">MIME</a>
|
124
|
+
types of RFCs 2045 and 2231. It follows the official IANA registry at <a
|
125
|
+
href="http://www.iana.org/assignments/media-types">www.iana.org/assignments/media-types</a>/
|
126
|
+
and <a
|
127
|
+
href="ftp://ftp.iana.org/assignments/media-types">ftp.iana.org/assignments/media-types</a>
|
128
|
+
with some unofficial types added from the the collection at <a
|
129
|
+
href="http://www.ltsw.se/knbase/internet/mime.htp">www.ltsw.se/knbase/internet/mime.htp</a>
|
130
|
+
</p>
|
131
|
+
<p>
|
132
|
+
This is originally based on Perl <a href="Types.html">MIME::Types</a> by
|
133
|
+
Mark Overmeer.
|
134
|
+
</p>
|
135
|
+
<h1>Author</h1>
|
136
|
+
<table>
|
137
|
+
<tr><td valign="top">Copyright:</td><td>Copyright © 2002 - 2006 by Austin Ziegler <austin@rubyforge.org>
|
138
|
+
|
139
|
+
</td></tr>
|
140
|
+
<tr><td valign="top">Version:</td><td>1.15
|
141
|
+
|
142
|
+
</td></tr>
|
143
|
+
<tr><td valign="top">Based On:</td><td>Perl <a
|
144
|
+
href="http://search.cpan.org/author/MARKOV/MIME-Types-1.15/MIME/Types.pm">MIME::Types</a>,
|
145
|
+
Copyright © 2001 - 2005 by Mark Overmeer
|
146
|
+
<mimetypes@overmeer.net>.
|
147
|
+
|
148
|
+
</td></tr>
|
149
|
+
<tr><td valign="top">Licence:</td><td>Ruby’s, Perl Artistic, or GPL version 2 (or later)
|
150
|
+
|
151
|
+
</td></tr>
|
152
|
+
<tr><td valign="top">See Also:</td><td><a
|
153
|
+
href="http://www.iana.org/assignments/media-types">www.iana.org/assignments/media-types</a>/
|
154
|
+
<a
|
155
|
+
href="http://www.ltsw.se/knbase/internet/mime.htp">www.ltsw.se/knbase/internet/mime.htp</a>
|
156
|
+
|
157
|
+
</td></tr>
|
158
|
+
</table>
|
159
|
+
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
</div>
|
164
|
+
|
165
|
+
<div id="method-list">
|
166
|
+
<h3 class="section-bar">Methods</h3>
|
167
|
+
|
168
|
+
<div class="name-list">
|
169
|
+
<a href="#M000014">[]</a>
|
170
|
+
<a href="#M000010">[]</a>
|
171
|
+
<a href="#M000017">add</a>
|
172
|
+
<a href="#M000013">add</a>
|
173
|
+
<a href="#M000009">new</a>
|
174
|
+
<a href="#M000016">of</a>
|
175
|
+
<a href="#M000012">of</a>
|
176
|
+
<a href="#M000011">type_for</a>
|
177
|
+
<a href="#M000015">type_for</a>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
|
184
|
+
<!-- if includes -->
|
185
|
+
|
186
|
+
<div id="section">
|
187
|
+
|
188
|
+
|
189
|
+
<div id="constants-list">
|
190
|
+
<h3 class="section-bar">Constants</h3>
|
191
|
+
|
192
|
+
<div class="name-list">
|
193
|
+
<table summary="Constants">
|
194
|
+
<tr class="top-aligned-row context-row">
|
195
|
+
<td class="context-item-name">VERSION</td>
|
196
|
+
<td>=</td>
|
197
|
+
<td class="context-item-value">'1.15'</td>
|
198
|
+
<td width="3em"> </td>
|
199
|
+
<td class="context-item-desc">
|
200
|
+
The released version of Ruby <a href="Types.html">MIME::Types</a>
|
201
|
+
|
202
|
+
</td>
|
203
|
+
</tr>
|
204
|
+
</table>
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
<div id="attribute-list">
|
211
|
+
<h3 class="section-bar">Attributes</h3>
|
212
|
+
|
213
|
+
<div class="name-list">
|
214
|
+
<table>
|
215
|
+
<tr class="top-aligned-row context-row">
|
216
|
+
<td class="context-item-name">data_version</td>
|
217
|
+
<td class="context-item-value"> [R] </td>
|
218
|
+
<td class="context-item-desc">
|
219
|
+
The data version.
|
220
|
+
|
221
|
+
</td>
|
222
|
+
</tr>
|
223
|
+
</table>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<!-- if method_list -->
|
230
|
+
<div id="methods">
|
231
|
+
<h3 class="section-bar">Public Class methods</h3>
|
232
|
+
|
233
|
+
<div id="method-M000014" class="method-detail">
|
234
|
+
<a name="M000014"></a>
|
235
|
+
|
236
|
+
<div class="method-heading">
|
237
|
+
<a href="#M000014" class="method-signature">
|
238
|
+
<span class="method-name">[]</span><span class="method-args">(type_id, flags = {})</span>
|
239
|
+
</a>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div class="method-description">
|
243
|
+
<p>
|
244
|
+
Returns a list of <a href="Type.html">MIME::Type</a> objects, which may be
|
245
|
+
empty. The optional flag parameters are :complete (finds only complete <a
|
246
|
+
href="Type.html">MIME::Type</a> objects) and :platform (finds only <a
|
247
|
+
href="Types.html">MIME::Types</a> for the current platform). It is possible
|
248
|
+
for multiple matches to be returned for either type (in the example below,
|
249
|
+
‘text/plain’ returns two values — one for the general
|
250
|
+
case, and one for VMS systems.
|
251
|
+
</p>
|
252
|
+
<pre>
|
253
|
+
puts "\nMIME::Types['text/plain']"
|
254
|
+
MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
|
255
|
+
|
256
|
+
puts "\nMIME::Types[/^image/, :complete => true]"
|
257
|
+
MIME::Types[/^image/, :complete => true].each do |t|
|
258
|
+
puts t.to_a.join(", ")
|
259
|
+
end
|
260
|
+
</pre>
|
261
|
+
<p><a class="source-toggle" href="#"
|
262
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
263
|
+
<div class="method-source-code" id="M000014-source">
|
264
|
+
<pre>
|
265
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 641</span>
|
266
|
+
641: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">type_id</span>, <span class="ruby-identifier">flags</span> = {})
|
267
|
+
642: <span class="ruby-ivar">@__types__</span>[<span class="ruby-identifier">type_id</span>, <span class="ruby-identifier">flags</span>]
|
268
|
+
643: <span class="ruby-keyword kw">end</span>
|
269
|
+
</pre>
|
270
|
+
</div>
|
271
|
+
</div>
|
272
|
+
</div>
|
273
|
+
|
274
|
+
<div id="method-M000017" class="method-detail">
|
275
|
+
<a name="M000017"></a>
|
276
|
+
|
277
|
+
<div class="method-heading">
|
278
|
+
<a href="#M000017" class="method-signature">
|
279
|
+
<span class="method-name">add</span><span class="method-args">(*types)</span>
|
280
|
+
</a>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
<p>
|
285
|
+
Add one or more <a href="Type.html">MIME::Type</a> objects to the set of
|
286
|
+
known types. Each type should be experimental (e.g.,
|
287
|
+
‘application/x-ruby’). If the type is already known, a warning
|
288
|
+
will be displayed.
|
289
|
+
</p>
|
290
|
+
<p>
|
291
|
+
<b>Please inform the maintainer of this module when registered types are
|
292
|
+
missing.</b>
|
293
|
+
</p>
|
294
|
+
<p><a class="source-toggle" href="#"
|
295
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
296
|
+
<div class="method-source-code" id="M000017-source">
|
297
|
+
<pre>
|
298
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 668</span>
|
299
|
+
668: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">types</span>)
|
300
|
+
669: <span class="ruby-ivar">@__types__</span>.<span class="ruby-identifier">add</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">types</span>)
|
301
|
+
670: <span class="ruby-keyword kw">end</span>
|
302
|
+
</pre>
|
303
|
+
</div>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
<div id="method-M000009" class="method-detail">
|
308
|
+
<a name="M000009"></a>
|
309
|
+
|
310
|
+
<div class="method-heading">
|
311
|
+
<a href="#M000009" class="method-signature">
|
312
|
+
<span class="method-name">new</span><span class="method-args">(data_version = nil)</span>
|
313
|
+
</a>
|
314
|
+
</div>
|
315
|
+
|
316
|
+
<div class="method-description">
|
317
|
+
<p><a class="source-toggle" href="#"
|
318
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
319
|
+
<div class="method-source-code" id="M000009-source">
|
320
|
+
<pre>
|
321
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 533</span>
|
322
|
+
533: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">data_version</span> = <span class="ruby-keyword kw">nil</span>)
|
323
|
+
534: <span class="ruby-ivar">@type_variants</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [] }
|
324
|
+
535: <span class="ruby-ivar">@extension_index</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [] }
|
325
|
+
536: <span class="ruby-keyword kw">end</span>
|
326
|
+
</pre>
|
327
|
+
</div>
|
328
|
+
</div>
|
329
|
+
</div>
|
330
|
+
|
331
|
+
<div id="method-M000016" class="method-detail">
|
332
|
+
<a name="M000016"></a>
|
333
|
+
|
334
|
+
<div class="method-heading">
|
335
|
+
<a href="#M000016" class="method-signature">
|
336
|
+
<span class="method-name">of</span><span class="method-args">(filename, platform = false)</span>
|
337
|
+
</a>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
<div class="method-description">
|
341
|
+
<p>
|
342
|
+
A synonym for <a href="Types.html#M000011">MIME::Types.type_for</a>
|
343
|
+
</p>
|
344
|
+
<p><a class="source-toggle" href="#"
|
345
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
346
|
+
<div class="method-source-code" id="M000016-source">
|
347
|
+
<pre>
|
348
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 658</span>
|
349
|
+
658: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">of</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span> = <span class="ruby-keyword kw">false</span>)
|
350
|
+
659: <span class="ruby-ivar">@__types__</span>.<span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span>)
|
351
|
+
660: <span class="ruby-keyword kw">end</span>
|
352
|
+
</pre>
|
353
|
+
</div>
|
354
|
+
</div>
|
355
|
+
</div>
|
356
|
+
|
357
|
+
<div id="method-M000015" class="method-detail">
|
358
|
+
<a name="M000015"></a>
|
359
|
+
|
360
|
+
<div class="method-heading">
|
361
|
+
<a href="#M000015" class="method-signature">
|
362
|
+
<span class="method-name">type_for</span><span class="method-args">(filename, platform = false)</span>
|
363
|
+
</a>
|
364
|
+
</div>
|
365
|
+
|
366
|
+
<div class="method-description">
|
367
|
+
<p>
|
368
|
+
Return the list of <a href="Types.html">MIME::Types</a> which belongs to
|
369
|
+
the file based on its filename extension. If <tt>platform</tt> is
|
370
|
+
<tt>true</tt>, then only file types that are specific to the current
|
371
|
+
platform will be returned.
|
372
|
+
</p>
|
373
|
+
<pre>
|
374
|
+
puts "MIME::Types.type_for('citydesk.xml')
|
375
|
+
=> "#{MIME::Types.type_for('citydesk.xml')}"
|
376
|
+
puts "MIME::Types.type_for('citydesk.gif')
|
377
|
+
=> "#{MIME::Types.type_for('citydesk.gif')}"
|
378
|
+
</pre>
|
379
|
+
<p><a class="source-toggle" href="#"
|
380
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
381
|
+
<div class="method-source-code" id="M000015-source">
|
382
|
+
<pre>
|
383
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 653</span>
|
384
|
+
653: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span> = <span class="ruby-keyword kw">false</span>)
|
385
|
+
654: <span class="ruby-ivar">@__types__</span>.<span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span>)
|
386
|
+
655: <span class="ruby-keyword kw">end</span>
|
387
|
+
</pre>
|
388
|
+
</div>
|
389
|
+
</div>
|
390
|
+
</div>
|
391
|
+
|
392
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
393
|
+
|
394
|
+
<div id="method-M000010" class="method-detail">
|
395
|
+
<a name="M000010"></a>
|
396
|
+
|
397
|
+
<div class="method-heading">
|
398
|
+
<a href="#M000010" class="method-signature">
|
399
|
+
<span class="method-name">[]</span><span class="method-args">(type_id, flags = {})</span>
|
400
|
+
</a>
|
401
|
+
</div>
|
402
|
+
|
403
|
+
<div class="method-description">
|
404
|
+
<p>
|
405
|
+
Returns a list of <a href="Type.html">MIME::Type</a> objects, which may be
|
406
|
+
empty. The optional flag parameters are :complete (finds only complete <a
|
407
|
+
href="Type.html">MIME::Type</a> objects) and :platform (finds only <a
|
408
|
+
href="Types.html">MIME::Types</a> for the current platform). It is possible
|
409
|
+
for multiple matches to be returned for either type (in the example below,
|
410
|
+
‘text/plain’ returns two values — one for the general
|
411
|
+
case, and one for VMS systems.
|
412
|
+
</p>
|
413
|
+
<pre>
|
414
|
+
puts "\nMIME::Types['text/plain']"
|
415
|
+
MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
|
416
|
+
|
417
|
+
puts "\nMIME::Types[/^image/, :complete => true]"
|
418
|
+
MIME::Types[/^image/, :complete => true].each do |t|
|
419
|
+
puts t.to_a.join(", ")
|
420
|
+
end
|
421
|
+
</pre>
|
422
|
+
<p><a class="source-toggle" href="#"
|
423
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
424
|
+
<div class="method-source-code" id="M000010-source">
|
425
|
+
<pre>
|
426
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 562</span>
|
427
|
+
562: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">type_id</span>, <span class="ruby-identifier">flags</span> = {})
|
428
|
+
563: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type_id</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Regexp</span>)
|
429
|
+
564: <span class="ruby-identifier">matches</span> = []
|
430
|
+
565: <span class="ruby-ivar">@type_variants</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
431
|
+
566: <span class="ruby-identifier">matches</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@type_variants</span>[<span class="ruby-identifier">k</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">type_id</span>
|
432
|
+
567: <span class="ruby-keyword kw">end</span>
|
433
|
+
568: <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">flatten!</span>
|
434
|
+
569: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">type_id</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>)
|
435
|
+
570: <span class="ruby-identifier">matches</span> = [<span class="ruby-identifier">type_id</span>]
|
436
|
+
571: <span class="ruby-keyword kw">else</span>
|
437
|
+
572: <span class="ruby-identifier">matches</span> = <span class="ruby-ivar">@type_variants</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-identifier">type_id</span>)]
|
438
|
+
573: <span class="ruby-keyword kw">end</span>
|
439
|
+
574:
|
440
|
+
575: <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">complete?</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:complete</span>]
|
441
|
+
576: <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">platform?</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:platform</span>]
|
442
|
+
577: <span class="ruby-identifier">matches</span>
|
443
|
+
578: <span class="ruby-keyword kw">end</span>
|
444
|
+
</pre>
|
445
|
+
</div>
|
446
|
+
</div>
|
447
|
+
</div>
|
448
|
+
|
449
|
+
<div id="method-M000013" class="method-detail">
|
450
|
+
<a name="M000013"></a>
|
451
|
+
|
452
|
+
<div class="method-heading">
|
453
|
+
<a href="#M000013" class="method-signature">
|
454
|
+
<span class="method-name">add</span><span class="method-args">(*types)</span>
|
455
|
+
</a>
|
456
|
+
</div>
|
457
|
+
|
458
|
+
<div class="method-description">
|
459
|
+
<p>
|
460
|
+
Add one or more <a href="Type.html">MIME::Type</a> objects to the set of
|
461
|
+
known types. Each type should be experimental (e.g.,
|
462
|
+
‘application/x-ruby’). If the type is already known, a warning
|
463
|
+
will be displayed.
|
464
|
+
</p>
|
465
|
+
<p>
|
466
|
+
<b>Please inform the maintainer of this module when registered types are
|
467
|
+
missing.</b>
|
468
|
+
</p>
|
469
|
+
<p><a class="source-toggle" href="#"
|
470
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
471
|
+
<div class="method-source-code" id="M000013-source">
|
472
|
+
<pre>
|
473
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 606</span>
|
474
|
+
606: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">types</span>)
|
475
|
+
607: <span class="ruby-identifier">types</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mime_type</span><span class="ruby-operator">|</span>
|
476
|
+
608: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@type_variants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>)
|
477
|
+
609: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@type_variants</span>[<span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">mime_type</span>)
|
478
|
+
610: <span class="ruby-identifier">warn</span> <span class="ruby-node">"Type #{mime_type} already registered as a variant of #{mime_type.simplified}."</span>
|
479
|
+
611: <span class="ruby-keyword kw">end</span>
|
480
|
+
612: <span class="ruby-keyword kw">end</span>
|
481
|
+
613: <span class="ruby-identifier">add_type_variant</span>(<span class="ruby-identifier">mime_type</span>)
|
482
|
+
614: <span class="ruby-identifier">index_extensions</span>(<span class="ruby-identifier">mime_type</span>)
|
483
|
+
615: <span class="ruby-keyword kw">end</span>
|
484
|
+
616: <span class="ruby-keyword kw">end</span>
|
485
|
+
</pre>
|
486
|
+
</div>
|
487
|
+
</div>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
<div id="method-M000012" class="method-detail">
|
491
|
+
<a name="M000012"></a>
|
492
|
+
|
493
|
+
<div class="method-heading">
|
494
|
+
<a href="#M000012" class="method-signature">
|
495
|
+
<span class="method-name">of</span><span class="method-args">(filename, platform = false)</span>
|
496
|
+
</a>
|
497
|
+
</div>
|
498
|
+
|
499
|
+
<div class="method-description">
|
500
|
+
<p>
|
501
|
+
A synonym for <a href="Types.html#M000011">MIME::Types.type_for</a>
|
502
|
+
</p>
|
503
|
+
<p><a class="source-toggle" href="#"
|
504
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
505
|
+
<div class="method-source-code" id="M000012-source">
|
506
|
+
<pre>
|
507
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 596</span>
|
508
|
+
596: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">of</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span> = <span class="ruby-keyword kw">false</span>)
|
509
|
+
597: <span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span>)
|
510
|
+
598: <span class="ruby-keyword kw">end</span>
|
511
|
+
</pre>
|
512
|
+
</div>
|
513
|
+
</div>
|
514
|
+
</div>
|
515
|
+
|
516
|
+
<div id="method-M000011" class="method-detail">
|
517
|
+
<a name="M000011"></a>
|
518
|
+
|
519
|
+
<div class="method-heading">
|
520
|
+
<a href="#M000011" class="method-signature">
|
521
|
+
<span class="method-name">type_for</span><span class="method-args">(filename, platform = false)</span>
|
522
|
+
</a>
|
523
|
+
</div>
|
524
|
+
|
525
|
+
<div class="method-description">
|
526
|
+
<p>
|
527
|
+
Return the list of <a href="Types.html">MIME::Types</a> which belongs to
|
528
|
+
the file based on its filename extension. If <tt>platform</tt> is
|
529
|
+
<tt>true</tt>, then only file types that are specific to the current
|
530
|
+
platform will be returned.
|
531
|
+
</p>
|
532
|
+
<pre>
|
533
|
+
puts "MIME::Types.type_for('citydesk.xml')
|
534
|
+
=> "#{MIME::Types.type_for('citydesk.xml')}"
|
535
|
+
puts "MIME::Types.type_for('citydesk.gif')
|
536
|
+
=> "#{MIME::Types.type_for('citydesk.gif')}"
|
537
|
+
</pre>
|
538
|
+
<p><a class="source-toggle" href="#"
|
539
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
540
|
+
<div class="method-source-code" id="M000011-source">
|
541
|
+
<pre>
|
542
|
+
<span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 588</span>
|
543
|
+
588: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">platform</span> = <span class="ruby-keyword kw">false</span>)
|
544
|
+
589: <span class="ruby-identifier">ext</span> = <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/.*\./o</span>, <span class="ruby-value str">''</span>)
|
545
|
+
590: <span class="ruby-identifier">list</span> = <span class="ruby-ivar">@extension_index</span>[<span class="ruby-identifier">ext</span>]
|
546
|
+
591: <span class="ruby-identifier">list</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">platform?</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">platform</span>
|
547
|
+
592: <span class="ruby-identifier">list</span>
|
548
|
+
593: <span class="ruby-keyword kw">end</span>
|
549
|
+
</pre>
|
550
|
+
</div>
|
551
|
+
</div>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
|
555
|
+
</div>
|
556
|
+
|
557
|
+
|
558
|
+
</div>
|
559
|
+
|
560
|
+
|
561
|
+
<div id="validator-badges">
|
562
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
563
|
+
</div>
|
564
|
+
|
565
|
+
</body>
|
566
|
+
</html>
|