ballast 1.5.3 → 1.6.0

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.
@@ -291,7 +291,7 @@
291
291
  </div>
292
292
 
293
293
  <div id="footer">
294
- Generated on Sat Jan 4 16:26:00 2014 by
294
+ Generated on Sat Jan 25 11:54:04 2014 by
295
295
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
296
296
  0.8.7.3 (ruby-2.1.0).
297
297
  </div>
@@ -638,7 +638,7 @@
638
638
  </div>
639
639
 
640
640
  <div id="footer">
641
- Generated on Sat Jan 4 16:26:00 2014 by
641
+ Generated on Sat Jan 25 11:54:04 2014 by
642
642
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
643
643
  0.8.7.3 (ruby-2.1.0).
644
644
  </div>
@@ -260,7 +260,7 @@ Subfolders are not supported.</p>
260
260
  <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_section'>section</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_content'>content</span><span class='lbracket'>[</span><span class='id identifier rubyid_environment'>environment</span><span class='rbracket'>]</span>
261
261
  <span class='kw'>end</span>
262
262
 
263
- <span class='id identifier rubyid_enable_dotted_access'>enable_dotted_access</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
263
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable_dotted_access'>enable_dotted_access</span>
264
264
  <span class='kw'>end</span></pre>
265
265
  </td>
266
266
  </tr>
@@ -273,7 +273,7 @@ Subfolders are not supported.</p>
273
273
  </div>
274
274
 
275
275
  <div id="footer">
276
- Generated on Sat Jan 4 16:26:01 2014 by
276
+ Generated on Sat Jan 25 11:54:05 2014 by
277
277
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
278
278
  0.8.7.3 (ruby-2.1.0).
279
279
  </div>
@@ -408,7 +408,7 @@
408
408
  </div>
409
409
 
410
410
  <div id="footer">
411
- Generated on Sat Jan 4 16:26:00 2014 by
411
+ Generated on Sat Jan 25 11:54:05 2014 by
412
412
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
413
413
  0.8.7.3 (ruby-2.1.0).
414
414
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jan 4 16:26:00 2014 by
119
+ Generated on Sat Jan 25 11:54:04 2014 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.3 (ruby-2.1.0).
122
122
  </div>
@@ -317,7 +317,7 @@
317
317
  </div>
318
318
 
319
319
  <div id="footer">
320
- Generated on Sat Jan 4 16:26:00 2014 by
320
+ Generated on Sat Jan 25 11:54:04 2014 by
321
321
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
322
322
  0.8.7.3 (ruby-2.1.0).
323
323
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jan 4 16:26:00 2014 by
151
+ Generated on Sat Jan 25 11:54:05 2014 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.3 (ruby-2.1.0).
154
154
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jan 4 16:26:00 2014 by
151
+ Generated on Sat Jan 25 11:54:05 2014 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.3 (ruby-2.1.0).
154
154
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jan 4 16:26:00 2014 by
151
+ Generated on Sat Jan 25 11:54:05 2014 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.3 (ruby-2.1.0).
154
154
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jan 4 16:26:00 2014 by
119
+ Generated on Sat Jan 25 11:54:04 2014 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.3 (ruby-2.1.0).
122
122
  </div>
@@ -345,7 +345,7 @@
345
345
  </div>
346
346
 
347
347
  <div id="footer">
348
- Generated on Sat Jan 4 16:26:01 2014 by
348
+ Generated on Sat Jan 25 11:54:05 2014 by
349
349
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
350
350
  0.8.7.3 (ruby-2.1.0).
351
351
  </div>
@@ -1295,7 +1295,7 @@ as owner will be created.</p>
1295
1295
  </div>
1296
1296
 
1297
1297
  <div id="footer">
1298
- Generated on Sat Jan 4 16:26:01 2014 by
1298
+ Generated on Sat Jan 25 11:54:05 2014 by
1299
1299
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1300
1300
  0.8.7.3 (ruby-2.1.0).
1301
1301
  </div>
@@ -302,8 +302,7 @@
302
302
  32
303
303
  33
304
304
  34
305
- 35
306
- 36</pre>
305
+ 35</pre>
307
306
  </td>
308
307
  <td>
309
308
  <pre class="code"><span class="info file"># File 'lib/ballast/operations_chain.rb', line 32</span>
@@ -311,7 +310,6 @@
311
310
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_operations'>operations</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
312
311
  <span class='ivar'>@context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span>
313
312
  <span class='ivar'>@operations</span> <span class='op'>=</span> <span class='id identifier rubyid_operations'>operations</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span>
314
- <span class='id identifier rubyid_setup'>setup</span>
315
313
  <span class='kw'>end</span></pre>
316
314
  </td>
317
315
  </tr>
@@ -403,7 +401,14 @@
403
401
  34
