ballast 1.8.0 → 1.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c802071fba8b05babb9c4577a90ac4e57f62c8c
4
- data.tar.gz: ce018497207921be1527567a4d6ef4e7f3733675
3
+ metadata.gz: 39e19900481364236e6aae98ac58d33aa1166ae2
4
+ data.tar.gz: b49b4116fe02f4ef2cc703223872e92b1858d1c2
5
5
  SHA512:
6
- metadata.gz: a1e9bf785dc3ffb8aed3a4d0969b32cd8a12df3bd9b216e0555eafec957c19c375e24e4a4c144ab552e3d73d8f21e9c42de72abdae41e2fd95f03b9b284aa016
7
- data.tar.gz: 97c56b3504e4e9573e97866def360a22cf9a926c56efcf78d27175f0d434a32aeb5a78936e88ff10d537928795ac6d9c3c4e96c488ebc501e1c14f12c3931184
6
+ metadata.gz: 6aaad63d5f226fa63669282006bd414d2d1652b3b79543a3bac939790eda408d5d516a75e15c23f38291aef4773dae66685d798d2050fafc6a75713559bba1cc
7
+ data.tar.gz: 07a227ce4e58db272e7e8770469d3ba05a1bb002c845482ea7c127536e6a504961dc99670ce7cbbd8aa281fe2c18f5399140fc9ceb6c60b83e14604e3bd38e0a
data/.gitignore CHANGED
@@ -4,6 +4,7 @@ coverage/
4
4
  pkg/
5
5
  .idea/
6
6
  .yardoc/
7
+ .bundle/
7
8
  /metrics
8
9
  /.metrics
9
10
  /tmp/metric_fu
@@ -2,7 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1.0
5
- before_install: gem install bundler -v "1.5.1"
6
5
  script: bundle exec rake spec:coverage
7
6
  gemfile: .travis-gemfile
8
7
  notifications:
@@ -1,3 +1,7 @@
1
+ ### 1.9.0 / 2014-02-16
2
+
3
+ * Added `start_reactor` to `Ballast.in_em_thread`.
4
+
1
5
  ### 1.8.0 / 2014-01-29
2
6
 
3
7
  * Added `Ballast.in_em_thread`.
data/Gemfile CHANGED
@@ -17,5 +17,5 @@ gem "simplecov", ">= 0.8.2"
17
17
  gem "coveralls", ">= 0.7.0", require: false
18
18
  gem "pry", ">= 0"
19
19
  gem "yard", ">= 0.8.7.3"
20
- gem "kramdown", ">= 1.3.1"
21
- gem "github-markup", ">= 1.0.0"
20
+ gem "kramdown", ">= 1.3.2"
21
+ gem "github-markup", ">= 1.0.2"
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency("actionpack", ">= 4.0.0")
28
28
  gem.add_dependency("rack", "~> 1.5.2")
29
29
  gem.add_dependency("oj", "~> 2.5.4")
30
- gem.add_dependency("brauser", "~> 3.2.5")
30
+ gem.add_dependency("brauser", "~> 3.2.6")
31
31
  gem.add_dependency("interactor", "~> 2.1.0")
32
32
  gem.add_dependency("addressable", "~> 2.3.5")
33
33
  gem.add_dependency("rack-fiber_pool", ">= 0.9.3")
@@ -127,7 +127,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
127
127
  <li class="public ">
128
128
  <span class="summary_signature">
129
129
 
130
- <a href="#in_em_thread-class_method" title="in_em_thread (class method)">+ (Object) <strong>in_em_thread</strong>(&amp;block) </a>
130
+ <a href="#in_em_thread-class_method" title="in_em_thread (class method)">+ (Object) <strong>in_em_thread</strong>(start_reactor = false, &amp;block) </a>
131
131
 
132
132
 
133
133
 
@@ -159,7 +159,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
159
159
  <div class="method_details first">
160
160
  <h3 class="signature first" id="in_em_thread-class_method">
161
161
 
162
- + (<tt>Object</tt>) <strong>in_em_thread</strong>(&amp;block)
162
+ + (<tt>Object</tt>) <strong>in_em_thread</strong>(start_reactor = false, &amp;block)
163
163
 
164
164
 
165
165
 
@@ -176,6 +176,23 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
176
176
  <p class="tag_title">Parameters:</p>
177
177
  <ul class="param">
178
178
 
