s33r 0.4.2 → 0.5

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.
Files changed (114) hide show
  1. data/examples/cli/instant_download_server.rb +88 -0
  2. data/examples/cli/s3cli.rb +31 -52
  3. data/examples/cli/simple.rb +16 -6
  4. data/examples/fores33r/app/controllers/browser_controller.rb +12 -10
  5. data/examples/fores33r/app/helpers/application_helper.rb +2 -1
  6. data/examples/fores33r/app/views/browser/_upload.rhtml +1 -1
  7. data/examples/fores33r/app/views/browser/index.rhtml +4 -4
  8. data/examples/fores33r/config/environment.rb +5 -3
  9. data/examples/fores33r/log/development.log +2259 -0
  10. data/examples/fores33r/log/mongrel.log +59 -0
  11. data/examples/s3.yaml +2 -6
  12. data/lib/s33r/bucket.rb +103 -0
  13. data/lib/s33r/bucket_listing.rb +33 -76
  14. data/lib/s33r/client.rb +305 -446
  15. data/lib/s33r/networking.rb +197 -0
  16. data/lib/s33r/s33r_exception.rb +29 -18
  17. data/lib/s33r/s33r_http.rb +36 -18
  18. data/lib/s33r/s3_acl.rb +32 -52
  19. data/lib/s33r/s3_logging.rb +117 -0
  20. data/lib/s33r/s3_obj.rb +124 -69
  21. data/lib/s33r/utility.rb +447 -0
  22. data/test/cases/spec_acl.rb +10 -40
  23. data/test/cases/spec_bucket_listing.rb +12 -32
  24. data/test/cases/spec_logging.rb +47 -0
  25. data/test/cases/spec_networking.rb +11 -0
  26. data/test/cases/spec_s3_object.rb +44 -5
  27. data/test/cases/spec_utility.rb +264 -0
  28. data/test/files/acl.xml +0 -6
  29. data/test/files/config.yaml +5 -0
  30. data/test/files/logging_status_disabled.xml +3 -0
  31. data/test/files/logging_status_enabled.xml +7 -0
  32. data/test/test_setup.rb +7 -2
  33. metadata +16 -94
  34. data/examples/cli/acl_x.rb +0 -41
  35. data/examples/cli/logging_x.rb +0 -20
  36. data/examples/fores33r/README +0 -183
  37. data/html/classes/MIME.html +0 -120
  38. data/html/classes/MIME/InvalidContentType.html +0 -119
  39. data/html/classes/MIME/Type.html +0 -1173
  40. data/html/classes/MIME/Types.html +0 -566
  41. data/html/classes/Net.html +0 -108
  42. data/html/classes/Net/HTTPGenericRequest.html +0 -233
  43. data/html/classes/Net/HTTPResponse.html +0 -271
  44. data/html/classes/S33r.html +0 -986
  45. data/html/classes/S33r/BucketListing.html +0 -434
  46. data/html/classes/S33r/Client.html +0 -1575
  47. data/html/classes/S33r/LoggingResource.html +0 -222
  48. data/html/classes/S33r/NamedBucket.html +0 -693
  49. data/html/classes/S33r/OrderlyXmlMarkup.html +0 -165
  50. data/html/classes/S33r/S33rException.html +0 -124
  51. data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +0 -111
  52. data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +0 -119
  53. data/html/classes/S33r/S33rException/InvalidBucketListing.html +0 -111
  54. data/html/classes/S33r/S33rException/InvalidPermission.html +0 -111
  55. data/html/classes/S33r/S33rException/InvalidS3GroupType.html +0 -111
  56. data/html/classes/S33r/S33rException/MalformedBucketName.html +0 -111
  57. data/html/classes/S33r/S33rException/MethodNotAvailable.html +0 -111
  58. data/html/classes/S33r/S33rException/MissingBucketName.html +0 -111
  59. data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +0 -111
  60. data/html/classes/S33r/S33rException/MissingResource.html +0 -111
  61. data/html/classes/S33r/S33rException/S3FallenOver.html +0 -111
  62. data/html/classes/S33r/S33rException/TryingToPutEmptyResource.html +0 -117
  63. data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +0 -111
  64. data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +0 -111
  65. data/html/classes/S33r/S3ACL.html +0 -125
  66. data/html/classes/S33r/S3ACL/ACLDoc.html +0 -521
  67. data/html/classes/S33r/S3ACL/AmazonCustomer.html +0 -168
  68. data/html/classes/S33r/S3ACL/CanonicalUser.html +0 -212
  69. data/html/classes/S33r/S3ACL/Grant.html +0 -403
  70. data/html/classes/S33r/S3ACL/Grantee.html +0 -239
  71. data/html/classes/S33r/S3ACL/Group.html +0 -178
  72. data/html/classes/S33r/S3Object.html +0 -618
  73. data/html/classes/S33r/Sync.html +0 -152
  74. data/html/classes/XML.html +0 -202
  75. data/html/classes/XML/Document.html +0 -125
  76. data/html/classes/XML/Node.html +0 -124
  77. data/html/created.rid +0 -1
  78. data/html/files/CHANGELOG.html +0 -107
  79. data/html/files/MIT-LICENSE.html +0 -129
  80. data/html/files/README_txt.html +0 -259
  81. data/html/files/lib/s33r/bucket_listing_rb.html +0 -101
  82. data/html/files/lib/s33r/builder_rb.html +0 -108
  83. data/html/files/lib/s33r/client_rb.html +0 -111
  84. data/html/files/lib/s33r/core_rb.html +0 -113
  85. data/html/files/lib/s33r/libxml_extensions_rb.html +0 -101
  86. data/html/files/lib/s33r/libxml_loader_rb.html +0 -109
  87. data/html/files/lib/s33r/logging_rb.html +0 -108
  88. data/html/files/lib/s33r/mimetypes_rb.html +0 -120
  89. data/html/files/lib/s33r/named_bucket_rb.html +0 -101
  90. data/html/files/lib/s33r/s33r_exception_rb.html +0 -101
  91. data/html/files/lib/s33r/s33r_http_rb.html +0 -108
  92. data/html/files/lib/s33r/s3_acl_rb.html +0 -108
  93. data/html/files/lib/s33r/s3_obj_rb.html +0 -108
  94. data/html/files/lib/s33r/sync_rb.html +0 -101
  95. data/html/files/lib/s33r_rb.html +0 -101
  96. data/html/fr_class_index.html +0 -66
  97. data/html/fr_file_index.html +0 -44
  98. data/html/fr_method_index.html +0 -183
  99. data/html/index.html +0 -24
  100. data/html/rdoc-style.css +0 -208
  101. data/lib/s33r/core.rb +0 -296
  102. data/lib/s33r/logging.rb +0 -43
  103. data/lib/s33r/named_bucket.rb +0 -148
  104. data/lib/s33r/sync.rb +0 -13
  105. data/test/cases/spec_all_buckets.rb +0 -28
  106. data/test/cases/spec_client.rb +0 -101
  107. data/test/cases/spec_core.rb +0 -128
  108. data/test/cases/spec_namedbucket.rb +0 -46
  109. data/test/cases/spec_sync.rb +0 -34
  110. data/test/files/all_buckets.xml +0 -21
  111. data/test/files/client_config.yml +0 -5
  112. data/test/files/namedbucket_config.yml +0 -8
  113. data/test/files/namedbucket_config2.yml +0 -8
  114. data/test/test_bucket_setup.rb +0 -41
