mack-distributed 0.7.0 → 0.7.0.1

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 (32) hide show
  1. metadata +2 -33
  2. data/doc/classes/Mack/Distributable.html +0 -137
  3. data/doc/classes/Mack/Distributed/Errors/ApplicationNameUndefined.html +0 -118
  4. data/doc/classes/Mack/Distributed/Errors/InvalidAddressableURIFormat.html +0 -152
  5. data/doc/classes/Mack/Distributed/Errors/UnknownApplication.html +0 -155
  6. data/doc/classes/Mack/Distributed/Errors/UnknownRouteName.html +0 -156
  7. data/doc/classes/Mack/Distributed/Routes/Urls.html +0 -213
  8. data/doc/classes/Mack/Distributed/Utils/Rinda.html +0 -230
  9. data/doc/classes/Mack/Distributed/View.html +0 -221
  10. data/doc/classes/Mack/Distributed/ViewCache.html +0 -170
  11. data/doc/classes/Mack/Rendering/Type/Distributed.html +0 -173
  12. data/doc/classes/Mack/Rendering/Type/Layout.html +0 -174
  13. data/doc/classes/Mack/Routes/Urls.html +0 -165
  14. data/doc/created.rid +0 -1
  15. data/doc/files/README.html +0 -272
  16. data/doc/files/lib/mack-distributed/distributable_rb.html +0 -101
  17. data/doc/files/lib/mack-distributed/distributed_rb.html +0 -101
  18. data/doc/files/lib/mack-distributed/errors/errors_rb.html +0 -101
  19. data/doc/files/lib/mack-distributed/extensions/route_map_rb.html +0 -101
  20. data/doc/files/lib/mack-distributed/extensions/urls_rb.html +0 -101
  21. data/doc/files/lib/mack-distributed/routes/urls_rb.html +0 -101
  22. data/doc/files/lib/mack-distributed/utils/rinda_rb.html +0 -101
  23. data/doc/files/lib/mack-distributed/views/rendering/type/distributed_rb.html +0 -101
  24. data/doc/files/lib/mack-distributed/views/rendering/type/layout_rb.html +0 -101
  25. data/doc/files/lib/mack-distributed/views/view_cache_rb.html +0 -101
  26. data/doc/files/lib/mack-distributed/views/view_rb.html +0 -101
  27. data/doc/files/lib/mack-distributed_rb.html +0 -110
  28. data/doc/fr_class_index.html +0 -38
  29. data/doc/fr_file_index.html +0 -39
  30. data/doc/fr_method_index.html +0 -43
  31. data/doc/index.html +0 -24
  32. data/doc/rdoc-style.css +0 -208
