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
data/test/files/acl.xml CHANGED
@@ -25,12 +25,6 @@
25
25
  </Grantee>
26
26
  <Permission>READ</Permission>
27
27
  </Grant>
28
- <Grant>
29
- <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail">
30
- <EmailAddress>bingo@blinky.com</EmailAddress>
31
- </Grantee>
32
- <Permission>WRITE</Permission>
33
- </Grant>
34
28
  <Grant>
35
29
  <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
36
30
  <URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
@@ -0,0 +1,5 @@
1
+ access: '44CF9590006BF252F707'
2
+ secret: <%= Testing::SECRET_ACCESS_KEY %>
3
+ use_ssl: false
4
+ options:
5
+ email_to: 'elliot@somedomain.com'
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ </BucketLoggingStatus>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ <LoggingEnabled>
4
+ <TargetBucket>mylogs</TargetBucket>
5
+ <TargetPrefix>mybucket-access_log-</TargetPrefix>
6
+ </LoggingEnabled>
7
+ </BucketLoggingStatus>
data/test/test_setup.rb CHANGED
@@ -4,14 +4,19 @@ require_gem 'rspec'
4
4
 
5
5
  require File.dirname(__FILE__) + '/../lib/s33r'
6
6
  include S33r
7
- include S33r::S33rException
8
- include S33r::Sync
7
+ include S33r::S3Exception
9
8
  include S33r::S3ACL
9
+ include S33r::S3Logging
10
10
 
11
11
  # set up some constants
12
12
  module Testing
13
13
  ACCESS_KEY = '44CF9590006BF252F707'
14
14
  SECRET_ACCESS_KEY = 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
15
+ EMAIL = 'elliot@somedomain.com'
16
+ end
17
+
18
+ def load_test_xml(filename)
19
+ clean_xml(File.open(File.join(File.dirname(__FILE__), '/files', filename)).read)
15
20
  end
16
21
 
17
22
  # convenience for highlighting tasks
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: s33r
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.2
7
- date: 2007-01-03 00:00:00 +00:00
6
+ version: "0.5"
7
+ date: 2007-01-17 00:00:00 +00:00
8
8
  summary: A library for accessing Amazon S3
9
9
  require_paths:
10
10
  - lib
@@ -44,7 +44,6 @@ files:
44
44
  - examples/fores33r/vendor
45
45
  - examples/fores33r/public
46
46
  - examples/fores33r/Rakefile
47
- - examples/fores33r/README
48
47
  - examples/fores33r/test/unit
49
48
  - examples/fores33r/test/functional
50
49
  - examples/fores33r/test/integration
@@ -73,6 +72,8 @@ files:
73
72
  - examples/fores33r/tmp/cache
74
73
  - examples/fores33r/tmp/sessions
75
74
  - examples/fores33r/tmp/sockets
75
+ - examples/fores33r/log/development.log
76
+ - examples/fores33r/log/mongrel.log
76
77
  - examples/fores33r/script/performance
77
78
  - examples/fores33r/script/process
78
79
  - examples/fores33r/script/breakpointer
@@ -116,38 +117,34 @@ files:
116
117
  - examples/fores33r/public/javascripts/controls.js
117
118
  - examples/fores33r/public/stylesheets/core.css
118
119
  - examples/cli/simple.rb
119
- - examples/cli/logging_x.rb
120
120
  - examples/cli/s3cli.rb
121
- - examples/cli/acl_x.rb
121
+ - examples/cli/instant_download_server.rb
122
122
  - lib/s33r
123
123
  - lib/s33r.rb
124
124
  - lib/s33r/bucket_listing.rb
125
125
  - lib/s33r/libxml_loader.rb
126
- - lib/s33r/client.rb
127
- - lib/s33r/named_bucket.rb
126
+ - lib/s33r/utility.rb
128
127
  - lib/s33r/s3_acl.rb
129
128
  - lib/s33r/s3_obj.rb
130
129
  - lib/s33r/builder.rb
