spik 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +130 -0
  3. data/Rakefile +37 -0
  4. data/lib/spik/execution.rb +29 -0
  5. data/lib/spik/models.rb +15 -0
  6. data/lib/spik/tmp.rb +50 -0
  7. data/lib/spik/version.rb +3 -0
  8. data/lib/spik.rb +48 -0
  9. data/lib/tasks/spik_tasks.rake +4 -0
  10. data/test/dummy/Rakefile +7 -0
  11. data/test/dummy/app/assets/javascripts/application.js +9 -0
  12. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/controllers/home_controller.rb +23 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/models/notice.rb +3 -0
  17. data/test/dummy/app/models/post.rb +3 -0
  18. data/test/dummy/app/views/home/index.html.erb +23 -0
  19. data/test/dummy/app/views/home/search.html.erb +12 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +12 -0
  21. data/test/dummy/config/application.rb +45 -0
  22. data/test/dummy/config/boot.rb +10 -0
  23. data/test/dummy/config/database.yml +25 -0
  24. data/test/dummy/config/environment.rb +5 -0
  25. data/test/dummy/config/environments/development.rb +30 -0
  26. data/test/dummy/config/environments/production.rb +60 -0
  27. data/test/dummy/config/environments/test.rb +39 -0
  28. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/test/dummy/config/initializers/inflections.rb +10 -0
  30. data/test/dummy/config/initializers/mime_types.rb +5 -0
  31. data/test/dummy/config/initializers/secret_token.rb +7 -0
  32. data/test/dummy/config/initializers/session_store.rb +8 -0
  33. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  34. data/test/dummy/config/locales/en.yml +5 -0
  35. data/test/dummy/config/routes.rb +60 -0
  36. data/test/dummy/config.ru +4 -0
  37. data/test/dummy/db/development.sqlite3 +0 -0
  38. data/test/dummy/db/migrate/20111022073857_create_posts.rb +13 -0
  39. data/test/dummy/db/migrate/20111022090628_create_notices.rb +13 -0
  40. data/test/dummy/db/production.sqlite3 +0 -0
  41. data/test/dummy/db/schema.rb +30 -0
  42. data/test/dummy/log/development.log +1339 -0
  43. data/test/dummy/log/production.log +5372 -0
  44. data/test/dummy/log/test.log +0 -0
  45. data/test/dummy/public/404.html +26 -0
  46. data/test/dummy/public/422.html +26 -0
  47. data/test/dummy/public/500.html +26 -0
  48. data/test/dummy/public/favicon.ico +0 -0
  49. data/test/dummy/script/rails +6 -0
  50. data/test/dummy/tmp/cache/assets/CB3/ED0/sprockets%2F21371325c045193edd88a7eb5897e4d0 +9052 -0
  51. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  52. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
  53. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9427 -0
  54. data/test/dummy/tmp/cache/assets/DB4/540/sprockets%2F77df85bd03af068df99d6a714cd58ff2 +373 -0
  55. data/test/dummy/tmp/cache/assets/DD0/030/sprockets%2F6fea4f8c8ac6003482feb9df8afa0361 +9068 -0
  56. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  57. data/test/dummy/tmp/cache/assets/E54/940/sprockets%2Fe5c4f565eaabc3ea3cc4006bf5b9c6ce +389 -0
  58. data/test/integration/missing_method_test.rb +12 -0
  59. data/test/spik_test.rb +13 -0
  60. data/test/test_helper.rb +10 -0
  61. metadata +156 -0
