acts_as_monitor 0.0.2 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CHANGELOG.md +6 -3
  2. data/README.md +22 -0
  3. data/app/controllers/acts_as_monitor/monitors_controller.rb +18 -0
  4. data/app/helpers/acts_as_monitor_helper.rb +25 -0
  5. data/app/views/acts_as_monitor/monitors/show.html.erb +26 -0
  6. data/config/routes.rb +3 -1
  7. data/lib/acts_as_monitor/engine.rb +21 -8
  8. data/lib/acts_as_monitor/monitor.rb +1 -1
  9. data/lib/acts_as_monitor/version.rb +1 -1
  10. data/lib/acts_as_monitor.rb +10 -10
  11. data/lib/generators/acts_as_monitor/install/install_generator.rb +33 -25
  12. data/lib/generators/acts_as_monitor/install/templates/acts_as_monitor.css +48 -0
  13. data/lib/generators/acts_as_monitor/install/templates/acts_as_monitor.it.yml +8 -1
  14. data/lib/generators/acts_as_monitor/install/templates/acts_as_monitor_javascript.js +78 -0
  15. data/lib/generators/acts_as_monitor/install/templates/acts_as_monitor_loading.gif +0 -0
  16. data/test/acts_as_monitor_helper_test.rb +16 -0
  17. data/test/{units/acts_as_monitor_test.rb → acts_as_monitor_test.rb} +3 -20
  18. data/test/dummy/Rakefile +7 -0
  19. data/test/dummy/app/controllers/application_controller.rb +3 -0
  20. data/test/dummy/app/controllers/homes_controller.rb +4 -0
  21. data/test/dummy/app/helpers/application_helper.rb +2 -0
  22. data/test/dummy/app/helpers/homes_helper.rb +2 -0
  23. data/test/dummy/app/models/test_class.rb +33 -0
  24. data/test/dummy/app/models/test_class_no_monitor.rb +2 -0
  25. data/test/dummy/app/views/homes/index.html.erb +8 -0
  26. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/test/dummy/config/application.rb +45 -0
  28. data/test/dummy/config/boot.rb +10 -0
  29. data/test/dummy/config/database.yml +22 -0
  30. data/test/dummy/config/environment.rb +5 -0
  31. data/test/dummy/config/environments/development.rb +26 -0
  32. data/test/dummy/config/environments/production.rb +49 -0
  33. data/test/dummy/config/environments/test.rb +35 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/inflections.rb +10 -0
  36. data/test/dummy/config/initializers/mime_types.rb +5 -0
  37. data/test/dummy/config/initializers/secret_token.rb +7 -0
  38. data/test/dummy/config/initializers/session_store.rb +8 -0
  39. data/test/dummy/config/locales/acts_as_monitor.it.yml +14 -0
  40. data/test/dummy/config/locales/en.yml +5 -0
  41. data/test/dummy/config/routes.rb +58 -0
  42. data/test/dummy/config.ru +4 -0
  43. data/test/{acts_as_monitor.sqlite3.db → dummy/db/development.sqlite3} +0 -0
  44. data/test/dummy/db/migrate/20120523110000_add_test_tables.rb +12 -0
  45. data/test/dummy/db/schema.rb +19 -0
  46. data/test/dummy/db/test.sqlite3 +0 -0
  47. data/test/dummy/log/development.log +4537 -0
  48. data/test/dummy/log/production.log +0 -0
  49. data/test/dummy/log/server.log +0 -0
  50. data/test/dummy/log/test.log +188 -0
  51. data/test/dummy/public/404.html +26 -0
  52. data/test/dummy/public/422.html +26 -0
  53. data/test/dummy/public/500.html +26 -0
  54. data/test/dummy/public/favicon.ico +0 -0
  55. data/test/dummy/public/images/acts_as_monitor_green.png +0 -0
  56. data/test/dummy/public/images/acts_as_monitor_red.png +0 -0
  57. data/test/dummy/public/images/acts_as_monitor_yellow.png +0 -0
  58. data/test/dummy/public/javascripts/acts_as_monitor_javascript.js +66 -0
  59. data/test/dummy/public/javascripts/application.js +2 -0
  60. data/test/dummy/public/javascripts/builder.js +136 -0
  61. data/test/dummy/public/javascripts/controls.js +965 -0
  62. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  63. data/test/dummy/public/javascripts/effects.js +1123 -0
  64. data/test/dummy/public/javascripts/prototype.js +6001 -0
  65. data/test/dummy/public/javascripts/rails.js +191 -0
  66. data/test/dummy/public/javascripts/scriptaculous.js +68 -0
  67. data/test/dummy/public/javascripts/slider.js +275 -0
  68. data/test/dummy/public/javascripts/sound.js +59 -0
  69. data/test/dummy/public/javascripts/unittest.js +568 -0
  70. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  71. data/test/dummy/public/stylesheets/acts_as_monitor.css +30 -0
  72. data/test/dummy/script/rails +6 -0
  73. data/test/integration/navigation_test.rb +7 -0
  74. data/test/support/integration_case.rb +5 -0
  75. data/test/test_helper.rb +17 -42
  76. metadata +128 -11
  77. data/app/controllers/acts_as_monitor/monitor_controller.rb +0 -7
  78. data/app/helpers/monitor_helper.rb +0 -11
  79. data/app/views/acts_as_monitor/indext.html.erb +0 -1