131
- - lib/s33r/logging.rb
130
+ - lib/s33r/client.rb
132
131
  - lib/s33r/libxml_extensions.rb
133
- - lib/s33r/core.rb
134
132
  - lib/s33r/s33r_http.rb
135
133
  - lib/s33r/s33r_exception.rb
136
134
  - lib/s33r/mimetypes.rb
137
- - lib/s33r/sync.rb
135
+ - lib/s33r/bucket.rb
136
+ - lib/s33r/networking.rb
137
+ - lib/s33r/s3_logging.rb
138
138
  - test/files
139
139
  - test/cases
140
- - test/test_bucket_setup.rb
141
140
  - test/test_setup.rb
142
141
  - test/files/textfile.txt
143
142
  - test/files/wave.jpg
144
- - test/files/namedbucket_config2.yml
145
143
  - test/files/bucket_listing2.xml
146
- - test/files/all_buckets.xml
144
+ - test/files/config.yaml
147
145
  - test/files/bucket_listing3.xml
148
146
  - test/files/acl.xml
149
- - test/files/namedbucket_config.yml
150
- - test/files/client_config.yml
147
+ - test/files/logging_status_enabled.xml
151
148
  - test/files/logging_acl.xml
152
149
  - test/files/bucket_listing.xml
153
150
  - test/files/bucket_listing_broken.xml
@@ -157,89 +154,14 @@ files:
157
154
  - test/files/suspect_bucket_listing.xml
158
155
  - test/files/acl_grant3.xml
159
156
  - test/files/acl_grant4.xml
157
+ - test/files/logging_status_disabled.xml
160
158
  - test/cases/spec_bucket_listing.rb
161
159
  - test/cases/spec_s3_object.rb
162
- - test/cases/spec_all_buckets.rb
163
- - test/cases/spec_core.rb
164
- - test/cases/spec_sync.rb
165
- - test/cases/spec_client.rb
160
+ - test/cases/spec_logging.rb
166
161
  - test/cases/spec_acl.rb
167
162
  - test/cases/spec_xml.rb