179
+ <li>
180
+
181
+ <span class='name'>start_reactor</span>
182
+
183
+
184
+ <span class='type'>(<tt>Boolean</tt>)</span>
185
+
186
+
187
+ <em class="default">(defaults to: <tt>false</tt>)</em>
188
+
189
+
190
+ &mdash;
191
+ <div class='inline'><p>If start a EM::Synchrony reactor if none is running.</p>
192
+ </div>
193
+
194
+ </li>
195
+
179
196
  <li>
180
197
 
181
198
  <span class='name'>block</span>
@@ -200,7 +217,6 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
200
217
  <pre class="lines">
201
218
 
202
219
 
203
- 35
204
220
  36
205
221
  37
206
222
  38
@@ -208,16 +224,27 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
208
224
  40
209
225
  41
210
226
  42
211
- 43</pre>
227
+ 43
228
+ 44
229
+ 45
230
+ 46
231
+ 47
232
+ 48
233
+ 49</pre>
212
234
  </td>
213
235
  <td>
214
- <pre class="code"><span class="info file"># File 'lib/ballast.rb', line 35</span>
236
+ <pre class="code"><span class="info file"># File 'lib/ballast.rb', line 36</span>
215
237
 
216
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_in_em_thread'>in_em_thread</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
238
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_in_em_thread'>in_em_thread</span><span class='lparen'>(</span><span class='id identifier rubyid_start_reactor'>start_reactor</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
217
239
  <span class='kw'>if</span> <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_reactor_running?'>reactor_running?</span> <span class='kw'>then</span>
218
240
  <span class='const'>EM</span><span class='op'>::</span><span class='const'>Synchrony</span><span class='period'>.</span><span class='id identifier rubyid_defer'>defer</span> <span class='kw'>do</span>
219
241
  <span class='const'>Fiber</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_resume'>resume</span>
220
242
  <span class='kw'>end</span>
243
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_start_reactor'>start_reactor</span> <span class='kw'>then</span>
244
+ <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_synchrony'>synchrony</span> <span class='kw'>do</span>
245
+ <span class='const'>Ballast</span><span class='period'>.</span><span class='id identifier rubyid_in_em_thread'>in_em_thread</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
246
+ <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
247
+ <span class='kw'>end</span>
221
248
  <span class='kw'>else</span>
222
249
  <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
223
250
  <span class='kw'>end</span>
@@ -232,7 +259,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
232
259
  </div>
233
260
 
234
261
  <div id="footer">
235
- Generated on Wed Jan 29 14:58:29 2014 by
262
+ Generated on Sun Feb 16 14:30:46 2014 by
236
263
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
237
264
  0.8.7.3 (ruby-2.1.0).
238
265
  </div>
@@ -118,7 +118,7 @@
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Wed Jan 29 14:58:29 2014 by
121
+ Generated on Sun Feb 16 14:30:46 2014 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
123
  0.8.7.3 (ruby-2.1.0).
124
124
  </div>
@@ -895,7 +895,7 @@
895
895
  </div>
896
896
 
897
897
  <div id="footer">
898
- Generated on Wed Jan 29 14:58:29 2014 by
898
+ Generated on Sun Feb 16 14:30:47 2014 by
899
899
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
900
900
  0.8.7.3 (ruby-2.1.0).
901
901
  </div>
@@ -1098,7 +1098,7 @@ and <code>%:Z</code> for the zone name considering also DST.</p>
1098
1098
  </div>
1099
1099
 
1100
1100
  <div id="footer">
1101
- Generated on Wed Jan 29 14:58:29 2014 by
1101
+ Generated on Sun Feb 16 14:30:47 2014 by
1102
1102
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1103
1103
  0.8.7.3 (ruby-2.1.0).
1104
1104
  </div>
@@ -291,7 +291,7 @@
291
291
  </div>
292
292
 
293
293
  <div id="footer">
294
- Generated on Wed Jan 29 14:58:29 2014 by
294
+ Generated on Sun Feb 16 14:30:47 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>
@@ -850,7 +850,7 @@
850
850
  </div>
851
851
 
852
852
  <div id="footer">
853
- Generated on Wed Jan 29 14:58:29 2014 by
853
+ Generated on Sun Feb 16 14:30:46 2014 by
854
854
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
855
855
  0.8.7.3 (ruby-2.1.0).
856
856
  </div>
@@ -273,7 +273,7 @@ Subfolders are not supported.</p>
273
273
  </div>