@@ -1,165 +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>Module: Mack::Routes::Urls</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">Mack::Routes::Urls</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/mack-distributed/extensions/urls_rb.html">
59
- lib/mack-distributed/extensions/urls.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
-
76
-
77
- </div>
78
-
79
- <div id="method-list">
80
- <h3 class="section-bar">Methods</h3>
81
-
82
- <div class="name-list">
83
- <a href="#M000017">distributed_url</a>&nbsp;&nbsp;
84
- </div>
85
- </div>
86
-
87
- </div>
88
-
89
-
90
- <!-- if includes -->
91
-
92
- <div id="section">
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
- <!-- if method_list -->
102
- <div id="methods">
103
- <h3 class="section-bar">Public Instance methods</h3>
104
-
105
- <div id="method-M000017" class="method-detail">
106
- <a name="M000017"></a>
107
-
108
- <div class="method-heading">
109
- <a href="#M000017" class="method-signature">
110
- <span class="method-name">distributed_url</span><span class="method-args">(app_name, route_name, options = {})</span>
111
- </a>
112
- </div>
113
-
114
- <div class="method-description">
115
- <p>
116
- Retrieves a distributed route from a DRb server.
117
- </p>
118
- <p>
119
- Example:
120
- </p>
121
- <pre>
122
- distributed_url(:app_1, :home_page_url)
123
- distributed_url(:registration_app, :signup_url, {:from =&gt; :google})
124
- </pre>
125
- <p><a class="source-toggle" href="#"
126
- onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
127
- <div class="method-source-code" id="M000017-source">
128
- <pre>
129
- <span class="ruby-comment cmt"># File lib/mack-distributed/extensions/urls.rb, line 11</span>
130
- 11: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">distributed_url</span>(<span class="ruby-identifier">app_name</span>, <span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span> = {})
131
- 12: <span class="ruby-identifier">route_name</span> = <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">to_s</span>
132
- 13: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/_url$/</span>)
133
- 14: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/_distributed_url$/</span>)
134
- 15: <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;_url&quot;</span>, <span class="ruby-value str">&quot;_distributed_url&quot;</span>)
135
- 16: <span class="ruby-keyword kw">end</span>
136
- 17: <span class="ruby-keyword kw">else</span>
137
- 18: <span class="ruby-identifier">route_name</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;_distributed_url&quot;</span>
138
- 19: <span class="ruby-keyword kw">end</span>
139
- 20:
140
- 21: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">app_config</span>.<span class="ruby-identifier">mack</span>.<span class="ruby-identifier">distributed_app_name</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">app_name</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">app_config</span>.<span class="ruby-identifier">mack</span>.<span class="ruby-identifier">distributed_app_name</span>.<span class="ruby-identifier">to_sym</span>
141
- 22: <span class="ruby-comment cmt"># if it's local let's just use it and not go out to Rinda</span>
142
- 23: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span>)
143
- 24: <span class="ruby-keyword kw">end</span>
144
- 25: <span class="ruby-identifier">d_urls</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Distributed</span><span class="ruby-operator">::</span><span class="ruby-constant">Routes</span><span class="ruby-operator">::</span><span class="ruby-constant">Urls</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">app_name</span>)
145
- 26: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Distributed</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">UnknownRouteName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app_name</span>, <span class="ruby-identifier">route_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">d_urls</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">route_name</span>)
146
- 27: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">d_urls</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span>)
147
- 28: <span class="ruby-keyword kw">end</span>
148
- </pre>
149
- </div>
150
- </div>
151
- </div>
152
-
153
-
154
- </div>
155
-
156
-
157
- </div>
158
-
159
-
160
- <div id="validator-badges">
161
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
162
- </div>
163
-
164
- </body>
165
- </html>
data/doc/created.rid DELETED
@@ -1 +0,0 @@
1
- Mon, 25 Aug 2008 11:24:38 -0400
@@ -1,272 +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>File: README</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="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Aug 25 10:11:29 -0400 2008</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h3>Setup</h3>
73
- <p>
74
- Using distributed functionality with Mack is incredibly easy. The first
75
- thing we need to do is start the Mack ring server.
76
- </p>
77
- <pre>
78
- mack_ring_server start
79
- </pre>
80
- <p>
81
- That&#8216;s the glue that holds everything together. The ring server acts
82
- a registry/lookup agent so applications know where to find the services
83
- they are looking for.
84
- </p>
85
- <p>
86
- In order to use the distributed functionality, you really need two
87
- applications. The first application will be serving the distributed
88
- object(s), routes, etc&#8230; and the second application will be using the
89
- distributed functionality. Both applications will need the mack-distributed
90
- gem. In the config/initializers/gems.rb add the following to both
91
- applications:
92
- </p>
93
- <pre>
94
- gem.add &quot;mack-distributed&quot;, :libs =&gt; &quot;mack-distributed&quot;
95
- </pre>
96
- <h2>Using Distributed Objects (Models)</h2>
97
- <p>
98
- Distributed objects are an easy way to share functionality across many
99
- different Mack applications. Whether it&#8216;s a database model, or a bit
100
- of library code, it&#8216;s easy to share and re-use.
101
- </p>
102
- <h3>Application 1 (Server)</h3>
103
- <p>
104
- Let&#8216;s configure our &#8216;server&#8217; application. This is where
105
- pretty much all the &#8216;heavy lifting&#8217; is done. First we need
106
- setup our configuration file:
107
- </p>
108
- <p>
109
- config/app_config/default.yml:
110
- </p>
111
- <pre>
112
- # All distributed applications need to have a unique name so they can easily be identified for lookup.
113
- mack::distributed_app_name: my_cool_app
114
- # Turn object sharing on
115
- mack::share_objects: true
116
- </pre>
117
- <p>
118
- Let&#8216;s assume that we have a simple User DataMapper model that looks
119
- something like this:
120
- </p>
121
- <pre>
122
- class User
123
- include DataMapper::Resource
124
-
125
- property :id, Serial
126
- property :username, String
127
- end
128
- </pre>
129
- <p>
130
- It takes only one line of code to make that into a distributed object. We
131
- just need to include <a
132
- href="../classes/Mack/Distributable.html">Mack::Distributable</a> into the
133
- User class, like such:
134
- </p>
135
- <pre>
136
- class User
137
- include Mack::Distributable
138
- include DataMapper::Resource
139
-
140
- property :id, Serial
141
- property :username, String
142
- end
143
- </pre>
144
- <p>
145
- Now, start your server:
146
- </p>
147
- <pre>
148
- rake server
149
- </pre>
150
- <h3>Application 2 (Client)</h3>
151
- <p>
152
- Here&#8216;s where things get really cool. We don&#8216;t have to do
153
- anything else to our second application to get it find and use our User
154
- model from the first application. When we add the mack-distributed gem,
155
- we&#8216;ve given it all the magic it needs to run.
156
- </p>
157
- <p>
158
- Let&#8216;s start up our console:
159
- </p>
160
- <pre>
161
- rake console
162
- </pre>
163
- <p>
164
- Now, in our console we can do the following:
165
- </p>
166
- <pre>
167
- user = Mack::Distributed::User.new
168
- user.username = &quot;foobar&quot;
169
- user.save
170
- </pre>
171
- <p>
172
- In the first application you&#8216;ll see an insert into the users table in
173
- the logs. If you look in the database, you&#8216;ll see that we&#8216;ve
174
- successfully created a new user.
175
- </p>
176
- <h3>How does it work?</h3>
177
- <p>
178
- When you include <a
179
- href="../classes/Mack/Distributable.html">Mack::Distributable</a> into a
180
- class it registers a proxy of that class with ring server. When another
181
- application makes a call to Mack::Distributed::&lt;class_name&gt; it looks
182
- up and finds that class in the ring server and returns the proxy object to
183
- you.
184
- </p>
185
- <h3>Using Distributed Views</h3>
186
- <p>
187
- With distributed views, you can easily share views and layouts among
188
- different Mack Applications.
189
- </p>
190
- <h2>Application 1 (Server)</h2>
191
- <p>
192
- config/app_config/default.yml: mack::distributed_site_domain: <a
193
- href="http://localhost:3001">localhost:3001</a> mack::distributed_app_name:
194
- my_cool_app # Turn view sharing on mack::share_views: true # and all the
195
- model sharing settings&#8230;
196
- </p>
197
- <p>
198
- That&#8216;s it. When the server is started, the distributed view module
199
- will register a proxy with rinda ready for use by the client.
200
- </p>
201
- <h2>Application 2 (Client)</h2>
202
- <p>
203
- To use distributed view, you need to specify a fully qualified distributed
204
- URI in the form of:
205
- </p>
206
- <pre>
207
- distributed://app_name/path
208
- </pre>
209
- <p>
210
- so, let&#8216;s say I want to render a page using a layout in application
211
- 1, I&#8216;d do:
212
- </p>
213
- <pre>
214
- render(:action, &quot;index&quot;, :layout =&gt; &quot;distributed://my_cool_app/application&quot;)
215
- </pre>
216
- <p>
217
- The above code will render the index page using application.html layout
218
- that lives in the application 1 space.
219
- </p>
220
- <p>
221
- You can also specify the distributed layout globally in the controller.
222
- Example:
223
- </p>
224
- <pre>
225
- class MyController
226
- include Mack::Controller
227
-
228
- layout &quot;distributed://my_cool_app/application&quot;
229
- end
230
- </pre>
231
- <p>
232
- All the actions in MyController will use the distributed layout
233
- </p>
234
- <p>
235
- Now, to render a distributed view, you&#8216;d do the following:
236
- </p>
237
- <pre>
238
- render(:distributed, &quot;distributed://my_cool_app/admin/index&quot;)
239
- </pre>
240
-
241
- </div>
242
-
243
-
244
- </div>
245
-
246
-
247
- </div>
248
-
249
-
250
- <!-- if includes -->
251
-
252
- <div id="section">
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
- <!-- if method_list -->
262
-
263
-
264
- </div>
265
-
266
-
267
- <div id="validator-badges">
268
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
269
- </div>
270
-
271
- </body>
272
- </html>
@@ -1,101 +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>File: distributable.rb</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="fileHeader">
50
- <h1>distributable.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/mack-distributed/distributable.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Aug 25 10:11:29 -0400 2008</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
-
72
-
73
- </div>
74
-
75
-
76
- </div>
77
-
78
-
79
- <!-- if includes -->
80
-
81
- <div id="section">
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
- <!-- if method_list -->
91
-
92
-
93
- </div>
94
-
95
-
96
- <div id="validator-badges">
97
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
- </div>
99
-
100
- </body>
101
- </html>