168
- - test/cases/spec_namedbucket.rb
169
- - html/created.rid
170
- - html/rdoc-style.css
171
- - html/files
172
- - html/classes
173
- - html/fr_file_index.html
174
- - html/fr_class_index.html
175
- - html/fr_method_index.html
176
- - html/index.html
177
- - html/files/README_txt.html
178
- - html/files/MIT-LICENSE.html
179
- - html/files/CHANGELOG.html
180
- - html/files/lib
181
- - html/files/lib/s33r_rb.html
182
- - html/files/lib/s33r
183
- - html/files/lib/s33r/bucket_listing_rb.html
184
- - html/files/lib/s33r/libxml_loader_rb.html
185
- - html/files/lib/s33r/client_rb.html
186
- - html/files/lib/s33r/named_bucket_rb.html
187
- - html/files/lib/s33r/s3_acl_rb.html
188
- - html/files/lib/s33r/s3_obj_rb.html
189
- - html/files/lib/s33r/builder_rb.html
190
- - html/files/lib/s33r/logging_rb.html
191
- - html/files/lib/s33r/libxml_extensions_rb.html
192
- - html/files/lib/s33r/core_rb.html
193
- - html/files/lib/s33r/s33r_http_rb.html
194
- - html/files/lib/s33r/s33r_exception_rb.html
195
- - html/files/lib/s33r/mimetypes_rb.html
196
- - html/files/lib/s33r/sync_rb.html
197
- - html/classes/XML.html
198
- - html/classes/XML
199
- - html/classes/Net.html
200
- - html/classes/Net
201
- - html/classes/MIME.html
202
- - html/classes/MIME
203
- - html/classes/S33r.html
204
- - html/classes/S33r
205
- - html/classes/XML/Node.html
206
- - html/classes/XML/Document.html
207
- - html/classes/Net/HTTPGenericRequest.html
208
- - html/classes/Net/HTTPResponse.html
209
- - html/classes/MIME/Types.html
210
- - html/classes/MIME/InvalidContentType.html
211
- - html/classes/MIME/Type.html
212
- - html/classes/S33r/Sync.html
213
- - html/classes/S33r/S33rException.html
214
- - html/classes/S33r/S33rException
215
- - html/classes/S33r/S3ACL.html
216
- - html/classes/S33r/S3ACL
217
- - html/classes/S33r/LoggingResource.html
218
- - html/classes/S33r/S3Object.html
219
- - html/classes/S33r/NamedBucket.html
220
- - html/classes/S33r/Client.html
221
- - html/classes/S33r/BucketListing.html
222
- - html/classes/S33r/OrderlyXmlMarkup.html
223
- - html/classes/S33r/S33rException/MissingResource.html
224
- - html/classes/S33r/S33rException/InvalidBucketListing.html
225
- - html/classes/S33r/S33rException/BucketListingMaxKeysError.html
226
- - html/classes/S33r/S33rException/MissingBucketName.html
227
- - html/classes/S33r/S33rException/MalformedBucketName.html
228
- - html/classes/S33r/S33rException/MissingRequiredHeaders.html
229
- - html/classes/S33r/S33rException/MethodNotAvailable.html
230
- - html/classes/S33r/S33rException/InvalidPermission.html
231
- - html/classes/S33r/S33rException/InvalidS3GroupType.html
232
- - html/classes/S33r/S33rException/S3FallenOver.html
233
- - html/classes/S33r/S33rException/UnsupportedCannedACL.html
234
- - html/classes/S33r/S33rException/TryingToPutEmptyResource.html
235
- - html/classes/S33r/S33rException/UnsupportedHTTPMethod.html
236
- - html/classes/S33r/S33rException/BucketNotLogTargetable.html
237
- - html/classes/S33r/S3ACL/Group.html
238
- - html/classes/S33r/S3ACL/CanonicalUser.html
239
- - html/classes/S33r/S3ACL/AmazonCustomer.html
240
- - html/classes/S33r/S3ACL/ACLDoc.html
241
- - html/classes/S33r/S3ACL/Grantee.html
242
- - html/classes/S33r/S3ACL/Grant.html
163
+ - test/cases/spec_utility.rb
164
+ - test/cases/spec_networking.rb
243
165
  test_files: []
244
166
 
245
167
  rdoc_options: []
