ramaze 0.0.8 → 0.0.9

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 (49) hide show
  1. data/Rakefile +42 -0
  2. data/doc/allison/LICENSE +184 -0
  3. data/doc/allison/README +37 -0
  4. data/doc/allison/allison.css +300 -0
  5. data/doc/allison/allison.gif +0 -0
  6. data/doc/allison/allison.js +307 -0
  7. data/doc/allison/allison.rb +287 -0
  8. data/doc/allison/cache/BODY +588 -0
  9. data/doc/allison/cache/CLASS_INDEX +4 -0
  10. data/doc/allison/cache/CLASS_PAGE +1 -0
  11. data/doc/allison/cache/FILE_INDEX +4 -0
  12. data/doc/allison/cache/FILE_PAGE +1 -0
  13. data/doc/allison/cache/FONTS +1 -0
  14. data/doc/allison/cache/FR_INDEX_BODY +1 -0
  15. data/doc/allison/cache/IMGPATH +1 -0
  16. data/doc/allison/cache/INDEX +1 -0
  17. data/doc/allison/cache/JAVASCRIPT +307 -0
  18. data/doc/allison/cache/METHOD_INDEX +4 -0
  19. data/doc/allison/cache/METHOD_LIST +1 -0
  20. data/doc/allison/cache/SRC_PAGE +1 -0
  21. data/doc/allison/cache/STYLE +322 -0
  22. data/doc/allison/cache/URL +1 -0
  23. data/doc/readme_chunks/principles.txt +33 -18
  24. data/doc/tutorial/todolist.html +599 -0
  25. data/doc/tutorial/todolist.txt +230 -230
  26. data/examples/identity.rb +21 -0
  27. data/examples/nitro_form.rb +22 -0
  28. data/lib/ramaze/controller.rb +1 -1
  29. data/lib/ramaze/dispatcher.rb +10 -4
  30. data/lib/ramaze/helper/{openid.rb → identity.rb} +15 -6
  31. data/lib/ramaze/helper/nitroform.rb +10 -0
  32. data/lib/ramaze/helper/stack.rb +1 -1
  33. data/lib/ramaze/inform.rb +18 -8
  34. data/lib/ramaze/snippets/kernel/aquire.rb +3 -3
  35. data/lib/ramaze/snippets/object/traits.rb +1 -1
  36. data/lib/ramaze/snippets/ramaze/caller_info.rb +17 -1
  37. data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
  38. data/lib/ramaze/store/yaml.rb +10 -1
  39. data/lib/ramaze/template/ezamar.rb +10 -5
  40. data/lib/ramaze/trinity/request.rb +12 -2
  41. data/lib/ramaze/version.rb +1 -1
  42. data/lib/ramaze.rb +5 -3
  43. data/spec/public/error404.xhtml +1 -0
  44. data/spec/spec_all.rb +21 -19
  45. data/spec/spec_helper.rb +1 -1
  46. data/spec/tc_error.rb +18 -4
  47. data/spec/tc_helper_cache.rb +1 -1
  48. data/spec/tc_helper_flash.rb +1 -2
  49. metadata +32 -4