274
274
 
275
275
  <div id="footer">
276
- Generated on Wed Jan 29 14:58:29 2014 by
276
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
411
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
119
+ Generated on Sun Feb 16 14:30:46 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 Wed Jan 29 14:58:29 2014 by
320
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
151
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
151
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
151
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
119
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
348
+ Generated on Sun Feb 16 14:30:47 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 Wed Jan 29 14:58:29 2014 by
1298
+ Generated on Sun Feb 16 14:30:47 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>
@@ -588,7 +588,7 @@ as owner will be created.</p>
588
588
  </div>
589
589
 
590
590
  <div id="footer">
591
- Generated on Wed Jan 29 14:58:29 2014 by
591
+ Generated on Sun Feb 16 14:30:47 2014 by
592
592
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
593
593
  0.8.7.3 (ruby-2.1.0).
594
594
  </div>
@@ -908,7 +908,7 @@
908
908
  </div>
909
909
 
910
910
  <div id="footer">
911
- Generated on Wed Jan 29 14:58:29 2014 by
911
+ Generated on Sun Feb 16 14:30:47 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'>8</span></pre></dd>
137
+ <dd><pre class="code"><span class='int'>9</span></pre></dd>
138
138
 
139
139
  <dt id="PATCH-constant" class="">PATCH =
140
140
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Wed Jan 29 14:58:29 2014 by
183
+ Generated on Sun Feb 16 14:30:46 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>
@@ -310,7 +310,7 @@
310
310
  </div>
311
311
 
312
312
  <div id="footer">
313
- Generated on Wed Jan 29 14:58:28 2014 by
313
+ Generated on Sun Feb 16 14:30:46 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>
@@ -106,7 +106,7 @@
106
106
  </div></div>
107
107
 
108
108
  <div id="footer">
109
- Generated on Wed Jan 29 14:58:28 2014 by
109
+ Generated on Sun Feb 16 14:30:46 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>
@@ -106,7 +106,7 @@
106
106
  </div></div>
107
107
 
108
108
  <div id="footer">
109
- Generated on Wed Jan 29 14:58:28 2014 by
109
+ Generated on Sun Feb 16 14:30:46 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>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Wed Jan 29 14:58:28 2014 by
106
+ Generated on Sun Feb 16 14:30:46 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>
@@ -31,12 +31,18 @@ require "ballast/middlewares/default_host"
31
31
  module Ballast
32
32
  # If running under eventmachine, run the block in a thread of its threadpool using EM::Synchrony, otherwise run the block normally.
33
33
  #
34
+ # @param start_reactor [Boolean] If start a EM::Synchrony reactor if none is running.
34
35
  # @param block [Proc] The block to run.
35
- def self.in_em_thread(&block)
36
+ def self.in_em_thread(start_reactor = false, &block)
36
37
  if EM.reactor_running? then
37
38
  EM::Synchrony.defer do
38
39
  Fiber.new { block.call }.resume
39
40
  end
41
+ elsif start_reactor then
42
+ EM.synchrony do
43
+ Ballast.in_em_thread(&block)
44
+ EM.stop
45
+ end
40
46
  else
41
47
  block.call
42
48
  end
@@ -13,7 +13,7 @@ module Ballast
13
13
  MAJOR = 1
14
14
 
15
15
  # The minor version.
16
- MINOR = 8
16
+ MINOR = 9
17
17
 
18
18
  # The patch version.
19
19
  PATCH = 0
@@ -24,5 +24,17 @@ describe Ballast do
24
24
  Ballast.in_em_thread { counter = 1 }
25
25
  expect(counter).to eq(1)
26
26
  end
27
+
28
+ it "should start a EM:Synchrony on the fly if requested to" do
29
+ counter = 0
30
+ expect(EM).to receive(:reactor_running?).and_return(false)
31
+ expect(EM).to receive(:reactor_running?).and_return(true)
32
+ expect(EM::Synchrony).to receive(:defer){|&block| block.call }
33
+ expect(EM).to receive(:synchrony).and_yield
34
+ expect(EM).to receive(:stop)
35
+
36
+ Ballast.in_em_thread(true) { counter = 1 }
37
+ expect(counter).to eq(1)
38
+ end
27
39
  end
28
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ballast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.5
61
+ version: 3.2.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.5
68
+ version: 3.2.6
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: interactor
71
71
  requirement: !ruby/object:Gem::Requirement