File without changes
File without changes
@@ -0,0 +1,188 @@
1
+ SQL (0.9ms)  SELECT name
2
+ FROM sqlite_master
3
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
4
+ 
5
+ SQL (0.1ms) select sqlite_version(*)
6
+ SQL (19.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
7
+ SQL (0.1ms) PRAGMA index_list("schema_migrations")
8
+ SQL (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
9
+ SQL (0.1ms) SELECT name
10
+ FROM sqlite_master
11
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
12
+ SQL (1.2ms)  SELECT name
13
+ FROM sqlite_master
14
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
15
+ 
16
+ SQL (1.0ms)  SELECT name
17
+ FROM sqlite_master
18
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
19
+ 
20
+ SQL (0.2ms) SELECT name
21
+ FROM sqlite_master
22
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
23
+ SQL (1.1ms)  SELECT name
24
+ FROM sqlite_master
25
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
26
+ 
27
+ SQL (0.1ms) SELECT name
28
+ FROM sqlite_master
29
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
30
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
31
+ Migrating to AddTestTables (20120523110000)
32
+ SQL (0.1ms) select sqlite_version(*)
33
+ SQL (0.2ms)  SELECT name
34
+ FROM sqlite_master
35
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
36
+ 
37
+ SQL (0.8ms) CREATE TABLE "test_classes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
38
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120523110000')
39
+ SQL (0.3ms) SELECT name
40
+ FROM sqlite_master
41
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
42
+ SQL (1.1ms)  SELECT name
43
+ FROM sqlite_master
44
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
45
+ 
46
+ SQL (0.2ms) SELECT name
47
+ FROM sqlite_master
48
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
49
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
50
+ Migrating to AddTestTables (20120523110000)
51
+ SQL (0.3ms) SELECT name
52
+ FROM sqlite_master
53
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
54
+ SQL (1.1ms)  SELECT name
55
+ FROM sqlite_master
56
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
57
+ 
58
+ SQL (0.7ms) SELECT name
59
+ FROM sqlite_master
60
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
61
+ SQL (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
62
+ Migrating to AddTestTables (20120523110000)
63
+ SQL (1.1ms)  SELECT name
64
+ FROM sqlite_master
65
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
66
+ 
67
+ SQL (0.2ms) SELECT name
68
+ FROM sqlite_master
69
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
70
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
71
+ Migrating to AddTestTables (20120523110000)
72
+ SQL (1.0ms)  SELECT name
73
+ FROM sqlite_master
74
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
75
+ 
76
+ SQL (0.2ms) SELECT name
77
+ FROM sqlite_master
78
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
79
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
80
+ Migrating to AddTestTables (20120523110000)
81
+ SQL (1.1ms)  SELECT name
82
+ FROM sqlite_master
83
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
84
+ 
85
+ SQL (0.2ms) SELECT name
86
+ FROM sqlite_master
87
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
88
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
89
+ Migrating to AddTestTables (20120523110000)
90
+ SQL (1.3ms)  SELECT name
91
+ FROM sqlite_master
92
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
93
+ 
94
+ SQL (0.2ms) SELECT name
95
+ FROM sqlite_master
96
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
97
+ SQL (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
98
+ Migrating to AddTestTables (20120523110000)
99
+ SQL (1.2ms)  SELECT name
100
+ FROM sqlite_master
101
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
102
+ 
103
+ SQL (0.2ms) SELECT name
104
+ FROM sqlite_master
105
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
106
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
107
+ Migrating to AddTestTables (20120523110000)
108
+ SQL (1.2ms)  SELECT name
109
+ FROM sqlite_master
110
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
111
+ 
112
+ SQL (0.2ms) SELECT name
113
+ FROM sqlite_master
114
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
115
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
116
+ Migrating to AddTestTables (20120523110000)
117
+ SQL (1.1ms)  SELECT name
118
+ FROM sqlite_master
119
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
120
+ 
121
+ SQL (0.2ms) SELECT name
122
+ FROM sqlite_master
123
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
124
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
125
+ Migrating to AddTestTables (20120523110000)
126
+ SQL (1.1ms)  SELECT name
127
+ FROM sqlite_master
128
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
129
+ 
130
+ SQL (0.2ms) SELECT name
131
+ FROM sqlite_master
132
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
133
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
134
+ Migrating to AddTestTables (20120523110000)
135
+ SQL (1.1ms)  SELECT name
136
+ FROM sqlite_master
137
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
138
+ 
139
+ SQL (0.2ms) SELECT name
140
+ FROM sqlite_master
141
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
142
+ SQL (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
143
+ Migrating to AddTestTables (20120523110000)
144
+ SQL (1.1ms)  SELECT name
145
+ FROM sqlite_master
146
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
147
+ 
148
+ SQL (0.2ms) SELECT name
149
+ FROM sqlite_master
150
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
151
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
152
+ Migrating to AddTestTables (20120523110000)
153
+ SQL (1.2ms)  SELECT name
154
+ FROM sqlite_master
155
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
156
+ 
157
+ SQL (0.2ms) SELECT name
158
+ FROM sqlite_master
159
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
160
+ SQL (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
161
+ Migrating to AddTestTables (20120523110000)
162
+ SQL (1.2ms)  SELECT name
163
+ FROM sqlite_master
164
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
165
+ 
166
+ SQL (0.2ms) SELECT name
167
+ FROM sqlite_master
168
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
169
+ SQL (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
170
+ Migrating to AddTestTables (20120523110000)
171
+ SQL (1.3ms)  SELECT name
172
+ FROM sqlite_master
173
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
174
+ 
175
+ SQL (0.2ms) SELECT name
176
+ FROM sqlite_master
177
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
178
+ SQL (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
179
+ Migrating to AddTestTables (20120523110000)
180
+ SQL (1.2ms)  SELECT name
181
+ FROM sqlite_master
182
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
183
+ 
184
+ SQL (0.2ms) SELECT name
185
+ FROM sqlite_master
186
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
187
+ SQL (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
188
+ Migrating to AddTestTables (20120523110000)
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,66 @@
1
+ document.observe('dom:loaded', function()
2
+ {
3
+ create_status_window();
4
+
5
+ function create_status_window() {
6
+ new Insertion.Bottom(
7
+ document.body,
8
+ "<div id='acts_as_monitor_status_window'></div>"
9
+ );
10
+ var status_window = $('acts_as_monitor_status_window');
11
+ Position.absolutize(status_window);
12
+ status_window.observe('click', function(ev) {status_window.fade(); });
13
+ status_window.hide();
14
+ }
15
+
16
+ var handle_monitor = function(ev)
17
+ {
18
+ var id = ev.target.getAttribute('data-id');
19
+ new Ajax.Request('/acts_as_monitor/monitors/'+ id +'.js',
20
+ {
21
+ method: 'get',
22
+ evalJSON: 'force',
23
+ parameters: {
24
+ class_name: ev.target.getAttribute('data-class')
25
+ //id: ev.target.getAttribute('data-id')
26
+ },
27
+ onSuccess: function(response)
28
+ {
29
+ var rsp = response.responseJSON;
30
+ create_popup(rsp.text,ev.target);
31
+ },
32
+ onFailure: function(response)
33
+ {
34
+ alert('Failure ' + response.status);
35
+ }
36
+ });
37
+ }
38
+
39
+ //Create popup with information
40
+ function create_popup(text,target)
41
+ {
42
+ //alert(text);
43
+ var status_window = $('acts_as_monitor_status_window');
44
+ status_window.update(text);
45
+ Position.clone(target,status_window);
46
+ new Effect.Appear(status_window);
47
+ //alert("Fatto");
48
+ }
49
+
50
+ //$$('.acts_as_monitor_icon_red .acts_as_monitor_icon_yellow .acts_as_monitor_icon_green')
51
+ var pulsate_forever = function(elem) {
52
+ new Effect.Pulsate(elem, {
53
+ //afterFinish: function(o) { new Effect.Pulsate(o.element, o.options); }
54
+ });
55
+ }
56
+ $$('.acts_as_monitor_icon_red').each(function(elmt)
57
+ {
58
+ elmt.observe('click', handle_monitor);
59
+ pulsate_forever(elmt);
60
+ });
61
+
62
+ $$('.acts_as_monitor_icon_yellow').each(function(elmt)
63
+ {
64
+ elmt.observe('click', handle_monitor);
65
+ });
66
+ });
@@ -0,0 +1,2 @@
1
+ // Place your application-specific JavaScript functions and classes here
2
+ // This file is automatically included by javascript_include_tag :defaults
@@ -0,0 +1,136 @@
1
+ // script.aculo.us builder.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
2
+
3
+ // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ //
5
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
7
+
8
+ var Builder = {
9
+ NODEMAP: {
10
+ AREA: 'map',
11
+ CAPTION: 'table',
12
+ COL: 'table',
13
+ COLGROUP: 'table',
14
+ LEGEND: 'fieldset',
15
+ OPTGROUP: 'select',
16
+ OPTION: 'select',
17
+ PARAM: 'object',
18
+ TBODY: 'table',
19
+ TD: 'table',
20
+ TFOOT: 'table',
21
+ TH: 'table',
22
+ THEAD: 'table',
23
+ TR: 'table'
24
+ },
25
+ // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
26
+ // due to a Firefox bug
27
+ node: function(elementName) {
28
+ elementName = elementName.toUpperCase();
29
+
30
+ // try innerHTML approach
31
+ var parentTag = this.NODEMAP[elementName] || 'div';
32
+ var parentElement = document.createElement(parentTag);
33
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
34
+ parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
35
+ } catch(e) {}
36
+ var element = parentElement.firstChild || null;
37
+
38
+ // see if browser added wrapping tags
39
+ if(element && (element.tagName.toUpperCase() != elementName))
40
+ element = element.getElementsByTagName(elementName)[0];
41
+
42
+ // fallback to createElement approach
43
+ if(!element) element = document.createElement(elementName);
44
+
45
+ // abort if nothing could be created
46
+ if(!element) return;
47
+
48
+ // attributes (or text)
49
+ if(arguments[1])
50
+ if(this._isStringOrNumber(arguments[1]) ||
51
+ (arguments[1] instanceof Array) ||
52
+ arguments[1].tagName) {
53
+ this._children(element, arguments[1]);
54
+ } else {
55
+ var attrs = this._attributes(arguments[1]);
56
+ if(attrs.length) {
57
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
58
+ parentElement.innerHTML = "<" +elementName + " " +
59
+ attrs + "></" + elementName + ">";
60
+ } catch(e) {}
61
+ element = parentElement.firstChild || null;
62
+ // workaround firefox 1.0.X bug
63
+ if(!element) {
64
+ element = document.createElement(elementName);
65
+ for(attr in arguments[1])
66
+ element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
67
+ }
68
+ if(element.tagName.toUpperCase() != elementName)
69
+ element = parentElement.getElementsByTagName(elementName)[0];
70
+ }
71
+ }
72
+
73
+ // text, or array of children
74
+ if(arguments[2])
75
+ this._children(element, arguments[2]);
76
+
77
+ return $(element);
78
+ },
79
+ _text: function(text) {
80
+ return document.createTextNode(text);
81
+ },
82
+
83
+ ATTR_MAP: {
84
+ 'className': 'class',
85
+ 'htmlFor': 'for'
86
+ },
87
+
88
+ _attributes: function(attributes) {
89
+ var attrs = [];
90
+ for(attribute in attributes)
91
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
92
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
93
+ return attrs.join(" ");
94
+ },
95
+ _children: function(element, children) {
96
+ if(children.tagName) {
97
+ element.appendChild(children);
98
+ return;
99
+ }
100
+ if(typeof children=='object') { // array can hold nodes and text
101
+ children.flatten().each( function(e) {
102
+ if(typeof e=='object')
103
+ element.appendChild(e);
104
+ else
105
+ if(Builder._isStringOrNumber(e))
106
+ element.appendChild(Builder._text(e));
107
+ });
108
+ } else
109
+ if(Builder._isStringOrNumber(children))
110
+ element.appendChild(Builder._text(children));
111
+ },
112
+ _isStringOrNumber: function(param) {
113
+ return(typeof param=='string' || typeof param=='number');
114
+ },
115
+ build: function(html) {
116
+ var element = this.node('div');
117
+ $(element).update(html.strip());
118
+ return element.down();
119
+ },
120
+ dump: function(scope) {
121
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
122
+
123
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
124
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
125
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
126
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
127
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
128
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
129
+
130
+ tags.each( function(tag){
131
+ scope[tag] = function() {
132
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
133
+ };
134
+ });
135
+ }
136
+ };