404
402
  35
405
403
  36
406
- 37</pre>
404
+ 37
405
+ 38
406
+ 39
407
+ 40
408
+ 41
409
+ 42
410
+ 43
411
+ 44</pre>
407
412
  </td>
408
413
  <td>
409
414
  <pre class="code"><span class="info file"># File 'lib/ballast/operations_chain.rb', line 11</span>
@@ -432,8 +437,15 @@
432
437
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_operations'>operations</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
433
438
  <span class='ivar'>@context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span>
434
439
  <span class='ivar'>@operations</span> <span class='op'>=</span> <span class='id identifier rubyid_operations'>operations</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span>
435
- <span class='id identifier rubyid_setup'>setup</span>
436
440
  <span class='kw'>end</span>
441
+
442
+ <span class='id identifier rubyid_private'>private</span>
443
+ <span class='comment'># Returns the operations to perform.
444
+ </span> <span class='comment'>#
445
+ </span> <span class='comment'># @return [Array] An array of operations to perform.
446
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_interactors'>interactors</span>
447
+ <span class='ivar'>@operations</span>
448
+ <span class='kw'>end</span>
437
449
  <span class='kw'>end</span></pre>
438
450
  </td>
439
451
  </tr>
@@ -576,7 +588,7 @@ as owner will be created.</p>
576
588
  </div>
577
589
 
578
590
  <div id="footer">
579
- Generated on Sat Jan 4 16:26:01 2014 by
591
+ Generated on Sat Jan 25 11:54:05 2014 by
580
592
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
581
593
  0.8.7.3 (ruby-2.1.0).
582
594
  </div>
@@ -908,7 +908,7 @@
908
908
  </div>
909
909
 
910
910
  <div id="footer">
911
- Generated on Sat Jan 4 16:26:01 2014 by
911
+ Generated on Sat Jan 25 11:54:05 2014 by
912
912
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
913
913
  0.8.7.3 (ruby-2.1.0).
914
914
  </div>
@@ -134,7 +134,7 @@
134
134
 
135
135
  </div>
136
136
  </dt>
137
- <dd><pre class="code"><span class='int'>5</span></pre></dd>
137
+ <dd><pre class="code"><span class='int'>6</span></pre></dd>
138
138
 
139
139
  <dt id="PATCH-constant" class="">PATCH =
140
140
  <div class="docstring">
@@ -149,7 +149,7 @@
149
149
 
150
150
  </div>
151
151
  </dt>
152
- <dd><pre class="code"><span class='int'>3</span></pre></dd>
152
+ <dd><pre class="code"><span class='int'>0</span></pre></dd>
153
153
 
154
154
  <dt id="STRING-constant" class="">STRING =
155
155
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sat Jan 4 16:26:00 2014 by
183
+ Generated on Sat Jan 25 11:54:04 2014 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.8.7.3 (ruby-2.1.0).
186
186
  </div>
data/doc/_index.html CHANGED
@@ -310,7 +310,7 @@
310
310
  </div>
311
311
 
312
312
  <div id="footer">
313
- Generated on Sat Jan 4 16:26:00 2014 by
313
+ Generated on Sat Jan 25 11:54:04 2014 by
314
314
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
315
315
  0.8.7.3 (ruby-2.1.0).
316
316
  </div>
data/doc/file.README.html CHANGED
@@ -106,7 +106,7 @@
106
106
  </div></div>
107
107
 
108
108
  <div id="footer">
109
- Generated on Sat Jan 4 16:26:00 2014 by
109
+ Generated on Sat Jan 25 11:54:04 2014 by
110
110
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
111
111
  0.8.7.3 (ruby-2.1.0).
112
112
  </div>
data/doc/index.html CHANGED
@@ -106,7 +106,7 @@
106
106
  </div></div>
107
107
 
108
108
  <div id="footer">
109
- Generated on Sat Jan 4 16:26:00 2014 by
109
+ Generated on Sat Jan 25 11:54:04 2014 by
110
110
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
111
111
  0.8.7.3 (ruby-2.1.0).
112
112
  </div>
data/doc/method_list.html CHANGED
@@ -228,14 +228,14 @@
228
228
 
229
229
 
230
230
  <li class="r1 ">
231
- <span class='object_link'><a href="Ballast/Operation.html#perform-class_method" title="Ballast::Operation.perform (method)">perform</a></span>
232
- <small>Ballast::Operation</small>
231
+ <span class='object_link'><a href="Ballast/OperationsChain.html#perform-class_method" title="Ballast::OperationsChain.perform (method)">perform</a></span>
232
+ <small>Ballast::OperationsChain</small>
233
233
  </li>
234
234
 
235
235
 
236
236
  <li class="r2 ">
