swiftiply 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +2 -0
- data/README +1 -1
- data/bin/echo_client +26 -0
- data/bin/swiftiply +21 -8
- data/ext/fastfilereader/extconf.rb +161 -0
- data/ext/fastfilereader/mapper.cpp +200 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/external/test_support.rb +13 -0
- data/setup.rb +7 -2
- data/src/fastfilereader.rb +109 -0
- data/src/swiftcore/Swiftiply.rb +432 -103
- data/src/swiftcore/Swiftiply/support_pagecache.rb +56 -0
- data/src/swiftcore/Swiftiply/swiftiply_client.rb +57 -0
- data/src/swiftcore/evented_mongrel.rb +32 -4
- data/src/swiftcore/swiftiplied_mongrel.rb +50 -38
- data/src/swiftcore/types.rb +1583 -0
- data/swiftiply.gemspec +4 -4
- data/test/TC_ProxyBag.rb +185 -0
- data/test/TC_Swiftiply.rb +458 -0
- data/test/TC_Swiftiply/mongrel/evented_hello.rb +25 -0
- data/test/TC_Swiftiply/mongrel/swiftiplied_hello.rb +25 -0
- data/test/TC_Swiftiply/mongrel/threaded_hello.rb +25 -0
- data/test/TC_Swiftiply/slow_echo_client +26 -0
- metadata +34 -121
- data/src/ramaze/adapter/evented_mongrel.rb +0 -2
- data/src/ramaze/adapter/swiftiplied_mongrel.rb +0 -2
- data/test/rails/README +0 -182
- data/test/rails/Rakefile +0 -10
- data/test/rails/app/controllers/application.rb +0 -6
- data/test/rails/app/controllers/tests_controller.rb +0 -15
- data/test/rails/app/helpers/application_helper.rb +0 -3
- data/test/rails/config/boot.rb +0 -45
- data/test/rails/config/database.yml +0 -36
- data/test/rails/config/environment.rb +0 -60
- data/test/rails/config/environments/development.rb +0 -21
- data/test/rails/config/environments/production.rb +0 -18
- data/test/rails/config/environments/production_no_caching.rb +0 -18
- data/test/rails/config/environments/test.rb +0 -19
- data/test/rails/config/routes.rb +0 -23
- data/test/rails/doc/README_FOR_APP +0 -2
- data/test/rails/observe_ram.rb +0 -10
- data/test/rails/public/404.html +0 -30
- data/test/rails/public/500.html +0 -30
- data/test/rails/public/dispatch.cgi +0 -10
- data/test/rails/public/dispatch.fcgi +0 -24
- data/test/rails/public/dispatch.rb +0 -10
- data/test/rails/public/favicon.ico +0 -0
- data/test/rails/public/images/rails.png +0 -0
- data/test/rails/public/index.html +0 -277
- data/test/rails/public/javascripts/application.js +0 -2
- data/test/rails/public/javascripts/controls.js +0 -833
- data/test/rails/public/javascripts/dragdrop.js +0 -942
- data/test/rails/public/javascripts/effects.js +0 -1088
- data/test/rails/public/javascripts/prototype.js +0 -2515
- data/test/rails/public/robots.txt +0 -1
- data/test/rails/script/about +0 -3
- data/test/rails/script/breakpointer +0 -3
- data/test/rails/script/console +0 -3
- data/test/rails/script/destroy +0 -3
- data/test/rails/script/generate +0 -3
- data/test/rails/script/performance/benchmarker +0 -3
- data/test/rails/script/performance/profiler +0 -3
- data/test/rails/script/plugin +0 -3
- data/test/rails/script/process/inspector +0 -3
- data/test/rails/script/process/reaper +0 -3
- data/test/rails/script/process/spawner +0 -3
- data/test/rails/script/runner +0 -3
- data/test/rails/script/server +0 -3
- data/test/rails/test/test_helper.rb +0 -28
- data/test/ramaze/conf/benchmark.yaml +0 -35
- data/test/ramaze/conf/debug.yaml +0 -34
- data/test/ramaze/conf/live.yaml +0 -33
- data/test/ramaze/conf/silent.yaml +0 -31
- data/test/ramaze/conf/stage.yaml +0 -33
- data/test/ramaze/main.rb +0 -18
- data/test/ramaze/public/404.jpg +0 -0
- data/test/ramaze/public/css/coderay.css +0 -105
- data/test/ramaze/public/css/ramaze_error.css +0 -42
- data/test/ramaze/public/error.zmr +0 -77
- data/test/ramaze/public/favicon.ico +0 -0
- data/test/ramaze/public/js/jquery.js +0 -1923
- data/test/ramaze/public/ramaze.png +0 -0
- data/test/ramaze/src/controller/main.rb +0 -8
- data/test/ramaze/src/element/page.rb +0 -17
- data/test/ramaze/src/model.rb +0 -6
- data/test/ramaze/template/index.xhtml +0 -6
- data/test/ramaze/yaml.db +0 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
load_attempted ||= false
|
3
|
+
require 'swiftcore/evented_mongrel'
|
4
|
+
rescue LoadError => e
|
5
|
+
unless load_attempted
|
6
|
+
load_attempted = true
|
7
|
+
require 'rubygems'
|
8
|
+
retry
|
9
|
+
end
|
10
|
+
raise e
|
11
|
+
end
|
12
|
+
|
13
|
+
class SimpleHandler < Mongrel::HttpHandler
|
14
|
+
def process(request, response)
|
15
|
+
response.start(200) do |head,out|
|
16
|
+
head["Content-Type"] = "text/plain"
|
17
|
+
out.write("hello!\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
httpserver = Mongrel::HttpServer.new("127.0.0.1", 29998)
|
23
|
+
httpserver.register("/hello", SimpleHandler.new)
|
24
|
+
httpserver.register("/dir", Mongrel::DirHandler.new("."))
|
25
|
+
httpserver.run.join
|
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
load_attempted ||= false
|
3
|
+
require 'swiftcore/swiftiplied_mongrel'
|
4
|
+
rescue LoadError => e
|
5
|
+
unless load_attempted
|
6
|
+
load_attempted = true
|
7
|
+
require 'rubygems'
|
8
|
+
retry
|
9
|
+
end
|
10
|
+
raise e
|
11
|
+
end
|
12
|
+
|
13
|
+
class SimpleHandler < Mongrel::HttpHandler
|
14
|
+
def process(request, response)
|
15
|
+
response.start(200) do |head,out|
|
16
|
+
head["Content-Type"] = "text/plain"
|
17
|
+
out.write("hello!\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
httpserver = Mongrel::HttpServer.new("127.0.0.1", 29999)
|
23
|
+
httpserver.register("/hello", SimpleHandler.new)
|
24
|
+
httpserver.register("/dir", Mongrel::DirHandler.new("."))
|
25
|
+
httpserver.run.join
|
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
load_attempted ||= false
|
3
|
+
require 'mongrel'
|
4
|
+
rescue LoadError => e
|
5
|
+
unless load_attempted
|
6
|
+
load_attempted = true
|
7
|
+
require 'rubygems'
|
8
|
+
retry
|
9
|
+
end
|
10
|
+
raise e
|
11
|
+
end
|
12
|
+
|
13
|
+
class SimpleHandler < Mongrel::HttpHandler
|
14
|
+
def process(request, response)
|
15
|
+
response.start(200) do |head,out|
|
16
|
+
head["Content-Type"] = "text/plain"
|
17
|
+
out.write("hello!\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
httpserver = Mongrel::HttpServer.new("127.0.0.1", 29997)
|
23
|
+
httpserver.register("/hello", SimpleHandler.new)
|
24
|
+
httpserver.register("/dir", Mongrel::DirHandler.new("."))
|
25
|
+
httpserver.run.join
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'swiftcore/Swiftiply/swiftiply_client'
|
2
|
+
|
3
|
+
class SlowEchoClient < SwiftiplyClientProtocol
|
4
|
+
|
5
|
+
def post_init
|
6
|
+
@httpdata = ''
|
7
|
+
@timer_set = false
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def receive_data data
|
12
|
+
@httpdata << data
|
13
|
+
|
14
|
+
unless @timer_set
|
15
|
+
EventMachine.add_timer(2) {self.send_http_data(@httpdata); self.close_connection_after_writing}
|
16
|
+
@timer_set = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if ARGV[0] and ARGV[0].index(/:/) > 0
|
22
|
+
h,p = ARGV[0].split(/:/,2)
|
23
|
+
EventMachine.run { SlowEchoClient.connect(h,p.to_i) }
|
24
|
+
else
|
25
|
+
puts "slow_echo_client HOST:PORT"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: swiftiply
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.6.0
|
7
|
+
date: 2007-08-12 00:00:00 +02:00
|
8
8
|
summary: A fast clustering proxy for web applications.
|
9
9
|
require_paths:
|
10
10
|
- src
|
@@ -41,127 +41,40 @@ files:
|
|
41
41
|
- bin/swiftiply
|
42
42
|
- bin/mongrel_rails
|
43
43
|
- bin/swiftiply_mongrel_rails
|
44
|
+
- bin/echo_client
|
44
45
|
- external/test_support.rb
|
45
46
|
- external/package.rb
|
46
47
|
- src/swiftcore
|
47
|
-
- src/
|
48
|
+
- src/fastfilereader.rb
|
49
|
+
- src/swiftcore/types.rb
|
48
50
|
- src/swiftcore/Swiftiply.rb
|
49
51
|
- src/swiftcore/swiftiplied_mongrel.rb
|
50
52
|
- src/swiftcore/evented_mongrel.rb
|
51
|
-
- src/
|
52
|
-
- src/
|
53
|
-
- src/
|
54
|
-
- test/
|
55
|
-
- test/
|
56
|
-
- test/
|
57
|
-
- test/
|
58
|
-
- test/
|
59
|
-
- test/
|
60
|
-
- test/
|
61
|
-
- test/
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/
|
65
|
-
- test/
|
66
|
-
- test/
|
67
|
-
- test/
|
68
|
-
- test/
|
69
|
-
- test/rails/public
|
70
|
-
- test/rails/script
|
71
|
-
- test/rails/tmp
|
72
|
-
- test/rails/vendor
|
73
|
-
- test/rails/test/fixtures
|
74
|
-
- test/rails/test/functional
|
75
|
-
- test/rails/test/integration
|
76
|
-
- test/rails/test/mocks
|
77
|
-
- test/rails/test/unit
|
78
|
-
- test/rails/test/test_helper.rb
|
79
|
-
- test/rails/test/mocks/development
|
80
|
-
- test/rails/test/mocks/test
|
81
|
-
- test/rails/app/controllers
|
82
|
-
- test/rails/app/helpers
|
83
|
-
- test/rails/app/models
|
84
|
-
- test/rails/app/views
|
85
|
-
- test/rails/app/controllers/application.rb
|
86
|
-
- test/rails/app/controllers/tests_controller.rb
|
87
|
-
- test/rails/app/helpers/application_helper.rb
|
88
|
-
- test/rails/app/views/layouts
|
89
|
-
- test/rails/config/environments
|
90
|
-
- test/rails/config/database.yml
|
91
|
-
- test/rails/config/routes.rb
|
92
|
-
- test/rails/config/boot.rb
|
93
|
-
- test/rails/config/environment.rb
|
94
|
-
- test/rails/config/environments/production.rb
|
95
|
-
- test/rails/config/environments/development.rb
|
96
|
-
- test/rails/config/environments/test.rb
|
97
|
-
- test/rails/config/environments/production_no_caching.rb
|
98
|
-
- test/rails/doc/README_FOR_APP
|
99
|
-
- test/rails/lib/tasks
|
100
|
-
- test/rails/public/images
|
101
|
-
- test/rails/public/javascripts
|
102
|
-
- test/rails/public/stylesheets
|
103
|
-
- test/rails/public/dispatch.rb
|
104
|
-
- test/rails/public/dispatch.cgi
|
105
|
-
- test/rails/public/dispatch.fcgi
|
106
|
-
- test/rails/public/404.html
|
107
|
-
- test/rails/public/500.html
|
108
|
-
- test/rails/public/index.html
|
109
|
-
- test/rails/public/favicon.ico
|
110
|
-
- test/rails/public/robots.txt
|
111
|
-
- test/rails/public/images/rails.png
|
112
|
-
- test/rails/public/javascripts/prototype.js
|
113
|
-
- test/rails/public/javascripts/effects.js
|
114
|
-
- test/rails/public/javascripts/dragdrop.js
|
115
|
-
- test/rails/public/javascripts/controls.js
|
116
|
-
- test/rails/public/javascripts/application.js
|
117
|
-
- test/rails/script/performance
|
118
|
-
- test/rails/script/process
|
119
|
-
- test/rails/script/about
|
120
|
-
- test/rails/script/breakpointer
|
121
|
-
- test/rails/script/console
|
122
|
-
- test/rails/script/destroy
|
123
|
-
- test/rails/script/generate
|
124
|
-
- test/rails/script/runner
|
125
|
-
- test/rails/script/server
|
126
|
-
- test/rails/script/plugin
|
127
|
-
- test/rails/script/performance/benchmarker
|
128
|
-
- test/rails/script/performance/profiler
|
129
|
-
- test/rails/script/process/reaper
|
130
|
-
- test/rails/script/process/spawner
|
131
|
-
- test/rails/script/process/inspector
|
132
|
-
- test/rails/tmp/sessions
|
133
|
-
- test/rails/tmp/sockets
|
134
|
-
- test/rails/tmp/cache
|
135
|
-
- test/rails/tmp/pids
|
136
|
-
- test/rails/vendor/plugins
|
137
|
-
- test/ramaze/main.rb
|
138
|
-
- test/ramaze/yaml.db
|
139
|
-
- test/ramaze/conf
|
140
|
-
- test/ramaze/public
|
141
|
-
- test/ramaze/src
|
142
|
-
- test/ramaze/template
|
143
|
-
- test/ramaze/conf/stage.yaml
|
144
|
-
- test/ramaze/conf/benchmark.yaml
|
145
|
-
- test/ramaze/conf/live.yaml
|
146
|
-
- test/ramaze/conf/silent.yaml
|
147
|
-
- test/ramaze/conf/debug.yaml
|
148
|
-
- test/ramaze/public/js
|
149
|
-
- test/ramaze/public/css
|
150
|
-
- test/ramaze/public/favicon.ico
|
151
|
-
- test/ramaze/public/ramaze.png
|
152
|
-
- test/ramaze/public/404.jpg
|
153
|
-
- test/ramaze/public/error.zmr
|
154
|
-
- test/ramaze/public/js/jquery.js
|
155
|
-
- test/ramaze/public/css/ramaze_error.css
|
156
|
-
- test/ramaze/public/css/coderay.css
|
157
|
-
- test/ramaze/src/element
|
158
|
-
- test/ramaze/src/controller
|
159
|
-
- test/ramaze/src/model.rb
|
160
|
-
- test/ramaze/src/element/page.rb
|
161
|
-
- test/ramaze/src/controller/main.rb
|
162
|
-
- test/ramaze/template/index.xhtml
|
53
|
+
- src/swiftcore/Swiftiply
|
54
|
+
- src/swiftcore/Swiftiply/swiftiply_client.rb
|
55
|
+
- src/swiftcore/Swiftiply/support_pagecache.rb
|
56
|
+
- test/TC_Swiftiply.rb
|
57
|
+
- test/TC_ProxyBag.rb
|
58
|
+
- test/TC_ProxyBag
|
59
|
+
- test/TC_Swiftiply
|
60
|
+
- test/TC_ProxyBag/test_serve_static_file
|
61
|
+
- test/TC_Swiftiply/mongrel
|
62
|
+
- test/TC_Swiftiply/slow_echo_client
|
63
|
+
- test/TC_Swiftiply/test_serve_static_file
|
64
|
+
- test/TC_Swiftiply/test_serve_normal_proxy
|
65
|
+
- test/TC_Swiftiply/test_serve_static_file_from_cachedir
|
66
|
+
- test/TC_Swiftiply/test_serve_normal_proxy_with_authentication
|
67
|
+
- test/TC_Swiftiply/mongrel/swiftiplied_hello.rb
|
68
|
+
- test/TC_Swiftiply/mongrel/evented_hello.rb
|
69
|
+
- test/TC_Swiftiply/mongrel/threaded_hello.rb
|
70
|
+
- test/TC_Swiftiply/test_serve_static_file_from_cachedir/public
|
163
71
|
- ext/swiftiply_parse
|
72
|
+
- ext/fastfilereader
|
164
73
|
- ext/swiftiply_parse/parse.rl
|
74
|
+
- ext/fastfilereader/extconf.rb
|
75
|
+
- ext/fastfilereader/rubymain.cpp
|
76
|
+
- ext/fastfilereader/mapper.cpp
|
77
|
+
- ext/fastfilereader/mapper.h
|
165
78
|
test_files: []
|
166
79
|
|
167
80
|
rdoc_options:
|
@@ -176,17 +89,17 @@ executables:
|
|
176
89
|
- swiftiply
|
177
90
|
- mongrel_rails
|
178
91
|
- swiftiply_mongrel_rails
|
179
|
-
extensions:
|
180
|
-
|
92
|
+
extensions:
|
93
|
+
- ext/fastfilereader/extconf.rb
|
181
94
|
requirements:
|
182
|
-
- Eventmachine 0.
|
95
|
+
- Eventmachine 0.8.1 or higher.
|
183
96
|
dependencies:
|
184
97
|
- !ruby/object:Gem::Dependency
|
185
98
|
name: eventmachine
|
186
99
|
version_requirement:
|
187
100
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
188
101
|
requirements:
|
189
|
-
- - "
|
102
|
+
- - ">="
|
190
103
|
- !ruby/object:Gem::Version
|
191
|
-
version: 0.
|
104
|
+
version: 0.8.1
|
192
105
|
version:
|
data/test/rails/README
DELETED
@@ -1,182 +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. At the command prompt, start a new rails application using the rails command
|
31
|
-
and your application name. Ex: rails myapp
|
32
|
-
(If you've downloaded rails in a complete tgz or zip, this step is already done)
|
33
|
-
2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
|
34
|
-
3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
|
35
|
-
4. Follow the guidelines to start developing your application
|
36
|
-
|
37
|
-
|
38
|
-
== Web Servers
|
39
|
-
|
40
|
-
By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
|
41
|
-
Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server,
|
42
|
-
Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
|
43
|
-
that you can always get up and running quickly.
|
44
|
-
|
45
|
-
Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is
|
46
|
-
suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
|
47
|
-
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
|
48
|
-
More info at: http://mongrel.rubyforge.org
|
49
|
-
|
50
|
-
If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
|
51
|
-
Mongrel and WEBrick and also suited for production use, but requires additional
|
52
|
-
installation and currently only works well on OS X/Unix (Windows users are encouraged
|
53
|
-
to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
|
54
|
-
http://www.lighttpd.net.
|
55
|
-
|
56
|
-
And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
|
57
|
-
web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
|
58
|
-
for production.
|
59
|
-
|
60
|
-
But of course its also possible to run Rails on any platform that supports FCGI.
|
61
|
-
Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
|
62
|
-
please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
|
63
|
-
|
64
|
-
|
65
|
-
== Debugging Rails
|
66
|
-
|
67
|
-
Have "tail -f" commands running on the server.log and development.log. Rails will
|
68
|
-
automatically display debugging and runtime information to these files. Debugging
|
69
|
-
info will also be shown in the browser on requests from 127.0.0.1.
|
70
|
-
|
71
|
-
|
72
|
-
== Breakpoints
|
73
|
-
|
74
|
-
Breakpoint support is available through the script/breakpointer client. This
|
75
|
-
means that you can break out of execution at any point in the code, investigate
|
76
|
-
and change the model, AND then resume execution! Example:
|
77
|
-
|
78
|
-
class WeblogController < ActionController::Base
|
79
|
-
def index
|
80
|
-
@posts = Post.find(:all)
|
81
|
-
breakpoint "Breaking out from the list"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
So the controller will accept the action, run the first line, then present you
|
86
|
-
with a IRB prompt in the breakpointer window. Here you can do things like:
|
87
|
-
|
88
|
-
Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
|
89
|
-
|
90
|
-
>> @posts.inspect
|
91
|
-
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
|
92
|
-
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
|
93
|
-
>> @posts.first.title = "hello from a breakpoint"
|
94
|
-
=> "hello from a breakpoint"
|
95
|
-
|
96
|
-
...and even better is that you can examine how your runtime objects actually work:
|
97
|
-
|
98
|
-
>> f = @posts.first
|
99
|
-
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
100
|
-
>> f.
|
101
|
-
Display all 152 possibilities? (y or n)
|
102
|
-
|
103
|
-
Finally, when you're ready to resume execution, you press CTRL-D
|
104
|
-
|
105
|
-
|
106
|
-
== Console
|
107
|
-
|
108
|
-
You can interact with the domain model by starting the console through <tt>script/console</tt>.
|
109
|
-
Here you'll have all parts of the application configured, just like it is when the
|
110
|
-
application is running. You can inspect domain models, change values, and save to the
|
111
|
-
database. Starting the script without arguments will launch it in the development environment.
|
112
|
-
Passing an argument will specify a different environment, like <tt>script/console production</tt>.
|
113
|
-
|
114
|
-
To reload your controllers and models after launching the console run <tt>reload!</tt>
|
115
|
-
|
116
|
-
To reload your controllers and models after launching the console run <tt>reload!</tt>
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
== Description of contents
|
121
|
-
|
122
|
-
app
|
123
|
-
Holds all the code that's specific to this particular application.
|
124
|
-
|
125
|
-
app/controllers
|
126
|
-
Holds controllers that should be named like weblogs_controller.rb for
|
127
|
-
automated URL mapping. All controllers should descend from ApplicationController
|
128
|
-
which itself descends from ActionController::Base.
|
129
|
-
|
130
|
-
app/models
|
131
|
-
Holds models that should be named like post.rb.
|
132
|
-
Most models will descend from ActiveRecord::Base.
|
133
|
-
|
134
|
-
app/views
|
135
|
-
Holds the template files for the view that should be named like
|
136
|
-
weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby
|
137
|
-
syntax.
|
138
|
-
|
139
|
-
app/views/layouts
|
140
|
-
Holds the template files for layouts to be used with views. This models the common
|
141
|
-
header/footer method of wrapping views. In your views, define a layout using the
|
142
|
-
<tt>layout :default</tt> and create a file named default.rhtml. Inside default.rhtml,
|
143
|
-
call <% yield %> to render the view using this layout.
|
144
|
-
|
145
|
-
app/helpers
|
146
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are generated
|
147
|
-
for you automatically when using script/generate for controllers. Helpers can be used to
|
148
|
-
wrap functionality for your views into methods.
|
149
|
-
|
150
|
-
config
|
151
|
-
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
|
152
|
-
|
153
|
-
components
|
154
|
-
Self-contained mini-applications that can bundle together controllers, models, and views.
|
155
|
-
|
156
|
-
db
|
157
|
-
Contains the database schema in schema.rb. db/migrate contains all
|
158
|
-
the sequence of Migrations for your schema.
|
159
|
-
|
160
|
-
doc
|
161
|
-
This directory is where your application documentation will be stored when generated
|
162
|
-
using <tt>rake doc:app</tt>
|
163
|
-
|
164
|
-
lib
|
165
|
-
Application specific libraries. Basically, any kind of custom code that doesn't
|
166
|
-
belong under controllers, models, or helpers. This directory is in the load path.
|
167
|
-
|
168
|
-
public
|
169
|
-
The directory available for the web server. Contains subdirectories for images, stylesheets,
|
170
|
-
and javascripts. Also contains the dispatchers and the default HTML files. This should be
|
171
|
-
set as the DOCUMENT_ROOT of your web server.
|
172
|
-
|
173
|
-
script
|
174
|
-
Helper scripts for automation and generation.
|
175
|
-
|
176
|
-
test
|
177
|
-
Unit and functional tests along with fixtures. When using the script/generate scripts, template
|
178
|
-
test files will be generated for you and placed in this directory.
|
179
|
-
|
180
|
-
vendor
|
181
|
-
External libraries that the application depends on. Also includes the plugins subdirectory.
|
182
|
-
This directory is in the load path.
|