mack-active_record 0.6.1.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/classes/Mack/Database/Generators.html +140 -0
- data/doc/classes/Mack/Database/{Migrator.html → Migrations.html} +74 -39
- data/doc/classes/Mack/Database.html +158 -61
- data/doc/classes/Mack/Testing/ActiveRecordHelpers.html +168 -0
- data/doc/classes/Mack/ViewHelpers/ActiveRecordHelpers.html +52 -52
- data/doc/classes/Mack.html +8 -15
- data/doc/created.rid +1 -1
- data/doc/files/lib/mack-active_record/{genosaurus_helpers_rb.html → database_migrations_rb.html} +4 -4
- data/doc/files/lib/mack-active_record/database_rb.html +1 -11
- data/doc/files/lib/mack-active_record/{model_column_rb.html → generators_rb.html} +4 -4
- data/doc/files/lib/mack-active_record/helpers/orm_helpers_rb.html +1 -1
- data/doc/files/lib/mack-active_record/{scaffold_generator/scaffold_generator_rb.html → test_extensions_rb.html} +12 -17
- data/doc/files/lib/mack-active_record_rb.html +2 -1
- data/doc/files/lib/mack-active_record_tasks_rb.html +8 -1
- data/doc/fr_class_index.html +3 -5
- data/doc/fr_file_index.html +3 -3
- data/doc/fr_method_index.html +11 -14
- data/lib/mack-active_record/database.rb +81 -59
- data/lib/mack-active_record/database_migrations.rb +29 -0
- data/lib/mack-active_record/generators.rb +11 -0
- data/lib/mack-active_record/helpers/orm_helpers.rb +9 -12
- data/lib/mack-active_record/model_generator/manifest.yml +2 -2
- data/lib/mack-active_record/tasks/db_migration_tasks.rake +2 -15
- data/lib/mack-active_record/test_extensions.rb +101 -0
- data/lib/mack-active_record.rb +4 -3
- data/lib/mack-active_record_tasks.rb +1 -0
- metadata +22 -22
- data/doc/classes/Mack/Genosaurus/ActiveRecord/Helpers.html +0 -225
- data/doc/classes/Mack/Genosaurus/ActiveRecord/ModelColumn.html +0 -299
- data/doc/classes/Mack/ViewHelpers.html +0 -111
- data/doc/classes/ScaffoldGenerator.html +0 -123
- data/lib/mack-active_record/genosaurus_helpers.rb +0 -40
- data/lib/mack-active_record/model_column.rb +0 -55
- data/lib/mack-active_record/scaffold_generator/manifest.yml +0 -31
- data/lib/mack-active_record/scaffold_generator/scaffold_generator.rb +0 -42
- data/lib/mack-active_record/scaffold_generator/templates/app/views/edit.html.erb.template +0 -19
- data/lib/mack-active_record/scaffold_generator/templates/app/views/index.html.erb.template +0 -41
- data/lib/mack-active_record/scaffold_generator/templates/app/views/new.html.erb.template +0 -19
- data/lib/mack-active_record/scaffold_generator/templates/app/views/show.html.erb.template +0 -12
- data/lib/mack-active_record/scaffold_generator/templates/spec.rb.template +0 -47
- data/lib/mack-active_record/scaffold_generator/templates/test.rb.template +0 -9
- data/lib/mack-active_record/tasks/db_create_drop_tasks.rake +0 -52
@@ -58,6 +58,14 @@
|
|
58
58
|
<a href="../../files/lib/mack-active_record/database_rb.html">
|
59
59
|
lib/mack-active_record/database.rb
|
60
60
|
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../../files/lib/mack-active_record/database_migrations_rb.html">
|
63
|
+
lib/mack-active_record/database_migrations.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../../files/lib/mack-active_record/generators_rb.html">
|
67
|
+
lib/mack-active_record/generators.rb
|
68
|
+
</a>
|
61
69
|
<br />
|
62
70
|
</td>
|
63
71
|
</tr>
|
@@ -80,9 +88,11 @@
|
|
80
88
|
<h3 class="section-bar">Methods</h3>
|
81
89
|
|
82
90
|
<div class="name-list">
|
83
|
-
<a href="#
|
84
|
-
<a href="#
|
85
|
-
<a href="#
|
91
|
+
<a href="#M000003">create</a>
|
92
|
+
<a href="#M000004">drop</a>
|
93
|
+
<a href="#M000006">dump_structure</a>
|
94
|
+
<a href="#M000002">establish_connection</a>
|
95
|
+
<a href="#M000005">load_structure</a>
|
86
96
|
</div>
|
87
97
|
</div>
|
88
98
|
|
@@ -96,7 +106,8 @@
|
|
96
106
|
<div id="class-list">
|
97
107
|
<h3 class="section-bar">Classes and Modules</h3>
|
98
108
|
|
99
|
-
Module <a href="Database/
|
109
|
+
Module <a href="Database/Generators.html" class="link">Mack::Database::Generators</a><br />
|
110
|
+
Module <a href="Database/Migrations.html" class="link">Mack::Database::Migrations</a><br />
|
100
111
|
|
101
112
|
</div>
|
102
113
|
|
@@ -110,100 +121,186 @@
|
|
110
121
|
<div id="methods">
|
111
122
|
<h3 class="section-bar">Public Class methods</h3>
|
112
123
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
124
|
+
<div id="method-M000003" class="method-detail">
|
125
|
+
<a name="M000003"></a>
|
115
126
|
|
116
127
|
<div class="method-heading">
|
117
|
-
<a href="#
|
118
|
-
<span class="method-name">
|
128
|
+
<a href="#M000003" class="method-signature">
|
129
|
+
<span class="method-name">create</span><span class="method-args">(env = Mack.env, repis = :default)</span>
|
119
130
|
</a>
|
120
131
|
</div>
|
121
132
|
|
122
133
|
<div class="method-description">
|
134
|
+
<p>
|
135
|
+
Creates a database, if it doesn‘t already exist for the specified
|
136
|
+
environment
|
137
|
+
</p>
|
123
138
|
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('
|
125
|
-
<div class="method-source-code" id="
|
139
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
140
|
+
<div class="method-source-code" id="M000003-source">
|
126
141
|
<pre>
|
127
|
-
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
142
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line 12</span>
|
143
|
+
12: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">env</span> = <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">env</span>, <span class="ruby-identifier">repis</span> = <span class="ruby-identifier">:default</span>)
|
144
|
+
13: <span class="ruby-identifier">dbs</span> = <span class="ruby-identifier">db_settings</span>(<span class="ruby-identifier">env</span>)
|
145
|
+
14: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:adapter</span>]
|
146
|
+
15: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mysql"</span>
|
147
|
+
16: <span class="ruby-identifier">establish_mysql_connection</span>
|
148
|
+
17: <span class="ruby-identifier">create_mysql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>)
|
149
|
+
18: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"postgresql"</span>
|
150
|
+
19: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGHOST'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>]
|
151
|
+
20: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPORT'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>]
|
152
|
+
21: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPASSWORD'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>]
|
153
|
+
22: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
154
|
+
23: <span class="ruby-identifier">create_postgresql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>)
|
155
|
+
24: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"sqlite3"</span>
|
156
|
+
25: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
157
|
+
26: <span class="ruby-keyword kw">end</span>
|
158
|
+
27: <span class="ruby-keyword kw">end</span>
|
134
159
|
</pre>
|
135
160
|
</div>
|
136
161
|
</div>
|
137
162
|
</div>
|
138
163
|
|
139
|
-
<div id="method-
|
140
|
-
<a name="
|
164
|
+
<div id="method-M000004" class="method-detail">
|
165
|
+
<a name="M000004"></a>
|
141
166
|
|
142
167
|
<div class="method-heading">
|
143
|
-
<a href="#
|
144
|
-
<span class="method-name">
|
168
|
+
<a href="#M000004" class="method-signature">
|
169
|
+
<span class="method-name">drop</span><span class="method-args">(env = Mack.env, repis = :default)</span>
|
145
170
|
</a>
|
146
171
|
</div>
|
147
172
|
|
148
173
|
<div class="method-description">
|
149
174
|
<p>
|
150
|
-
|
175
|
+
Drops a database, if it exists for the specified environment
|
151
176
|
</p>
|
152
|
-
<p
|
153
|
-
|
154
|
-
|
177
|
+
<p><a class="source-toggle" href="#"
|
178
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
179
|
+
<div class="method-source-code" id="M000004-source">
|
180
|
+
<pre>
|
181
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line 30</span>
|
182
|
+
30: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">drop</span>(<span class="ruby-identifier">env</span> = <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">env</span>, <span class="ruby-identifier">repis</span> = <span class="ruby-identifier">:default</span>)
|
183
|
+
31: <span class="ruby-identifier">dbs</span> = <span class="ruby-identifier">db_settings</span>(<span class="ruby-identifier">env</span>)
|
184
|
+
32: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:adapter</span>]
|
185
|
+
33: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mysql"</span>
|
186
|
+
34: <span class="ruby-identifier">establish_mysql_connection</span>
|
187
|
+
35: <span class="ruby-identifier">drop_mysql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>)
|
188
|
+
36: <span class="ruby-comment cmt"># ActiveRecord::Base.connection.drop_database dbs[:database]</span>
|
189
|
+
37: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"postgresql"</span>
|
190
|
+
38: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGHOST'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>]
|
191
|
+
39: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPORT'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>]
|
192
|
+
40: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPASSWORD'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>]
|
193
|
+
41: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
194
|
+
42: <span class="ruby-identifier">drop_postgresql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>)
|
195
|
+
43: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"sqlite3"</span>
|
196
|
+
44: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
197
|
+
45: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_rf</span>(<span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:database</span>])
|
198
|
+
46: <span class="ruby-keyword kw">end</span>
|
199
|
+
47: <span class="ruby-keyword kw">end</span>
|
200
|
+
</pre>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div id="method-M000006" class="method-detail">
|
206
|
+
<a name="M000006"></a>
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<a href="#M000006" class="method-signature">
|
210
|
+
<span class="method-name">dump_structure</span><span class="method-args">(env = Mack.env, repis = :default)</span>
|
211
|
+
</a>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div class="method-description">
|
215
|
+
<p>
|
216
|
+
Dumps the structure of the database to a file.
|
217
|
+
</p>
|
218
|
+
<p><a class="source-toggle" href="#"
|
219
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
220
|
+
<div class="method-source-code" id="M000006-source">
|
221
|
+
<pre>
|
222
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line 66</span>
|
223
|
+
66: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dump_structure</span>(<span class="ruby-identifier">env</span> = <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">env</span>, <span class="ruby-identifier">repis</span> = <span class="ruby-identifier">:default</span>)
|
224
|
+
67: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Database</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">env</span>)
|
225
|
+
68: <span class="ruby-identifier">dbs</span> = <span class="ruby-identifier">db_settings</span>(<span class="ruby-identifier">env</span>)
|
226
|
+
69: <span class="ruby-identifier">structure</span> = <span class="ruby-value str">""</span>
|
227
|
+
70: <span class="ruby-identifier">output_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Mack</span>.<span class="ruby-identifier">root</span>, <span class="ruby-value str">"db"</span>, <span class="ruby-node">"#{env}_schema_structure.sql"</span>)
|
228
|
+
71: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:adapter</span>]
|
229
|
+
72: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mysql"</span>
|
230
|
+
73: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-value str">"w"</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">structure_dump</span>}
|
231
|
+
74: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"postgresql"</span>
|
232
|
+
75: <span class="ruby-node">`pg_dump -i -U "#{dbs[:username]}" -s -x -O -n #{ENV["SCHEMA"] ||= "public"} -f #{output_file} #{dbs[:database]}`</span>
|
233
|
+
76: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"sqlite3"</span>
|
234
|
+
77: <span class="ruby-node">`sqlite3 #{dbs[:database]} .schema > #{output_file}`</span>
|
235
|
+
78: <span class="ruby-keyword kw">else</span>
|
236
|
+
79: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Task not supported for '#{dbs[:adapter]}'"</span>
|
237
|
+
80: <span class="ruby-keyword kw">end</span>
|
238
|
+
81: <span class="ruby-keyword kw">end</span>
|
239
|
+
</pre>
|
240
|
+
</div>
|
241
|
+
</div>
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div id="method-M000002" class="method-detail">
|
245
|
+
<a name="M000002"></a>
|
246
|
+
|
247
|
+
<div class="method-heading">
|
248
|
+
<a href="#M000002" class="method-signature">
|
249
|
+
<span class="method-name">establish_connection</span><span class="method-args">(env = Mack.env)</span>
|
250
|
+
</a>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<div class="method-description">
|
254
|
+
<p>
|
255
|
+
Sets up and establishes connections to the database based on the specified
|
256
|
+
environment and the settings in the database.yml file.
|
155
257
|
</p>
|
156
258
|
<p><a class="source-toggle" href="#"
|
157
|
-
onclick="toggleCode('
|
158
|
-
<div class="method-source-code" id="
|
259
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
260
|
+
<div class="method-source-code" id="M000002-source">
|
159
261
|
<pre>
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
52: <span class="ruby-identifier">establish_mysql_connection</span>
|
166
|
-
53: <span class="ruby-identifier">drop_mysql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop_and_create</span>
|
167
|
-
54: <span class="ruby-identifier">create_mysql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:create</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop_and_create</span>
|
168
|
-
55:
|
169
|
-
56: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"postgresql"</span>
|
170
|
-
57: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGHOST'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:host</span>]
|
171
|
-
58: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPORT'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:port</span>]
|
172
|
-
59: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PGPASSWORD'</span>] = <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:password</span>]
|
173
|
-
60:
|
174
|
-
61: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
175
|
-
62: <span class="ruby-identifier">drop_postgresql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop_and_create</span>
|
176
|
-
63: <span class="ruby-identifier">create_postgresql_db</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">dbs</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:create</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop_and_create</span>
|
177
|
-
64:
|
178
|
-
65: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"sqlite3"</span>
|
179
|
-
66: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">clear_active_connections!</span>
|
180
|
-
67: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_rf</span>(<span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:database</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drop_and_create</span>
|
181
|
-
68: <span class="ruby-keyword kw">end</span>
|
182
|
-
69: <span class="ruby-keyword kw">end</span>
|
262
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line 6</span>
|
263
|
+
6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">env</span> = <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">env</span>)
|
264
|
+
7: <span class="ruby-identifier">dbs</span> = <span class="ruby-identifier">db_settings</span>(<span class="ruby-identifier">env</span>)
|
265
|
+
8: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">dbs</span>)
|
266
|
+
9: <span class="ruby-keyword kw">end</span>
|
183
267
|
</pre>
|
184
268
|
</div>
|
185
269
|
</div>
|
186
270
|
</div>
|
187
271
|
|
188
|
-
<div id="method-
|
189
|
-
<a name="
|
272
|
+
<div id="method-M000005" class="method-detail">
|
273
|
+
<a name="M000005"></a>
|
190
274
|
|
191
275
|
<div class="method-heading">
|
192
|
-
<a href="#
|
193
|
-
<span class="method-name">
|
276
|
+
<a href="#M000005" class="method-signature">
|
277
|
+
<span class="method-name">load_structure</span><span class="method-args">(file, env = Mack.env, repis = :default)</span>
|
194
278
|
</a>
|
195
279
|
</div>
|
196
280
|
|
197
281
|
<div class="method-description">
|
282
|
+
<p>
|
283
|
+
Loads the structure of the given file into the database
|
284
|
+
</p>
|
198
285
|
<p><a class="source-toggle" href="#"
|
199
|
-
onclick="toggleCode('
|
200
|
-
<div class="method-source-code" id="
|
286
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
287
|
+
<div class="method-source-code" id="M000005-source">
|
201
288
|
<pre>
|
202
|
-
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
289
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/database.rb, line 50</span>
|
290
|
+
50: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_structure</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">env</span> = <span class="ruby-constant">Mack</span>.<span class="ruby-identifier">env</span>, <span class="ruby-identifier">repis</span> = <span class="ruby-identifier">:default</span>)
|
291
|
+
51: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Database</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">env</span>)
|
292
|
+
52: <span class="ruby-identifier">dbs</span> = <span class="ruby-identifier">db_settings</span>(<span class="ruby-identifier">env</span>)
|
293
|
+
53: <span class="ruby-identifier">sql</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>)
|
294
|
+
54: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">dbs</span>[<span class="ruby-identifier">:adapter</span>]
|
295
|
+
55: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mysql"</span>, <span class="ruby-value str">"sqlite3"</span>
|
296
|
+
56: <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">";"</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
|
297
|
+
57: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">strip!</span>
|
298
|
+
58: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">s</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">blank?</span>
|
299
|
+
59: <span class="ruby-keyword kw">end</span>
|
300
|
+
60: <span class="ruby-keyword kw">else</span>
|
301
|
+
61: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">blank?</span>
|
302
|
+
62: <span class="ruby-keyword kw">end</span>
|
303
|
+
63: <span class="ruby-keyword kw">end</span>
|
207
304
|
</pre>
|
208
305
|
</div>
|
209
306
|
</div>
|
@@ -0,0 +1,168 @@
|
|
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::Testing::ActiveRecordHelpers</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::Testing::ActiveRecordHelpers</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/mack-active_record/test_extensions_rb.html">
|
59
|
+
lib/mack-active_record/test_extensions.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
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
module Helpers
|
78
|
+
</p>
|
79
|
+
<pre>
|
80
|
+
alias_method :mack_rake_task, :rake_task
|
81
|
+
|
82
|
+
def rake_task(name, env = {}) # :nodoc:
|
83
|
+
DataMapper::MigrationRunner.reset!
|
84
|
+
mack_rake_task(name, env, [File.join(File.dirname(__FILE__), "tasks", "db_create_drop_tasks.rake"),
|
85
|
+
File.join(File.dirname(__FILE__), "tasks", "db_migration_tasks.rake")])
|
86
|
+
end
|
87
|
+
</pre>
|
88
|
+
<p>
|
89
|
+
end # Helpers
|
90
|
+
</p>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div id="method-list">
|
98
|
+
<h3 class="section-bar">Methods</h3>
|
99
|
+
|
100
|
+
<div class="name-list">
|
101
|
+
<a href="#M000012">rollback_transaction</a>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if includes -->
|
109
|
+
|
110
|
+
<div id="section">
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<!-- if method_list -->
|
120
|
+
<div id="methods">
|
121
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
122
|
+
|
123
|
+
<div id="method-M000012" class="method-detail">
|
124
|
+
<a name="M000012"></a>
|
125
|
+
|
126
|
+
<div class="method-heading">
|
127
|
+
<a href="#M000012" class="method-signature">
|
128
|
+
<span class="method-name">rollback_transaction</span><span class="method-args">() {|if block_given?| ...}</span>
|
129
|
+
</a>
|
130
|
+
</div>
|
131
|
+
|
132
|
+
<div class="method-description">
|
133
|
+
<p><a class="source-toggle" href="#"
|
134
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
135
|
+
<div class="method-source-code" id="M000012-source">
|
136
|
+
<pre>
|
137
|
+
<span class="ruby-comment cmt"># File lib/mack-active_record/test_extensions.rb, line 27</span>
|
138
|
+
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rollback_transaction</span>
|
139
|
+
28: <span class="ruby-keyword kw">begin</span>
|
140
|
+
29: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">transaction</span> <span class="ruby-keyword kw">do</span>
|
141
|
+
30: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
142
|
+
31: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Rollback!"</span>
|
143
|
+
32: <span class="ruby-keyword kw">end</span>
|
144
|
+
33: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
145
|
+
34: <span class="ruby-comment cmt"># we need to do this so we can throw up actual errors!</span>
|
146
|
+
35: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Rollback!"</span>
|
147
|
+
36: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span>
|
148
|
+
37: <span class="ruby-keyword kw">end</span>
|
149
|
+
38: <span class="ruby-keyword kw">end</span>
|
150
|
+
39: <span class="ruby-keyword kw">end</span>
|
151
|
+
</pre>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
<div id="validator-badges">
|
164
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
</body>
|
168
|
+
</html>
|