Binary file
@@ -0,0 +1,307 @@
1
+
2
+ // Javascript for Allison RDoc template
3
+ // Copyright 2006 Cloudburst LLC
4
+ // Some sections originally from public domain material
5
+
6
+ var href_base = '%style_url%'.replace(/(.*\/).*/, '$1'); // haha! inline js is good for something
7
+
8
+ function $(id) {
9
+ if (document.getElementById)
10
+ elem = document.getElementById(id);
11
+ else if ( document.all )
12
+ elem = eval("document.all." + id);
13
+ else
14
+ return false;
15
+ return elem;
16
+ }
17
+
18
+ function toggle(id) {
19
+ elem = $(id);
20
+ elemStyle = elem.style;
21
+ if (elemStyle.display == "block") {
22
+ elemStyle.display = "none"
23
+ } else {
24
+ elemStyle.display = "block"
25
+ }
26
+ return true;
27
+ }
28
+
29
+ function toggleText(id) {
30
+ elem = $(id)
31
+ if (m = elem.innerHTML.match(/(Hide)(.*)/)) {
32
+ elem.innerHTML = "Show" + m[2];
33
+ } else if (m = elem.innerHTML.match(/(Show)(.*)/)) {
34
+ elem.innerHTML = "Hide" + m[2];
35
+ }
36
+ return true;
37
+ }
38
+
39
+ function span(s, klass) {
40
+ return '<span class="' + klass + '">' + s + '</span>';
41
+ }
42
+
43
+ function highlightSymbols() {
44
+ pres = document.getElementsByTagName('pre');
45
+ for(var i = 0; i < pres.length; i++) {
46
+ pre = pres[i];
47
+ spans = pre.getElementsByTagName('span');
48
+ for(var k = 0; k < spans.length; k++) {
49
+ span = spans[k];
50
+ if (span.className.match(/ruby-identifier/)) {
51
+ if (span.innerHTML.match(/^:/)) {
52
+ span.className += " ruby-symbol";
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ function hasClass(obj) {
60
+ var result = false;
61
+ if (obj.getAttributeNode("class") != null) {
62
+ result = obj.getAttributeNode("class").value;
63
+ }
64
+ return result;
65
+ }
66
+
67
+ function stripe() {
68
+ var even = true;
69
+ var color = "#f4eefd";
70
+ var tables = document.getElementsByTagName('table');
71
+ if (tables.length == 0) { return; }
72
+ for (var h = 0; h < tables.length; h++) {
73
+ var trs = tables[h].getElementsByTagName("tr");
74
+ for (var i = 0; i < trs.length; i++) {
75
+ var tds = trs[i].getElementsByTagName("td");
76
+ for (var j = 0; j < tds.length; j++) {
77
+ if (hasClass(tds[j]) != "first") {
78
+ var mytd = tds[j];
79
+ if (even) {
80
+ mytd.style.backgroundColor = color;
81
+ }
82
+ }
83
+ }
84
+ even = ! even;
85
+ }
86
+ }
87
+ }
88
+
89
+ function ajaxGet(url) {
90
+ url = (href_base + url).replace('/./', '/')
91
+ var req = false;
92
+
93
+ if (window.ActiveXObject) {
94
+ try {
95
+ // stupid hack because IE7 disables local Ajax with the native xmlhttprequest object
96
+ // for security purposes. Yet ActiveX still works. Thanks, Microsoft. I hate you. Die.
97
+ req = new ActiveXObject("MSXML2.XMLHTTP.3.0");
98
+ } catch (e) {
99
+ try {
100
+ /* IE 6 and maybe 5, don't know, don't care */
101
+ req = new ActiveXObject("Msxml2.XMLHTTP");
102
+ } catch (e) {
103
+ try {
104
+ req = new ActiveXObject("Microsoft.XMLHTTP");
105
+ } catch (e) {
106
+ req = false;
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ /* real browsers */
113
+ if (!req && window.XMLHttpRequest) {
114
+ try {
115
+ req = new XMLHttpRequest();
116
+ } catch (e) {
117
+ req = false;
118
+ }
119
+ }
120
+
121
+ if (req) {
122
+ req.open('GET', url, false);
123
+ req.send(null);
124
+ return req.responseText;
125
+ } else {
126
+ return "Ajax error";
127
+ }
128
+ }
129
+
130
+
131
+ function addEvent(elm, evType, fn, useCapture) {
132
+ if (elm.addEventListener) {
133
+ elm.addEventListener(evType, fn, useCapture);
134
+ return true;
135
+ } else if (elm.attachEvent) {
136
+ var r = elm.attachEvent('on' + evType, fn);
137
+ return r;
138
+ } else {
139
+ elm['on' + evType] = fn;
140
+ }
141
+ }
142
+
143
+ function insertIndices() {
144
+ pages = ["class", "file", "method"]
145
+ for (x in pages) {
146
+ $(pages[x]).innerHTML += ajaxGet('fr_' + pages[x] + '_index.html').replace(/(href=")/g, '$1' + href_base);
147
+ }
148
+ /* mouseoverify method links */
149
+ links = $('method').getElementsByTagName('a');
150
+ for (var x = 0; x < links.length; x++) {
151
+ if (m = links[x].innerHTML.match(/(.*)\s\((.*)\)/)) {
152
+ links[x].innerHTML = m[1] + '<br>';
153
+ links[x].title = m[2];
154
+ }
155
+ }
156
+ /* this is stupid */
157
+ $('class').style.display = "block";
158
+ $('file').style.display = "block";
159
+
160
+ /* has to be here because IE7 does not guarantee the onLoad callback order */
161
+ abbreviateIndicesInner(["class", "file"], 25, "a");
162
+ /* same, linkTitle() depends on the class link list */
163
+ linkTitle();
164
+ }
165
+
166
+ function abbreviateIndices() {
167
+ abbreviateIndicesInner(["defined_in", "child_of", "includes"], 20, 'a');
168
+ abbreviateIndicesInner(["defined_in", "requires", "child_of", "includes"], 20, 'span');
169
+ }
170
+
171
+ function abbreviateIndicesInner(indices, amount, tag) {
172
+ for (var x = 0; x < indices.length; x++) {
173
+ var the_index = $(indices[x]);
174
+ if (the_index) {
175
+ links = the_index.getElementsByTagName(tag);
176
+ for (var y = 0; y < links.length; y++) {
177
+ var link = links[y];
178
+ if (link.getElementsByTagName('span').length == 0 && link.getElementsByTagName('a').length == 0) {
179
+ // avoid nesting
180
+ link.innerHTML = abbreviate(link.innerHTML, amount);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ function linkTitle() {
188
+ /* grab the correct title element from the index */
189
+ var index_page = ajaxGet('index.html');
190
+ title_text = index_page.match(/<title>(.*)<\/title>/m)[1];
191
+ document.title = title_text + " - " + document.title;
192
+ var p = $('header').getElementsByTagName('p')[0]
193
+ if (p.innerHTML.match(/^\s*$/)) {
194
+ p.innerHTML = title_text;
195
+ } else {
196
+ p.innerHTML = title_text + ": " + p.innerHTML;
197
+ }
198
+ /* set the link properly */
199
+ title_link = index_page.match(/<a\s+href="(.*?)"/)[1];
200
+ var element = $('title');
201
+ var item_type = "";
202
+ var item_name = "";
203
+ if (m = element.innerHTML.match(/(Class:|Module:|File:)\s*(.*)/)) {
204
+ item_type = m[1];
205
+ item_name = m[2];
206
+ } else {
207
+ item_name = element.innerHTML;
208
+ }
209
+ element.innerHTML = '<a href="' + href_base + title_link + '">' + item_type + " " + abbreviate(item_name, 25) + '</a>';
210
+ /* breadcrumb navigation for the win */
211
+ items = item_name.split("::");
212
+ items_new = item_name.split("::");
213
+ var s = ""
214
+ file_links = $('class').getElementsByTagName('a');
215
+ for (var x = 0; x < items.length - 1; x++ ){
216
+ var item = items[x];
217
+ link = ("/classes/" + items.slice(0,x).join("/") + "/" + item + ".html").replace('//', '/');
218
+ regex = new RegExp(RegExp.escape(link) + '$');
219
+ for (var y = 0; y < file_links.length; y++) {
220
+ if (file_links[y].href.match(regex)) {
221
+ items_new[x] = '<a href="' + href_base + link + '">' + item + '</a>';
222
+ break;
223
+ }
224
+ }
225
+ }
226
+ $('item_name').innerHTML = item_type + ' ' + items_new.join(" :: ");
227
+ }
228
+
229
+ function abbreviate(s, size) {
230
+ while (s.length > size) {
231
+ var old_s = s;
232
+ s = s.replace(/\s|\n/mg, '');
233
+ s = s.replace(/([A-Z])[a-z]+/m, '$1');
234
+ if (!s || old_s == s) {
235
+ return "..." + s.substring(s.length - size, s.length);
236
+ }
237
+ }
238
+ return s;
239
+ }
240
+
241
+ function disableSubmit(event) {
242
+ var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
243
+ if (keyCode == 13) {
244
+ return false;
245
+ } else {
246
+ return true;
247
+ }
248
+ }
249
+
250
+ function filterList(id, s, event) {
251
+
252
+ /* some half-assed escaping */
253
+ s = s.replace(/[^\w\d\.\_\-\/\:\=\[\]\?\!]/g, '');
254
+ s = RegExp.escape(s);
255
+
256
+ var show_all = false;
257
+ if (s.match(/^\s*$/)) {
258
+ show_all = true;
259
+ }
260
+
261
+ links = $(id).getElementsByTagName('a')
262
+ regex = new RegExp(s, 'i');
263
+
264
+ for (var x = 0; x < links.length; x++) {
265
+ var link = links[x];
266
+ if (show_all) {
267
+ link.style.display = 'inline';
268
+ } else {
269
+ if (link.innerHTML.match(regex)) {
270
+ link.style.display = 'inline';
271
+ } else {
272
+ link.style.display = 'none';
273
+ }
274
+ }
275
+ }
276
+ return true;
277
+ }
278
+
279
+ RegExp.escape = function(text) {
280
+ if (!arguments.callee.sRE) {
281
+ var specials = [
282
+ '/', '.', '*', '+', '?', '|',
283
+ '(', ')', '[', ']', '{', '}', '\\\\'
284
+ ];
285
+ arguments.callee.sRE = new RegExp(
286
+ '(\\\\' + specials.join('|\\\\') + ')', 'g'
287
+ );
288
+ }
289
+ return text.replace(arguments.callee.sRE, '\\\\$1');
290
+ }
291
+
292
+
293
+ function hacks() {
294
+ // show the spacer if necessary,
295
+ divs = document.getElementsByTagName('div');
296
+ for (x in divs) {
297
+ if (divs[x].className && divs[x].className.match(/top/)) {
298
+ document.getElementById('spacer').style.display = 'block';
299
+ }
300
+ }
301
+ }
302
+
303
+ addEvent(window, 'load', insertIndices, false);
304
+ addEvent(window, 'load', abbreviateIndices, false);
305
+ addEvent(window, 'load', stripe, false);
306
+ addEvent(window, 'load', highlightSymbols, false);
307
+ addEvent(window, 'load', hacks, false);
@@ -0,0 +1,287 @@
1
+ # Allison RDoc template
2
+ # Copyright 2006 Cloudburst LLC
3
+
4
+ class String
5
+ # fuck this stupid rdoc templater system
6
+ def if_exists (item = nil)
7
+ unless item
8
+ self unless self =~ /(%(\w+)%)/
9
+ "\nIF:#{$2}\n#{self}\nENDIF:#{$2}\n"
10
+ else
11
+ "\nIF:#{item}\n#{self}\nENDIF:#{item}\n"
12
+ end
13
+ end
14
+ def loop(item)
15
+ "\nSTART:#{item}\n#{self}\nEND:#{item}\n"
16
+ end
17
+ end
18
+
19
+ module RDoc
20
+ module Page
21
+
22
+ puts "Invoking Allison template..."
23
+
24
+ require 'pathname'
25
+ CACHE_DIR = Pathname.new(__FILE__).dirname.to_s + "/cache"
26
+
27
+ begin
28
+ require 'rubygems'
29
+ gem 'markaby', '>= 0.5' # how come this isn't activate_gem(), since that's what it does?
30
+ require 'markaby'
31
+ require 'base64'
32
+
33
+ module Allison
34
+ # markaby page says markaby is better in its own module...
35
+
36
+ URL = "http://blog.evanweaver.com/articles/2006/06/02/allison"
37
+ IMGPATH = 'allison.gif'
38
+
39
+ FONTS = METHOD_LIST = SRC_PAGE = FILE_PAGE = CLASS_PAGE = ""
40
+
41
+ FR_INDEX_BODY = "!INCLUDE!" # who knows
42
+
43
+ STYLE, JAVASCRIPT = ["css", "js"].map do |extension|
44
+ s = File.open(File.dirname(__FILE__) + "/allison.#{extension}").read
45
+ # programmatic css, because we're so badass
46
+ if extension == "css"
47
+ puts "Compiling CSS..."
48
+ s_lines = s.split("\n")
49
+ meths = []
50
+ s_lines.collect! do |line|
51
+ line = line.squeeze(" ").strip
52
+ if line =~ /(\w+)/ and meths.include? $1
53
+ line = instance_eval line
54
+ #puts "Called method #{$1}"
55
+ elsif line !~ /\*\/|\/\*/ and line =~ /(@.*|^def (\w+).*)/
56
+ #printf "Evalled #{$1}"
57
+ result = instance_eval $1
58
+ #puts " to #{result.inspect}"
59
+ result = (result.is_a?(Fixnum) ? result.to_s + "px" : result.to_s)
60
+ line = (line == $1 ? "" : line.gsub($1, result))
61
+ meths.push $2 if $2
62
+ elsif line =~ /\%#{IMGPATH}\%/
63
+ img = Base64.encode64(File.open(File.dirname(__FILE__) + "/#{IMGPATH}") {|f| f.read}).gsub("\n", '')
64
+ line.sub!(/\%#{IMGPATH}\%/, img)
65
+ end
66
+ line !~ /^\s*$|\s*^\/\*.*\*\/\s*$|\{|\}/ ? line + ";" : line
67
+ end
68
+ s = s_lines.join("\n")
69
+ else
70
+ puts "Inlining Javascript..."
71
+ end
72
+ s
73
+ end
74
+
75
+ puts "Compiling XHTML..."
76
+
77
+ INDEX = Markaby::Builder.new.xhtml_strict do
78
+ head do
79
+ title '%title%'
80
+ link :rel => 'stylesheet', :type => 'text/css', :href => 'rdoc-style.css', :media => 'screen'
81
+ tag! :meta, 'http-equiv' => 'refresh', 'content' => '0;url=%initial_page%'
82
+ end
83
+ body do
84
+ div.container! do
85
+ 10.times {|n| div('', :class => "curve", :id => "preheader_curve_#{n}") }
86
+ div.header! do
87
+ span.title! do
88
+ p { '&nbsp;' }
89
+ h1 "Ruby Documentation"
90
+ end
91
+ end
92
+ div.clear {}
93
+ div.redirect! do
94
+ a :href => '%initial_page%' do
95
+ h1 "Redirect"
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end.to_s
101
+
102
+ FILE_INDEX = METHOD_INDEX = CLASS_INDEX = Markaby::Builder.new.capture do
103
+ a :href => '%href%' do
104
+ self << '%name%'
105
+ br
106
+ end
107
+ end.loop('entries')
108
+
109
+ BODY = Markaby::Builder.new.xhtml_strict do
110
+ head do
111
+ title "%title%"
112
+ link :rel => 'stylesheet', :type => 'text/css', :href => '%style_url%', :media => 'screen'
113
+ script :type => 'text/javascript' do
114
+ JAVASCRIPT
115
+ end
116
+ end
117
+ body do
118
+ div.container! do
119
+ 10.times {|n| div('', :class => "curve", :id => "preheader_curve_#{n}") }
120
+ div.header! do
121
+ p {'%full_path%'.if_exists}
122
+ span do
123
+ h1.title! '%title%'.if_exists
124
+ end
125
+ self << "!INCLUDE!" # always empty
126
+ end
127
+ div.clear {}
128
+ div.left! do
129
+ self << (div.navigation.dark.top.child_of! do
130
+ # death to you, horrible templater >:(
131
+ h3 "Child of"
132
+ self << "<span>\n#{"<a href='%par_url%'>".if_exists}%parent%#{"</a>".if_exists('par_url')}</span>"
133
+ end).if_exists('parent')
134
+
135
+ self << div.navigation.dark.top.defined_in! do
136
+ h3('Defined in')
137
+ self << a('%full_path%', :href => '%full_path_url%').if_exists.loop('infiles')
138
+ end.if_exists('infiles')
139
+
140
+ ['includes', 'requires', 'methods'].each do |item|
141
+ self << div.navigation.top(:id => item) do
142
+ self << h3(item.capitalize)
143
+ self << "<span class='bpink'>\n#{"<a href='%aref%'>".if_exists}%name%#{br}#{"</a>".if_exists('aref')}</span>".if_exists('name').loop(item)
144
+ end.if_exists(item)
145
+ end
146
+
147
+ div.spacer! ''
148
+
149
+ # for the javascript ajaxy includes
150
+ ['class', 'file', 'method'].each do |item|
151
+ div.navigation.dark.index :id => "#{item}_wrapper" do
152
+ div.list_header do
153
+ h3 'All ' + (item == 'class' ? 'classes' : item + 's')
154
+ end
155
+ div.list_header_link do
156
+ a((item == 'method' ? 'Show...' : 'Hide...'),
157
+ :id => "#{item}_link", :href => "#",
158
+ :onclick=> "toggle('#{item}'); toggleText('#{item}_link'); return false;")
159
+ end
160
+ div.clear {}
161
+ div(:id => item) do
162
+ form do
163
+ label(:for => "filter_#{item}") { 'Filter:' + '&nbsp;' * 2 }
164
+ input '', :type => 'text', :id => "filter_#{item}",
165
+ :onKeyUp => "return filterList('#{item}', this.value, event);",
166
+ :onKeyPress => "return disableSubmit(event);"
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ 10.times {|n| div('', :class => "curve", :id => "left_curve_#{n}") }
173
+ end
174
+
175
+ div.content! do
176
+ self << capture do
177
+ h1.item_name! '%title%'
178
+ end.if_exists('title')
179
+
180
+ self << capture do
181
+ h1 'Description'
182
+ self << '%description%'
183
+ end.if_exists('description')
184
+
185
+ self << capture do
186
+ self << h1 {a '%sectitle%', :name => '%secsequence%'}.if_exists('sectitle')
187
+ self << p {'%seccomment%'}.if_exists
188
+
189
+ self << capture do
190
+ h1 "Child modules and classes"
191
+ p '%classlist%'
192
+ end.if_exists('classlist')
193
+
194
+ ['constants', 'aliases', 'attributes'].each do |item|
195
+ self << capture do
196
+ h1(item.capitalize)
197
+ p do
198
+ table do
199
+ fields = %w[name value old_name new_name rw desc a_desc]
200
+ self << tr do
201
+ # header row
202
+ th.first " "
203
+ if item == 'constants'
204
+ th 'Name'
205
+ th 'Value'
206
+ elsif item == 'aliases'
207
+ th 'Old name'
208
+ th 'New name'
209
+ elsif item == 'attributes'
210
+ th 'Name'
211
+ th 'Read/write?'
212
+ end
213
+ th.description(:colspan => 2){"Description"}
214
+ end
215
+ self << tr do
216
+ # looped item rows
217
+ td.first " "
218
+ fields.each do |field|
219
+ if field !~ /desc/
220
+ self << td('%' + field + '%', :class => field =~ /^old|^name/ ? "highlight" : "normal").if_exists
221
+ else
222
+ self << td(('%' + field+ '%').if_exists)
223
+ end
224
+ end
225
+ end.loop(item)
226
+ end
227
+ end
228
+ end.if_exists(item)
229
+ end
230
+
231
+ self << capture do
232
+ div.section_spacer ''
233
+ h1('%type% %category% methods')
234
+ self << capture do
235
+ self << a.small(:name => '%aref%') {br}.if_exists
236
+ div.a_method do
237
+ div do
238
+ h3 { "<a href='#%aref%'>".if_exists + '%callseq%'.if_exists + '%name%'.if_exists + '%params%'.if_exists + "</a>".if_exists('aref')}
239
+ self << '%m_desc%'.if_exists
240
+
241
+ self << capture do
242
+ p.source_link :id => '%aref%-show-link' do
243
+ a "Show source...", :id => '%aref%-link', :href => "#",
244
+ :onclick=> "toggle('%aref%-source'); toggleText('%aref%-link'); return false;"
245
+ end
246
+ div.source :id => '%aref%-source' do
247
+ pre { '%sourcecode%' }
248
+ end
249
+ end.if_exists('sourcecode')
250
+ end
251
+ end
252
+
253
+ end.loop('methods').if_exists('methods')
254
+ end.loop('method_list').if_exists('method_list')
255
+
256
+ end.loop('sections').if_exists('sections')
257
+
258
+ end
259
+ end
260
+
261
+ div.footer!.clear do
262
+ a 'Allison', :href => URL
263
+ end
264
+
265
+ end
266
+ end.to_s
267
+ end
268
+
269
+ Allison.constants.each do |c|
270
+ eval "#{c} = Allison::#{c}" # jump out of the namespace
271
+ File.open("#{CACHE_DIR}/#{c}", 'w') do |f|
272
+ f.puts eval(c) # write cache
273
+ end
274
+ end
275
+
276
+ rescue LoadError => e
277
+ # guess we don't have some dependency. hope the cache is fresh!
278
+ lib = (e.to_s[/(.*)\(/, 1] or e.to_s).split(" ").last.capitalize
279
+ puts "Loading from cache (#{lib} was missing)..."
280
+ Dir[CACHE_DIR + '/*'].each do |filename|
281
+ eval("#{filename.split("/").last} = File.open(filename) {|s| s.read}")
282
+ end
283
+ end
284
+
285
+ end
286
+
287
+ end