@@ -1,239 +0,0 @@
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: S33r::S3ACL::Grantee</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">S33r::S3ACL::Grantee</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/s33r/s3_acl_rb.html">
59
- lib/s33r/s3_acl.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
- Abstract representation of an S3 <a href="Grantee.html">Grantee</a>.
84
- </p>
85
-
86
- </div>
87
-
88
-
89
- </div>
90
-
91
- <div id="method-list">
92
- <h3 class="section-bar">Methods</h3>
93
-
94
- <div class="name-list">
95
- <a href="#M000074">==</a>&nbsp;&nbsp;
96
- <a href="#M000076">from_xml</a>&nbsp;&nbsp;
97
- <a href="#M000075">method_missing</a>&nbsp;&nbsp;
98
- </div>
99
- </div>
100
-
101
- </div>
102
-
103
-
104
- <!-- if includes -->
105
-
106
- <div id="section">
107
-
108
-
109
-
110
-
111
-
112
- <div id="attribute-list">
113
- <h3 class="section-bar">Attributes</h3>
114
-
115
- <div class="name-list">
116
- <table>
117
- <tr class="top-aligned-row context-row">
118
- <td class="context-item-name">grantee_type</td>
119
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
120
- <td class="context-item-desc"></td>
121
- </tr>
122
- </table>
123
- </div>
124
- </div>
125
-
126
-
127
-
128
- <!-- if method_list -->
129
- <div id="methods">
130
- <h3 class="section-bar">Public Class methods</h3>
131
-
132
- <div id="method-M000076" class="method-detail">
133
- <a name="M000076"></a>
134
-
135
- <div class="method-heading">
136
- <a href="#M000076" class="method-signature">
137
- <span class="method-name">from_xml</span><span class="method-args">(grantee_xml)</span>
138
- </a>
139
- </div>
140
-
141
- <div class="method-description">
142
- <p><a class="source-toggle" href="#"
143
- onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
144
- <div class="method-source-code" id="M000076-source">
145
- <pre>
146
- <span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 265</span>
147
- 265: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">grantee_xml</span>)
148
- 266: <span class="ruby-identifier">grantee_type</span> = <span class="ruby-identifier">grantee_xml</span>[<span class="ruby-value str">'type'</span>]
149
- 267:
150
- 268: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">grantee_type</span>
151
- 269: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:amazon_customer</span>]
152
- 270: <span class="ruby-constant">AmazonCustomer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">grantee_xml</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'EmailAddress'</span>))
153
- 271: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:canonical_user</span>]
154
- 272: <span class="ruby-constant">CanonicalUser</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">grantee_xml</span>)
155
- 273: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:group</span>]
156
- 274: <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">grantee_xml</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'URI'</span>)
157
- 275: <span class="ruby-comment cmt"># last part of the path is the group type</span>
158
- 276: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/#{GROUP_ACL_URI_BASE}/</span>, <span class="ruby-value str">''</span>)
159
- 277:
160
- 278: <span class="ruby-identifier">group_type</span> = <span class="ruby-identifier">:all_users</span>
161
- 279: <span class="ruby-constant">S3_GROUP_TYPES</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">group_type</span> = <span class="ruby-identifier">k</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">path</span> }
162
- 280: <span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">group_type</span>)
163
- 281: <span class="ruby-keyword kw">end</span>
164
- 282: <span class="ruby-keyword kw">end</span>
165
- </pre>
166
- </div>
167
- </div>
168
- </div>
169
-
170
- <h3 class="section-bar">Public Instance methods</h3>
171
-
172
- <div id="method-M000074" class="method-detail">
173
- <a name="M000074"></a>
174
-
175
- <div class="method-heading">
176
- <a href="#M000074" class="method-signature">
177
- <span class="method-name">==</span><span class="method-args">(obj)</span>
178
- </a>
179
- </div>
180
-
181
- <div class="method-description">
182
- <p><a class="source-toggle" href="#"
183
- onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
184
- <div class="method-source-code" id="M000074-source">
185
- <pre>
186
- <span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 248</span>
187
- 248: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">obj</span>)
188
- 249: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grantee</span>)
189
- 250: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
190
- 251: <span class="ruby-keyword kw">end</span>
191
- 252: <span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span>
192
- 253: <span class="ruby-identifier">method_name</span> = <span class="ruby-identifier">var</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^@/</span>, <span class="ruby-value str">''</span>)
193
- 254: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method_name</span>) <span class="ruby-operator">!=</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method_name</span>)
194
- 255: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
195
- 256: <span class="ruby-keyword kw">end</span>
196
- 257: <span class="ruby-keyword kw">end</span>
197
- 258: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
198
- 259: <span class="ruby-keyword kw">end</span>
199
- </pre>
200
- </div>
201
- </div>
202
- </div>
203
-
204
- <div id="method-M000075" class="method-detail">
205
- <a name="M000075"></a>
206
-
207
- <div class="method-heading">
208
- <a href="#M000075" class="method-signature">
209
- <span class="method-name">method_missing</span><span class="method-args">(*args)</span>
210
- </a>
211
- </div>
212
-
213
- <div class="method-description">
214
- <p><a class="source-toggle" href="#"
215
- onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
216
- <div class="method-source-code" id="M000075-source">
217
- <pre>
218
- <span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 261</span>
219
- 261: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
220
- 262: <span class="ruby-keyword kw">nil</span>
221
- 263: <span class="ruby-keyword kw">end</span>
222
- </pre>
223
- </div>
224
- </div>
225
- </div>
226
-
227
-
228
- </div>
229
-
230
-
231
- </div>
232
-
233
-
234
- <div id="validator-badges">
235
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
236
- </div>
237
-
238
- </body>
239
- </html>
@@ -1,178 +0,0 @@
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: S33r::S3ACL::Group</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">S33r::S3ACL::Group</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/s33r/s3_acl_rb.html">
59
- lib/s33r/s3_acl.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
- <a href="Grantee.html">
69
- Grantee
70
- </a>
71
- </td>
72
- </tr>
73
- </table>
74
- </div>
75
- <!-- banner header -->
76
-
77
- <div id="bodyContent">
78
-
79
-
80
-
81
- <div id="contextContent">
82
-
83
- <div id="description">
84
- <p>
85
- One of the predefined S3 groups.
86
- </p>
87
- <p>
88
- A group must have a type (AllUsers or AuthenticatedUsers).
89
- </p>
90
-
91
- </div>
92
-
93
-
94
- </div>
95
-
96
- <div id="method-list">
97
- <h3 class="section-bar">Methods</h3>
98
-
99
- <div class="name-list">
100
- <a href="#M000060">new</a>&nbsp;&nbsp;
101
- </div>
102
- </div>
103
-
104
- </div>
105
-
106
-
107
- <!-- if includes -->
108
-
109
- <div id="section">
110
-
111
-
112
-
113
-
114
-
115
- <div id="attribute-list">
116
- <h3 class="section-bar">Attributes</h3>
117
-
118
- <div class="name-list">
119
- <table>
120
- <tr class="top-aligned-row context-row">
121
- <td class="context-item-name">group_type</td>
122
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
123
- <td class="context-item-desc"></td>
124
- </tr>
125
- </table>
126
- </div>
127
- </div>
128
-
129
-
130
-
131
- <!-- if method_list -->
132
- <div id="methods">
133
- <h3 class="section-bar">Public Class methods</h3>
134
-
135
- <div id="method-M000060" class="method-detail">
136
- <a name="M000060"></a>
137
-
138
- <div class="method-heading">
139
- <a href="#M000060" class="method-signature">
140
- <span class="method-name">new</span><span class="method-args">(group_type)</span>
141
- </a>
142
- </div>
143
-
144
- <div class="method-description">
145
- <p>
146
- The type of group. A key from S3_GROUP_TYPES to one of the pre-defined
147
- Amazon group types.
148
- </p>
149
- <p><a class="source-toggle" href="#"
150
- onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
151
- <div class="method-source-code" id="M000060-source">
152
- <pre>
153
- <span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 328</span>
154
- 328: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">group_type</span>)
155
- 329: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">S3_GROUP_TYPES</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">group_type</span>)
156
- 330: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidS3GroupType</span>, <span class="ruby-value str">'No such group type #{group_type}'</span>
157
- 331: <span class="ruby-keyword kw">end</span>
158
- 332: <span class="ruby-ivar">@group_type</span> = <span class="ruby-constant">S3_GROUP_TYPES</span>[<span class="ruby-identifier">group_type</span>]
159
- 333: <span class="ruby-ivar">@grantee_type</span> = <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:group</span>]
160
- 334: <span class="ruby-keyword kw">end</span>
161
- </pre>
162
- </div>
163
- </div>
164
- </div>
165
-
166
-
167
- </div>
168
-
169
-
170
- </div>
171
-
172
-
173
- <div id="validator-badges">
174
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
175
- </div>
176
-
177
- </body>
178
- </html>
@@ -1,618 +0,0 @@
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: S33r::S3Object</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">S33r::S3Object</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/s33r/s3_obj_rb.html">
59
- lib/s33r/s3_obj.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
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000096">delete</a>&nbsp;&nbsp;
90
- <a href="#M000089">from_file</a>&nbsp;&nbsp;
91
- <a href="#M000093">from_response</a>&nbsp;&nbsp;
92
- <a href="#M000091">from_xml_node</a>&nbsp;&nbsp;
93
- <a href="#M000090">from_xml_string</a>&nbsp;&nbsp;
94
- <a href="#M000095">load</a>&nbsp;&nbsp;
95
- <a href="#M000087">new</a>&nbsp;&nbsp;
96
- <a href="#M000094">parse_response</a>&nbsp;&nbsp;
97
- <a href="#M000092">parse_xml_node</a>&nbsp;&nbsp;
98
- <a href="#M000097">save</a>&nbsp;&nbsp;
99
- <a href="#M000088">set_properties</a>&nbsp;&nbsp;
100
- </div>
101
- </div>
102
-
103
- </div>
104
-
105
-
106
- <!-- if includes -->
107
-
108
- <div id="section">
109
-
110
-
111
-
112
-
113
-
114
- <div id="attribute-list">
115
- <h3 class="section-bar">Attributes</h3>
116
-
117
- <div class="name-list">
118
- <table>
119
- <tr class="top-aligned-row context-row">
120
- <td class="context-item-name">content_type</td>
121
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
122
- <td class="context-item-desc"></td>
123
- </tr>
124
- <tr class="top-aligned-row context-row">
125
- <td class="context-item-name">etag</td>
126
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
127
- <td class="context-item-desc"></td>
128
- </tr>
129
- <tr class="top-aligned-row context-row">
130
- <td class="context-item-name">key</td>
131
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
132
- <td class="context-item-desc"></td>
133
- </tr>
134
- <tr class="top-aligned-row context-row">
135
- <td class="context-item-name">last_modified</td>
136
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
137
- <td class="context-item-desc"></td>
138
- </tr>
139
- <tr class="top-aligned-row context-row">
140
- <td class="context-item-name">meta</td>
141
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
142
- <td class="context-item-desc">
143
- Metadata set by x-amz-meta- style headers. Note that the bit after
144
- x-amz-meta- is stored for each key, rather than the full key.
145
-
146
- </td>
147
- </tr>
148
- <tr class="top-aligned-row context-row">
149
- <td class="context-item-name">mime_type</td>
150
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
151
- <td class="context-item-desc"></td>
152
- </tr>
153
- <tr class="top-aligned-row context-row">
154
- <td class="context-item-name">named_bucket</td>
155
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
156
- <td class="context-item-desc"></td>
157
- </tr>
158
- <tr class="top-aligned-row context-row">
159
- <td class="context-item-name">owner</td>
160
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
161
- <td class="context-item-desc"></td>
162
- </tr>
163
- <tr class="top-aligned-row context-row">
164
- <td class="context-item-name">size</td>
165
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
166
- <td class="context-item-desc"></td>
167
- </tr>
168
- <tr class="top-aligned-row context-row">
169
- <td class="context-item-name">storage_class</td>
170
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
171
- <td class="context-item-desc"></td>
172
- </tr>
173
- <tr class="top-aligned-row context-row">
174
- <td class="context-item-name">value</td>
175
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
176
- <td class="context-item-desc"></td>
177
- </tr>
178
- </table>
179
- </div>
180
- </div>
181
-
182
-
183
-
184
- <!-- if method_list -->
185
- <div id="methods">
186
- <h3 class="section-bar">Public Class methods</h3>
187
-
188
- <div id="method-M000089" class="method-detail">
189
- <a name="M000089"></a>
190
-
191
- <div class="method-heading">
192
- <a href="#M000089" class="method-signature">
193
- <span class="method-name">from_file</span><span class="method-args">(key, filename)</span>
194
- </a>
195
- </div>
196
-
197
- <div class="method-description">
198
- <p>
199
- To create an object which reads the content in from a file; this is not
200
- very efficient - it&#8217;s actually better to use <a
201
- href="NamedBucket.html#M000111">NamedBucket.put_file</a>, as this will
202
- stream out of a file to S3, rather than load the file in memory first.
203
- </p>
204
- <p><a class="source-toggle" href="#"
205
- onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
206
- <div class="method-source-code" id="M000089-source">
207
- <pre>
208
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 43</span>
209
- 43: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_file</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">filename</span>)
210
- 44: <span class="ruby-identifier">mime_type</span> = <span class="ruby-identifier">guess_mime_type</span>(<span class="ruby-identifier">filename</span>)
211
- 45: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>
212
- 46: <span class="ruby-identifier">value</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>).<span class="ruby-identifier">read</span>
213
- 47: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>, { <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">content_type</span> }, {}, <span class="ruby-identifier">value</span>)
214
- 48: <span class="ruby-keyword kw">end</span>
215
- </pre>
216
- </div>
217
- </div>
218
- </div>
219
-
220
- <div id="method-M000093" class="method-detail">
221
- <a name="M000093"></a>
222
-
223
- <div class="method-heading">
224
- <a href="#M000093" class="method-signature">
225
- <span class="method-name">from_response</span><span class="method-args">(key, resp)</span>
226
- </a>
227
- </div>
228
-
229
- <div class="method-description">
230
- <p>
231
- Create a new instance from a HTTP response. This is useful if you do a GET
232
- for a resource key and want to convert the response into an object; NB the
233
- response doesn&#8217;t necessarily contain all the metadata you might want
234
- - you need to do a HEAD for that.
235
- </p>
236
- <p>
237
- <tt>key</tt> is the key for the resource (not part of the response).
238
- </p>
239
- <p>
240
- Note that if the resp returns nil, a blank object is created.
241
- </p>
242
- <p><a class="source-toggle" href="#"
243
- onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
244
- <div class="method-source-code" id="M000093-source">
245
- <pre>
246
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 93</span>
247
- 93: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_response</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">resp</span>)
248
- 94: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_response</span>(<span class="ruby-identifier">resp</span>)
249
- 95: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>
250
- 96: <span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span> = <span class="ruby-identifier">result</span>
251
- 97: <span class="ruby-keyword kw">else</span>
252
- 98: <span class="ruby-identifier">metadata</span> = {}
253
- 99: <span class="ruby-identifier">amz_meta</span> = {}
254
- 100: <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
255
- 101: <span class="ruby-keyword kw">end</span>
256
- 102: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span>)
257
- 103: <span class="ruby-keyword kw">end</span>
258
- </pre>
259
- </div>
260
- </div>
261
- </div>
262
-
263
- <div id="method-M000091" class="method-detail">
264
- <a name="M000091"></a>
265
-
266
- <div class="method-heading">
267
- <a href="#M000091" class="method-signature">
268
- <span class="method-name">from_xml_node</span><span class="method-args">(doc)</span>
269
- </a>
270
- </div>
271
-
272
- <div class="method-description">
273
- <p>
274
- Create a new instance from an <a href="../XML.html">XML</a> document.
275
- </p>
276
- <p><a class="source-toggle" href="#"
277
- onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
278
- <div class="method-source-code" id="M000091-source">
279
- <pre>
280
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 59</span>
281
- 59: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_node</span>(<span class="ruby-identifier">doc</span>)
282
- 60: <span class="ruby-identifier">metadata</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_xml_node</span>(<span class="ruby-identifier">doc</span>)
283
- 61: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:key</span>], <span class="ruby-identifier">metadata</span>)
284
- 62: <span class="ruby-keyword kw">end</span>
285
- </pre>
286
- </div>
287
- </div>
288
- </div>
289
-
290
- <div id="method-M000090" class="method-detail">
291
- <a name="M000090"></a>
292
-
293
- <div class="method-heading">
294
- <a href="#M000090" class="method-signature">
295
- <span class="method-name">from_xml_string</span><span class="method-args">(xml_str)</span>
296
- </a>
297
- </div>
298
-
299
- <div class="method-description">
300
- <p>
301
- Set properties of the object from an <a href="../XML.html">XML</a> string.
302
- </p>
303
- <p>
304
- <tt>xml_str</tt> should be a string representing a full <a
305
- href="../XML.html">XML</a> document, containing a &lt;Contents&gt; element
306
- as its root element.
307
- </p>
308
- <p><a class="source-toggle" href="#"
309
- onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
310
- <div class="method-source-code" id="M000090-source">
311
- <pre>
312
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 54</span>
313
- 54: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_string</span>(<span class="ruby-identifier">xml_str</span>)
314
- 55: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_node</span>(<span class="ruby-constant">XML</span>.<span class="ruby-identifier">get_xml_doc</span>(<span class="ruby-identifier">xml_str</span>))
315
- 56: <span class="ruby-keyword kw">end</span>
316
- </pre>
317
- </div>
318
- </div>
319
- </div>
320
-
321
- <div id="method-M000087" class="method-detail">
322
- <a name="M000087"></a>
323
-
324
- <div class="method-heading">
325
- <a href="#M000087" class="method-signature">
326
- <span class="method-name">new</span><span class="method-args">(key, metadata={}, amz_meta={}, value=nil)</span>
327
- </a>
328
- </div>
329
-
330
- <div class="method-description">
331
- <p><a class="source-toggle" href="#"
332
- onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
333
- <div class="method-source-code" id="M000087-source">
334
- <pre>
335
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 13</span>
336
- 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">metadata</span>={}, <span class="ruby-identifier">amz_meta</span>={}, <span class="ruby-identifier">value</span>=<span class="ruby-keyword kw">nil</span>)
337
- 14: <span class="ruby-ivar">@key</span> = <span class="ruby-identifier">key</span>
338
- 15: <span class="ruby-ivar">@meta</span> = <span class="ruby-identifier">amz_meta</span>
339
- 16: <span class="ruby-ivar">@value</span> = <span class="ruby-identifier">value</span>
340
- 17: <span class="ruby-identifier">set_properties</span>(<span class="ruby-identifier">metadata</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">metadata</span>.<span class="ruby-identifier">empty?</span>
341
- 18: <span class="ruby-keyword kw">end</span>
342
- </pre>
343
- </div>
344
- </div>
345
- </div>
346
-
347
- <div id="method-M000094" class="method-detail">
348
- <a name="M000094"></a>
349
-
350
- <div class="method-heading">
351
- <a href="#M000094" class="method-signature">
352
- <span class="method-name">parse_response</span><span class="method-args">(resp)</span>
353
- </a>
354
- </div>
355
-
356
- <div class="method-description">
357
- <p>
358
- Parse the response returned by GET on a resource key within a bucket.
359
- </p>
360
- <p>
361
- <tt>resp</tt> is a <a href="../Net/HTTPResponse.html">Net::HTTPResponse</a>
362
- instance.
363
- </p>
364
- <p>
365
- Returns an array [<tt>metadata</tt>, +response.body+]; or nil if the object
366
- doesn&#8217;t exist.
367
- </p>
368
- <p><a class="source-toggle" href="#"
369
- onclick="toggleCode('M000094-source');return false;">[Source]</a></p>
370
- <div class="method-source-code" id="M000094-source">
371
- <pre>
372
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 112</span>
373
- 112: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_response</span>(<span class="ruby-identifier">resp</span>)
374
- 113: <span class="ruby-identifier">resp_headers</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">to_hash</span>
375
- 114:
376
- 115: <span class="ruby-comment cmt"># If there's no etag, there's no content in the resource.</span>
377
- 116: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'etag'</span>]
378
- 117: <span class="ruby-identifier">metadata</span> = {}
379
- 118: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'last-modified'</span>][<span class="ruby-value">0</span>]
380
- 119: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'etag'</span>][<span class="ruby-value">0</span>]
381
- 120: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'content-length'</span>][<span class="ruby-value">0</span>]
382
- 121: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:content_type</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'content-type'</span>][<span class="ruby-value">0</span>]
383
- 122:
384
- 123: <span class="ruby-comment cmt"># x-amz-meta- response headers.</span>
385
- 124: <span class="ruby-identifier">interesting_header</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">METADATA_PREFIX</span>)
386
- 125: <span class="ruby-identifier">amz_meta</span> = {}
387
- 126: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">each_header</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
388
- 127: <span class="ruby-identifier">amz_meta</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">interesting_header</span>, <span class="ruby-value str">''</span>)] = <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">interesting_header</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">key</span>
389
- 128: <span class="ruby-keyword kw">end</span>
390
- 129:
391
- 130: <span class="ruby-comment cmt"># The actual content of the S3 object.</span>
392
- 131: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>
393
- 132:
394
- 133: [<span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span>]
395
- 134: <span class="ruby-keyword kw">else</span>
396
- 135: <span class="ruby-keyword kw">nil</span>
397
- 136: <span class="ruby-keyword kw">end</span>
398
- 137: <span class="ruby-keyword kw">end</span>
399
- </pre>
400
- </div>
401
- </div>
402
- </div>
403
-
404
- <div id="method-M000092" class="method-detail">
405
- <a name="M000092"></a>
406
-
407
- <div class="method-heading">
408
- <a href="#M000092" class="method-signature">
409
- <span class="method-name">parse_xml_node</span><span class="method-args">(doc)</span>
410
- </a>
411
- </div>
412
-
413
- <div class="method-description">
414
- <p>
415
- Get properties of the object from an <a href="../XML.html">XML</a>
416
- document, e.g. as returned in a bucket listing.
417
- </p>
418
- <p>
419
- <tt>doc</tt>: <a href="../XML/Document.html">XML::Document</a> instance to
420
- parse to get properties for this object.
421
- </p>
422
- <p>
423
- Returns the metadata relating to the object, as stored on S3.
424
- </p>
425
- <p><a class="source-toggle" href="#"
426
- onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
427
- <div class="method-source-code" id="M000092-source">
428
- <pre>
429
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 70</span>
430
- 70: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_xml_node</span>(<span class="ruby-identifier">doc</span>)
431
- 71: <span class="ruby-identifier">metadata</span> = {}
432
- 72: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:key</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'Key'</span>)
433
- 73: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'LastModified'</span>)
434
- 74: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'ETag'</span>)
435
- 75: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'Size'</span>)
436
- 76:
437
- 77: <span class="ruby-comment cmt"># Build representation of the owner.</span>
438
- 78: <span class="ruby-identifier">user_xml_doc</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">'Owner'</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">first</span>
439
- 79: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:owner</span>] = <span class="ruby-constant">S3ACL</span><span class="ruby-operator">::</span><span class="ruby-constant">CanonicalUser</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">user_xml_doc</span>)
440
- 80:
441
- 81: <span class="ruby-identifier">metadata</span>
442
- 82: <span class="ruby-keyword kw">end</span>
443
- </pre>
444
- </div>
445
- </div>
446
- </div>
447
-
448
- <h3 class="section-bar">Public Instance methods</h3>
449
-
450
- <div id="method-M000096" class="method-detail">
451
- <a name="M000096"></a>
452
-
453
- <div class="method-heading">
454
- <a href="#M000096" class="method-signature">
455
- <span class="method-name">delete</span><span class="method-args">()</span>
456
- </a>
457
- </div>
458
-
459
- <div class="method-description">
460
- <p>
461
- Remove this object from its associated <a
462
- href="NamedBucket.html">NamedBucket</a>.
463
- </p>
464
- <p>
465
- Returns false if this object is not associated with a bucket; otherwise
466
- returns the response from S3.
467
- </p>
468
- <p><a class="source-toggle" href="#"
469
- onclick="toggleCode('M000096-source');return false;">[Source]</a></p>
470
- <div class="method-source-code" id="M000096-source">
471
- <pre>
472
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 163</span>
473
- 163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>
474
- 164: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">nil?</span>
475
- 165: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
476
- 166: <span class="ruby-keyword kw">else</span>
477
- 167: <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">delete_resource</span>(<span class="ruby-ivar">@key</span>)
478
- 168: <span class="ruby-keyword kw">end</span>
479
- 169: <span class="ruby-keyword kw">end</span>
480
- </pre>
481
- </div>
482
- </div>
483
- </div>
484
-
485
- <div id="method-M000095" class="method-detail">
486
- <a name="M000095"></a>
487
-
488
- <div class="method-heading">
489
- <a href="#M000095" class="method-signature">
490
- <span class="method-name">load</span><span class="method-args">()</span>
491
- </a>
492
- </div>
493
-
494
- <div class="method-description">
495
- <p>
496
- Load content into this object from S3; will perform an HTTP request to
497
- &quot;refresh&quot; the object (providing the object has an association
498
- with a bucket it can use for piggybacking).
499
- </p>
500
- <p>
501
- Returns false if value cannot be retrieved.
502
- </p>
503
- <p><a class="source-toggle" href="#"
504
- onclick="toggleCode('M000095-source');return false;">[Source]</a></p>
505
- <div class="method-source-code" id="M000095-source">
506
- <pre>
507
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 144</span>
508
- 144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load</span>
509
- 145: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">key_exists?</span>(<span class="ruby-ivar">@key</span>)
510
- 146: <span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">get_raw</span>(<span class="ruby-ivar">@key</span>)
511
- 147: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">ok?</span>
512
- 148: <span class="ruby-ivar">@value</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>
513
- 149: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">to_hash</span>[<span class="ruby-value str">'content-type'</span>]
514
- 150: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
515
- 151: <span class="ruby-keyword kw">else</span>
516
- 152: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
517
- 153: <span class="ruby-keyword kw">end</span>
518
- 154: <span class="ruby-keyword kw">else</span>
519
- 155: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
520
- 156: <span class="ruby-keyword kw">end</span>
521
- 157: <span class="ruby-keyword kw">end</span>
522
- </pre>
523
- </div>
524
- </div>
525
- </div>
526
-
527
- <div id="method-M000097" class="method-detail">
528
- <a name="M000097"></a>
529
-
530
- <div class="method-heading">
531
- <a href="#M000097" class="method-signature">
532
- <span class="method-name">save</span><span class="method-args">()</span>
533
- </a>
534
- </div>
535
-
536
- <div class="method-description">
537
- <p>
538
- Save this object back into its bucket.
539
- </p>
540
- <p>
541
- Only works if the object has an associated <a
542
- href="NamedBucket.html">NamedBucket</a>; returns false if it doesn&#8217;t.
543
- </p>
544
- <p><a class="source-toggle" href="#"
545
- onclick="toggleCode('M000097-source');return false;">[Source]</a></p>
546
- <div class="method-source-code" id="M000097-source">
547
- <pre>
548
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 175</span>
549
- 175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>
550
- 176: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">nil?</span>
551
- 177: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
552
- 178: <span class="ruby-keyword kw">else</span>
553
- 179: <span class="ruby-identifier">headers</span> = {}
554
- 180: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>] = <span class="ruby-ivar">@content_type</span> <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
555
- 181: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">metadata_headers</span>(<span class="ruby-identifier">headers</span>, <span class="ruby-identifier">meta</span>)
556
- 182: <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">put_stream</span>(<span class="ruby-ivar">@value</span>, <span class="ruby-ivar">@key</span>, <span class="ruby-identifier">headers</span>)
557
- 183: <span class="ruby-keyword kw">end</span>
558
- 184: <span class="ruby-keyword kw">end</span>
559
- </pre>
560
- </div>
561
- </div>
562
- </div>
563
-
564
- <div id="method-M000088" class="method-detail">
565
- <a name="M000088"></a>
566
-
567
- <div class="method-heading">
568
- <a href="#M000088" class="method-signature">
569
- <span class="method-name">set_properties</span><span class="method-args">(metadata)</span>
570
- </a>
571
- </div>
572
-
573
- <div class="method-description">
574
- <p>
575
- Set the properties of the object from some metadata name-value pairs.
576
- </p>
577
- <p>
578
- <tt>metadata</tt> is a hash of properties and their values, used to set the
579
- corresponding properties on the object.
580
- </p>
581
- <p>
582
- <tt>value</tt> is the data associated with the object on S3.
583
- </p>
584
- <p><a class="source-toggle" href="#"
585
- onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
586
- <div class="method-source-code" id="M000088-source">
587
- <pre>
588
- <span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 26</span>
589
- 26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_properties</span>(<span class="ruby-identifier">metadata</span>)
590
- 27: <span class="ruby-comment cmt"># required properties</span>
591
- 28: <span class="ruby-ivar">@etag</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;\&quot;&quot;</span>, <span class="ruby-value str">&quot;&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>]
592
- 29: <span class="ruby-ivar">@last_modified</span> = <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>]
593
- 30: <span class="ruby-ivar">@size</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>]
594
- 31:
595
- 32: <span class="ruby-comment cmt"># only set if creating object from XML (not available otherwise)</span>
596
- 33: <span class="ruby-ivar">@owner</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:owner</span>]
597
- 34:
598
- 35: <span class="ruby-comment cmt"># only set if creating object from HTTP response</span>
599
- 36: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:content_type</span>]
600
- 37: <span class="ruby-keyword kw">end</span>
601
- </pre>
602
- </div>
603
- </div>
604
- </div>
605
-
606
-
607
- </div>
608
-
609
-
610
- </div>
611
-
612
-
613
- <div id="validator-badges">
614
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
615
- </div>
616
-
617
- </body>
618
- </html>