@@ -1,41 +0,0 @@
1
- # Example of how to manipulate ACLs (see s3_acl.rb or rdoc for all ACL classes)
2
-
3
- require File.join(File.dirname(__FILE__), '../../lib/s33r')
4
- include S33r
5
- include S33r::S3ACL
6
-
7
- # initialise the client from a config file
8
- # (see s3.yaml in examples directory)
9
- c = Client.init('/home/ell/.s33r')
10
-
11
- # bucket whose ACL we're going to manipulate
12
- bucket = 'es-test'
13
-
14
- # get the ACL for the bucket
15
- acl = c.get_acl(bucket)
16
-
17
- # add a new grant to the ACL (allow all users read access)
18
- acl.add_grant(Grant.for_group(:all_users, :read))
19
-
20
- # remove a grant from the ACL;
21
- # note that s33r is able to compare existing grants in
22
- # an ACL with newly-minted ones
23
- acl.remove_grant(Grant.for_group(:authenticated_users, :read))
24
-
25
- # put the ACL back
26
- c.set_acl(acl, bucket)
27
-
28
- # get the ACL for a resource inside the bucket
29
- # and make it readable by a specific Amazon customer
30
- resource = 'test'
31
-
32
- # NB this method raises an error if the resource doesn't exist
33
- acl = c.get_acl(bucket, resource)
34
-
35
- # the email address you set here needs to be a valid Amazon customer
36
- acl.add_grant(Grant.for_amazon_customer('elliot@example.com', :read))
37
- p c.set_acl(acl, bucket, resource)
38
-
39
- # short-hand for making a resource public
40
- # c.make_public(bucket)
41
- # c.make_public(bucket, resource)
@@ -1,20 +0,0 @@
1
- # Example of how to set up logging on a bucket or resource.
2
-
3
- require File.join(File.dirname(__FILE__), '../../lib/s33r')
4
- include S33r
5
-
6
- # initialise the client from a config file
7
- # (see s3.yaml in examples directory)
8
- c = Client.init('/home/ell/.s33r')
9
-
10
- # Make a logging destination
11
- # This sets the required ACLs on a bucket to make it writeable by the
12
- # logging processes.
13
- c.enable_log_target('my-logging-bucket')
14
-
15
- # Set up logging for a bucket.
16
- c.enable_logging('es-test', 'my-logging-bucket')
17
-
18
- # Set up logging for a bucket with a custom log prefix.
19
- # (Default prefix is the name of the bucket which has logging enabled + "'")
20
- c.enable_logging('es-test2', 'my-logging-bucket', :prefix => 'special-logs-')
@@ -1,183 +0,0 @@
1
- == Welcome to Rails
2
-
3
- Rails is a web-application and persistence framework that includes everything
4
- needed to create database-backed web-applications according to the
5
- Model-View-Control pattern of separation. This pattern splits the view (also
6
- called the presentation) into "dumb" templates that are primarily responsible
7
- for inserting pre-built data in between HTML tags. The model contains the
8
- "smart" domain objects (such as Account, Product, Person, Post) that holds all
9
- the business logic and knows how to persist themselves to a database. The
10
- controller handles the incoming requests (such as Save New Account, Update
11
- Product, Show Post) by manipulating the model and directing data to the view.
12
-
13
- In Rails, the model is handled by what's called an object-relational mapping
14
- layer entitled Active Record. This layer allows you to present the data from
15
- database rows as objects and embellish these data objects with business logic
16
- methods. You can read more about Active Record in
17
- link:files/vendor/rails/activerecord/README.html.
18
-
19
- The controller and view are handled by the Action Pack, which handles both
20
- layers by its two parts: Action View and Action Controller. These two layers
21
- are bundled in a single package due to their heavy interdependence. This is
22
- unlike the relationship between the Active Record and Action Pack that is much
23
- more separate. Each of these packages can be used independently outside of
24
- Rails. You can read more about Action Pack in
25
- link:files/vendor/rails/actionpack/README.html.
26
-
27
-
28
- == Getting started
29
-
30
- 1. Start the web server: <tt>ruby script/server</tt> (run with --help for options)
31
- 2. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
32
- 3. Follow the guidelines to start developing your application
33
-
34
-
35
- == Web servers
36
-
37
- Rails uses the built-in web server in Ruby called WEBrick by default, so you don't
38
- have to install or configure anything to play around.
39
-
40
- If you have lighttpd installed, though, it'll be used instead when running script/server.
41
- It's considerably faster than WEBrick and suited for production use, but requires additional
42
- installation and currently only works well on OS X/Unix (Windows users are encouraged
43
- to start with WEBrick). We recommend version 1.4.11 and higher. You can download it from
44
- http://www.lighttpd.net.
45
-
46
- If you want something that's halfway between WEBrick and lighttpd, we heartily recommend
47
- Mongrel. It's a Ruby-based web server with a C-component (so it requires compilation) that
48
- also works very well with Windows. See more at http://mongrel.rubyforge.org/.
49
-
50
- But of course its also possible to run Rails with the premiere open source web server Apache.
51
- To get decent performance, though, you'll need to install FastCGI. For Apache 1.3, you want
52
- to use mod_fastcgi. For Apache 2.0+, you want to use mod_fcgid.
53
-
54
- See http://wiki.rubyonrails.com/rails/pages/FastCGI for more information on FastCGI.
55
-
56
- == Example for Apache conf
57
-
58
- <VirtualHost *:80>
59
- ServerName rails
60
- DocumentRoot /path/application/public/
61
- ErrorLog /path/application/log/server.log
62
-
63
- <Directory /path/application/public/>
64
- Options ExecCGI FollowSymLinks
65
- AllowOverride all
66
- Allow from all
67
- Order allow,deny
68
- </Directory>
69
- </VirtualHost>
70
-
71
- NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
72
- should be on and ".cgi" should respond. All requests from 127.0.0.1 go
73
- through CGI, so no Apache restart is necessary for changes. All other requests
74
- go through FCGI (or mod_ruby), which requires a restart to show changes.
75
-
76
-
77
- == Debugging Rails
78
-
79
- Have "tail -f" commands running on both the server.log, production.log, and
80
- test.log files. Rails will automatically display debugging and runtime
81
- information to these files. Debugging info will also be shown in the browser
82
- on requests from 127.0.0.1.
83
-
84
-
85
- == Breakpoints
86
-
87
- Breakpoint support is available through the script/breakpointer client. This
88
- means that you can break out of execution at any point in the code, investigate
89
- and change the model, AND then resume execution! Example:
90
-
91
- class WeblogController < ActionController::Base
92
- def index
93
- @posts = Post.find_all
94
- breakpoint "Breaking out from the list"
95
- end
96
- end
97
-
98
- So the controller will accept the action, run the first line, then present you
99
- with a IRB prompt in the breakpointer window. Here you can do things like:
100
-
101
- Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
102
-
103
- >> @posts.inspect
104
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
105
- #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
106
- >> @posts.first.title = "hello from a breakpoint"
107
- => "hello from a breakpoint"
108
-
109
- ...and even better is that you can examine how your runtime objects actually work:
110
-
111
- >> f = @posts.first
112
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
113
- >> f.
114
- Display all 152 possibilities? (y or n)
115
-
116
- Finally, when you're ready to resume execution, you press CTRL-D
117
-
118
-
119
- == Console
120
-
121
- You can interact with the domain model by starting the console through script/console.
122
- Here you'll have all parts of the application configured, just like it is when the
123
- application is running. You can inspect domain models, change values, and save to the
124
- database. Starting the script without arguments will launch it in the development environment.
125
- Passing an argument will specify a different environment, like <tt>script/console production</tt>.
126
-
127
- To reload your controllers and models after launching the console run <tt>reload!</tt>
128
-
129
-
130
-
131
- == Description of contents
132
-
133
- app
134
- Holds all the code that's specific to this particular application.
135
-
136
- app/controllers
137
- Holds controllers that should be named like weblog_controller.rb for
138
- automated URL mapping. All controllers should descend from
139
- ActionController::Base.
140
-
141
- app/models
142
- Holds models that should be named like post.rb.
143
- Most models will descend from ActiveRecord::Base.
144
-
145
- app/views
146
- Holds the template files for the view that should be named like
147
- weblog/index.rhtml for the WeblogController#index action. All views use eRuby
148
- syntax. This directory can also be used to keep stylesheets, images, and so on
149
- that can be symlinked to public.
150
-
151
- app/helpers
152
- Holds view helpers that should be named like weblog_helper.rb.
153
-
154
- app/apis
155
- Holds API classes for web services.
156
-
157
- config
158
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
159
-
160
- components
161
- Self-contained mini-applications that can bundle together controllers, models, and views.
162
-
163
- db
164
- Contains the database schema in schema.rb. db/migrate contains all
165
- the sequence of Migrations for your schema.
166
-
167
- lib
168
- Application specific libraries. Basically, any kind of custom code that doesn't
169
- belong under controllers, models, or helpers. This directory is in the load path.
170
-
171
- public
172
- The directory available for the web server. Contains subdirectories for images, stylesheets,
173
- and javascripts. Also contains the dispatchers and the default HTML files.
174
-
175
- script
176
- Helper scripts for automation and generation.
177
-
178
- test
179
- Unit and functional tests along with fixtures.
180
-
181
- vendor
182
- External libraries that the application depends on. Also includes the plugins subdirectory.
183
- This directory is in the load path.