@@ -0,0 +1,373 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1319269338.64787: @value{ I" length:EFi;I" digest;
2
+ F"%73ab0c1f1ca15b2fb76fb52efbe07d7aI" source;
3
+ FI";/**
4
+ * Unobtrusive scripting adapter for jQuery
5
+ *
6
+ * Requires jQuery 1.6.0 or later.
7
+ * https://github.com/rails/jquery-ujs
8
+
9
+ * Uploading file using rails.js
10
+ * =============================
11
+ *
12
+ * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
13
+ * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
14
+ *
15
+ * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
16
+ *
17
+ * Ex:
18
+ * $('form').live('ajax:aborted:file', function(event, elements){
19
+ * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
20
+ * // Returning false in this handler tells rails.js to disallow standard form submission
21
+ * return false;
22
+ * });
23
+ *
24
+ * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
25
+ *
26
+ * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
27
+ * techniques like the iframe method to upload the file instead.
28
+ *
29
+ * Required fields in rails.js
30
+ * ===========================
31
+ *
32
+ * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
33
+ * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
34
+ *
35
+ * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
36
+ *
37
+ * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
38
+ * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
39
+ *
40
+ * Ex:
41
+ * $('form').live('ajax:aborted:required', function(event, elements){
42
+ * // Returning false in this handler tells rails.js to submit the form anyway.
43
+ * // The blank required inputs are passed to this function in `elements`.
44
+ * return ! confirm("Would you like to submit the form with missing info?");
45
+ * });
46
+ */
47
+
48
+
49
+ (function($, undefined) {
50
+ // Shorthand to make it a little easier to call public rails functions from within rails.js
51
+ var rails;
52
+
53
+ $.rails = rails = {
54
+ // Link elements bound by jquery-ujs
55
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
56
+
57
+ // Select elements bound by jquery-ujs
58
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
59
+
60
+ // Form elements bound by jquery-ujs
61
+ formSubmitSelector: 'form',
62
+
63
+ // Form input elements bound by jquery-ujs
64
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
65
+
66
+ // Form input elements disabled during form submission
67
+ disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
68
+
69
+ // Form input elements re-enabled after form submission
70
+ enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
71
+
72
+ // Form required input elements
73
+ requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
74
+
75
+ // Form file input elements
76
+ fileInputSelector: 'input:file',
77
+
78
+ // Link onClick disable selector with possible reenable after remote submission
79
+ linkDisableSelector: 'a[data-disable-with]',
80
+
81
+ // Make sure that every Ajax request sends the CSRF token
82
+ CSRFProtection: function(xhr) {
83
+ var token = $('meta[name="csrf-token"]').attr('content');
84
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
85
+ },
86
+
87
+ // Triggers an event on an element and returns false if the event result is false
88
+ fire: function(obj, name, data) {
89
+ var event = $.Event(name);
90
+ obj.trigger(event, data);
91
+ return event.result !== false;
92
+ },
93
+
94
+ // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
95
+ confirm: function(message) {
96
+ return confirm(message);
97
+ },
98
+
99
+ // Default ajax function, may be overridden with custom function in $.rails.ajax
100
+ ajax: function(options) {
101
+ return $.ajax(options);
102
+ },
103
+
104
+ // Submits "remote" forms and links with ajax
105
+ handleRemote: function(element) {
106
+ var method, url, data,
107
+ crossDomain = element.data('cross-domain') || null,
108
+ dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
109
+ options;
110
+
111
+ if (rails.fire(element, 'ajax:before')) {
112
+
113
+ if (element.is('form')) {
114
+ method = element.attr('method');
115
+ url = element.attr('action');
116
+ data = element.serializeArray();
117
+ // memoized value from clicked submit button
118
+ var button = element.data('ujs:submit-button');
119
+ if (button) {
120
+ data.push(button);
121
+ element.data('ujs:submit-button', null);
122
+ }
123
+ } else if (element.is(rails.inputChangeSelector)) {
124
+ method = element.data('method');
125
+ url = element.data('url');
126
+ data = element.serialize();
127
+ if (element.data('params')) data = data + "&" + element.data('params');
128
+ } else {
129
+ method = element.data('method');
130
+ url = element.attr('href');
131
+ data = element.data('params') || null;
132
+ }
133
+
134
+ options = {
135
+ type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
136
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
137
+ beforeSend: function(xhr, settings) {
138
+ if (settings.dataType === undefined) {
139
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
140
+ }
141
+ return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
142
+ },
143
+ success: function(data, status, xhr) {
144
+ element.trigger('ajax:success', [data, status, xhr]);
145
+ },
146
+ complete: function(xhr, status) {
147
+ element.trigger('ajax:complete', [xhr, status]);
148
+ },
149
+ error: function(xhr, status, error) {
150
+ element.trigger('ajax:error', [xhr, status, error]);
151
+ }
152
+ };
153
+ // Only pass url to `ajax` options if not blank
154
+ if (url) { options.url = url; }
155
+
156
+ rails.ajax(options);
157
+ }
158
+ },
159
+
160
+ // Handles "data-method" on links such as:
161
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
162
+ handleMethod: function(link) {
163
+ var href = link.attr('href'),
164
+ method = link.data('method'),
165
+ target = link.attr('target'),
166
+ csrf_token = $('meta[name=csrf-token]').attr('content'),
167
+ csrf_param = $('meta[name=csrf-param]').attr('content'),
168
+ form = $('<form method="post" action="' + href + '"></form>'),
169
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
170
+
171
+ if (csrf_param !== undefined && csrf_token !== undefined) {
172
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
173
+ }
174
+
175
+ if (target) { form.attr('target', target); }
176
+
177
+ form.hide().append(metadata_input).appendTo('body');
178
+ form.submit();
179
+ },
180
+
181
+ /* Disables form elements:
182
+ - Caches element value in 'ujs:enable-with' data store
183
+ - Replaces element text with value of 'data-disable-with' attribute
184
+ - Sets disabled property to true
185
+ */
186
+ disableFormElements: function(form) {
187
+ form.find(rails.disableSelector).each(function() {
188
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
189
+ element.data('ujs:enable-with', element[method]());
190
+ element[method](element.data('disable-with'));
191
+ element.prop('disabled', true);
192
+ });
193
+ },
194
+
195
+ /* Re-enables disabled form elements:
196
+ - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
197
+ - Sets disabled property to false
198
+ */
199
+ enableFormElements: function(form) {
200
+ form.find(rails.enableSelector).each(function() {
201
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
202
+ if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
203
+ element.prop('disabled', false);
204
+ });
205
+ },
206
+
207
+ /* For 'data-confirm' attribute:
208
+ - Fires `confirm` event
209
+ - Shows the confirmation dialog
210
+ - Fires the `confirm:complete` event
211
+
212
+ Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
213
+ Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
214
+ Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
215
+ return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
216
+ */
217
+ allowAction: function(element) {
218
+ var message = element.data('confirm'),
219
+ answer = false, callback;
220
+ if (!message) { return true; }
221
+
222
+ if (rails.fire(element, 'confirm')) {
223
+ answer = rails.confirm(message);
224
+ callback = rails.fire(element, 'confirm:complete', [answer]);
225
+ }
226
+ return answer && callback;
227
+ },
228
+
229
+ // Helper function which checks for blank inputs in a form that match the specified CSS selector
230
+ blankInputs: function(form, specifiedSelector, nonBlank) {
231
+ var inputs = $(), input,
232
+ selector = specifiedSelector || 'input,textarea';
233
+ form.find(selector).each(function() {
234
+ input = $(this);
235
+ // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
236
+ if (nonBlank ? input.val() : !input.val()) {
237
+ inputs = inputs.add(input);
238
+ }
239
+ });
240
+ return inputs.length ? inputs : false;
241
+ },
242
+
243
+ // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
244
+ nonBlankInputs: function(form, specifiedSelector) {
245
+ return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
246
+ },
247
+
248
+ // Helper function, needed to provide consistent behavior in IE
249
+ stopEverything: function(e) {
250
+ $(e.target).trigger('ujs:everythingStopped');
251
+ e.stopImmediatePropagation();
252
+ return false;
253
+ },
254
+
255
+ // find all the submit events directly bound to the form and
256
+ // manually invoke them. If anyone returns false then stop the loop
257
+ callFormSubmitBindings: function(form) {
258
+ var events = form.data('events'), continuePropagation = true;
259
+ if (events !== undefined && events['submit'] !== undefined) {
260
+ $.each(events['submit'], function(i, obj){
261
+ if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
262
+ });
263
+ }
264
+ return continuePropagation;
265
+ },
266
+
267
+ // replace element's html with the 'data-disable-with' after storing original html
268
+ // and prevent clicking on it
269
+ disableElement: function(element) {
270
+ element.data('ujs:enable-with', element.html()); // store enabled state
271
+ element.html(element.data('disable-with')); // set to disabled state
272
+ element.bind('click.railsDisable', function(e) { // prevent further clicking
273
+ return rails.stopEverything(e)
274
+ });
275
+ },
276
+
277
+ // restore element to its original state which was disabled by 'disableElement' above
278
+ enableElement: function(element) {
279
+ if (element.data('ujs:enable-with') !== undefined) {
280
+ element.html(element.data('ujs:enable-with')); // set to old enabled state
281
+ // this should be element.removeData('ujs:enable-with')
282
+ // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
283
+ element.data('ujs:enable-with', false); // clean up cache
284
+ }
285
+ element.unbind('click.railsDisable'); // enable element
286
+ }
287
+
288
+ };
289
+
290
+ $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
291
+
292
+ $(rails.linkDisableSelector).live('ajax:complete', function() {
293
+ rails.enableElement($(this));
294
+ });
295
+
296
+ $(rails.linkClickSelector).live('click.rails', function(e) {
297
+ var link = $(this), method = link.data('method'), data = link.data('params');
298
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
299
+
300
+ if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
301
+
302
+ if (link.data('remote') !== undefined) {
303
+ if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
304
+ rails.handleRemote(link);
305
+ return false;
306
+ } else if (link.data('method')) {
307
+ rails.handleMethod(link);
308
+ return false;
309
+ }
310
+ });
311
+
312
+ $(rails.inputChangeSelector).live('change.rails', function(e) {
313
+ var link = $(this);
314
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
315
+
316
+ rails.handleRemote(link);
317
+ return false;
318
+ });
319
+
320
+ $(rails.formSubmitSelector).live('submit.rails', function(e) {
321
+ var form = $(this),
322
+ remote = form.data('remote') !== undefined,
323
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
324
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
325
+
326
+ if (!rails.allowAction(form)) return rails.stopEverything(e);
327
+
328
+ // skip other logic when required values are missing or file upload is present
329
+ if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
330
+ return rails.stopEverything(e);
331
+ }
332
+
333
+ if (remote) {
334
+ if (nonBlankFileInputs) {
335
+ return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
336
+ }
337
+
338
+ // If browser does not support submit bubbling, then this live-binding will be called before direct
339
+ // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
340
+ if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
341
+
342
+ rails.handleRemote(form);
343
+ return false;
344
+ } else {
345
+ // slight timeout so that the submit button gets properly serialized
346
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
347
+ }
348
+ });
349
+
350
+ $(rails.formInputClickSelector).live('click.rails', function(event) {
351
+ var button = $(this);
352
+
353
+ if (!rails.allowAction(button)) return rails.stopEverything(event);
354
+
355
+ // register the pressed submit button
356
+ var name = button.attr('name'),
357
+ data = name ? {name:name, value:button.val()} : null;
358
+
359
+ button.closest('form').data('ujs:submit-button', data);
360
+ });
361
+
362
+ $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
363
+ if (this == event.target) rails.disableFormElements($(this));
364
+ });
365
+
366
+ $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
367
+ if (this == event.target) rails.enableFormElements($(this));
368
+ });
369
+
370
+ })( jQuery );
371
+ ;
372
+ FI"
373
+ F"%4197c26478577e266a5eaeb772acd096