237
- <span class='object_link'><a href="Ballast/OperationsChain.html#perform-class_method" title="Ballast::OperationsChain.perform (method)">perform</a></span>
238
- <small>Ballast::OperationsChain</small>
237
+ <span class='object_link'><a href="Ballast/Operation.html#perform-class_method" title="Ballast::Operation.perform (method)">perform</a></span>
238
+ <small>Ballast::Operation</small>
239
239
  </li>
240
240
 
241
241
 
@@ -246,78 +246,84 @@
246
246
 
247
247
 
248
248
  <li class="r2 ">
249
+ <span class='object_link'><a href="Ballast/Concerns/Common.html#perform_operations_chain-instance_method" title="Ballast::Concerns::Common#perform_operations_chain (method)">#perform_operations_chain</a></span>
250
+ <small>Ballast::Concerns::Common</small>
251
+ </li>
252
+
253
+
254
+ <li class="r1 ">
249
255
  <span class='object_link'><a href="Ballast/Operation.html#perform_with_handling-instance_method" title="Ballast::Operation#perform_with_handling (method)">#perform_with_handling</a></span>
250
256
  <small>Ballast::Operation</small>
251
257
  </li>
252
258
 
253
259
 
254
- <li class="r1 ">
260
+ <li class="r2 ">
255
261
  <span class='object_link'><a href="Ballast/Concerns/Ajax.html#prepare_ajax-instance_method" title="Ballast::Concerns::Ajax#prepare_ajax (method)">#prepare_ajax</a></span>
256
262
  <small>Ballast::Concerns::Ajax</small>
257
263
  </li>
258
264
 
259
265
 
260
- <li class="r2 ">
266
+ <li class="r1 ">
261
267
  <span class='object_link'><a href="Ballast/Concerns/Ajax.html#prevent_caching-instance_method" title="Ballast::Concerns::Ajax#prevent_caching (method)">#prevent_caching</a></span>
262
268
  <small>Ballast::Concerns::Ajax</small>
263
269
  </li>
264
270
 
265
271
 
266
- <li class="r1 ">
272
+ <li class="r2 ">
267
273
  <span class='object_link'><a href="Ballast/RequestDomainMatcher.html#replace_block-instance_method" title="Ballast::RequestDomainMatcher#replace_block (method)">#replace_block</a></span>
268
274
  <small>Ballast::RequestDomainMatcher</small>
269
275
  </li>
270
276
 
271
277
 
272
- <li class="r2 ">
278
+ <li class="r1 ">
273
279
  <span class='object_link'><a href="Ballast/RequestDomainMatcher.html#replace_pattern-instance_method" title="Ballast::RequestDomainMatcher#replace_pattern (method)">#replace_pattern</a></span>
274
280
  <small>Ballast::RequestDomainMatcher</small>
275
281
  </li>
276
282
 
277
283
 
278
- <li class="r1 ">
284
+ <li class="r2 ">
279
285
  <span class='object_link'><a href="Ballast/RequestDomainMatcher.html#replace_string-instance_method" title="Ballast::RequestDomainMatcher#replace_string (method)">#replace_string</a></span>
280
286
  <small>Ballast::RequestDomainMatcher</small>
281
287
  </li>
282
288
 
283
289
 
284
- <li class="r2 ">
290
+ <li class="r1 ">
285
291
  <span class='object_link'><a href="Ballast/Operation.html#resolve_error-instance_method" title="Ballast::Operation#resolve_error (method)">#resolve_error</a></span>
286
292
  <small>Ballast::Operation</small>
287
293
  </li>
288
294
 
289
295
 
290
- <li class="r1 ">
296
+ <li class="r2 ">
291
297
  <span class='object_link'><a href="Ballast/Errors/BaseError.html#response-instance_method" title="Ballast::Errors::BaseError#response (method)">#response</a></span>
292
298
  <small>Ballast::Errors::BaseError</small>
293
299
  </li>
294
300
 
295
301
 
296
- <li class="r2 ">
302
+ <li class="r1 ">
297
303
  <span class='object_link'><a href="Ballast/Concerns/View.html#scope_css-instance_method" title="Ballast::Concerns::View#scope_css (method)">#scope_css</a></span>
298
304
  <small>Ballast::Concerns::View</small>
299
305
  </li>
300
306
 
301
307
 
302
- <li class="r1 ">
308
+ <li class="r2 ">
303
309
  <span class='object_link'><a href="Ballast/Concerns/Ajax.html#send_ajax-instance_method" title="Ballast::Concerns::Ajax#send_ajax (method)">#send_ajax</a></span>
304
310
  <small>Ballast::Concerns::Ajax</small>
305
311
  </li>
306
312
 
307
313
 
308
- <li class="r2 ">
314
+ <li class="r1 ">
309
315
  <span class='object_link'><a href="Ballast/Concerns/Common.html#sending_data%3F-instance_method" title="Ballast::Concerns::Common#sending_data? (method)">#sending_data?</a></span>
310
316
  <small>Ballast::Concerns::Common</small>
311
317
  </li>
312
318
 
313
319
 
314
- <li class="r1 ">
320
+ <li class="r2 ">
315
321
  <span class='object_link'><a href="Ballast/Operation.html#setup_response-instance_method" title="Ballast::Operation#setup_response (method)">#setup_response</a></span>
316
322
  <small>Ballast::Operation</small>
317
323
  </li>
318
324
 
319
325
 
320
- <li class="r2 ">
326
+ <li class="r1 ">
321
327
  <span class='object_link'><a href="Ballast/Concerns/Ajax.html#update_ajax-instance_method" title="Ballast::Concerns::Ajax#update_ajax (method)">#update_ajax</a></span>
322
328
  <small>Ballast::Concerns::Ajax</small>
323
329
  </li>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Jan 4 16:26:00 2014 by
106
+ Generated on Sat Jan 25 11:54:04 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.3 (ruby-2.1.0).
109
109
  </div>
@@ -73,13 +73,21 @@ module Ballast
73
73
  end
74
74
 
75
75
  # Allows HTTP Cross-Origin Resource Sharing.
76
- def allow_cors
76
+ #
77
+ # @param allow_origin [String] The value for the `Access-Control-Allow-Origin` header.
78
+ # @param allow_methods [Array] A list of methods for the `Access-Control-Allow-Methods` header.
79
+ # @param allow_headers [String] The value for the `Access-Control-Allow-Headers` header.
80
+ # @param max_age [Float|Fixnum] The value for the `Access-Control-Max-Age` header.
81
+ # @param allow_credentials [Boolean] The value for the `Access-Control-Allow-Credentials` header.
82
+ def allow_cors(allow_origin: "*", allow_methods: [:post, :get, :options], allow_headers: "*", max_age: 1.year, allow_credentials: false)
77
83
  headers.merge!({
78
- "Access-Control-Allow-Origin" => "*",
79
- "Access-Control-Allow-Methods" => "POST, GET, OPTIONS",
80
- "Access-Control-Allow-Headers" => "*",
81
- "Access-Control-Max-Age" => 1.year.to_i.to_s
84
+ "Access-Control-Allow-Origin" => allow_origin,
85
+ "Access-Control-Allow-Methods" => allow_methods.collect {|m| m.to_s.upcase }.join(", "),
86
+ "Access-Control-Allow-Headers" => allow_headers,
87
+ "Access-Control-Max-Age" => max_age.to_i.to_s
82
88
  })
89
+
90
+ headers["Access-Control-Allow-Credentials"] = "true" if allow_credentials
83
91
  end
84
92
 
85
93
  # Disallows web robots.
@@ -26,11 +26,21 @@ module Ballast
26
26
  # @param klass [Class] The operation to perform.
27
27
  # @param owner [Object] The owner to use. By default it uses itself.
28
28
  # @param kwargs [Hash] The arguments for performing.
29
- # @return [Operation] The performed operation
29
+ # @return [Operation] The performed operation.
30
30
  def perform_operation(klass, owner = nil, **kwargs)
31
31
  @operation = klass.perform(owner || self, **kwargs)
32
32
  end
33
33
 
34
+ # Performs an operations chain, using itself as owner by default.
35
+ #
36
+ # @param klasses [Array] The operations to perform.
37
+ # @param owner [Object] The owner to use. By default it uses itself.
38
+ # @param kwargs [Hash] The arguments for performing.
39
+ # @return [OperationChain] The performed operation chain.
40
+ def perform_operations_chain(klasses, owner = nil, **kwargs)
41
+ @operation = Ballast::OperationsChain.perform(owner || self, klasses, **kwargs)
42
+ end
43
+
34
44
  # Formats a relative date using abbreviation or short formats.
35
45
  #
36
46
  # @param date [DateTime] The date to format.
@@ -23,20 +23,7 @@ module Ballast
23
23
  self[section] = content[environment]
24
24
  end
25
25
 
26
- enable_dotted_access(self)
26
+ self.enable_dotted_access
27
27
  end
28
-
29
- private
30
- # Enables dotted access on a root object and its nested hashes.
31
- #
32
- # @param root [Hash] The hash to manage.
33
- def enable_dotted_access(root)
34
- root.extend(Hashie::Extensions::MethodReader)
35
- root.extend(Hashie::Extensions::MethodQuery)
36
-
37
- root.each do |_, node|
38
- enable_dotted_access(node) if node.is_a?(Hash)
39
- end
40
- end
41
28
  end
42
29
  end