emmy-machine 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af90dd06e107ddfab402d4e78eb7b9aa3112bca4
4
- data.tar.gz: 4e9081e0309625ebe177256489f22d11c7cef1b3
3
+ metadata.gz: cbcf6dad55c2c829b3c317639952d0b1d1a73cd9
4
+ data.tar.gz: 2df6741e6561736c9065ffa3a816d88a9cdef981
5
5
  SHA512:
6
- metadata.gz: 56c432fce256b7ac5012f819457dd0f804a7658d53860692fcfc64205fc5043f08dc86f25f275a426aab34a566de697bb6fe4d5dce27abe6952412c11ef95256
7
- data.tar.gz: 0a75bf638505a3a690e880c4d46e33da5c0a43d093788bd6c210a3f30ba89a2297c84170450cdcc082cb8552df3367aac03ca0237869cd65b711af42d083292b
6
+ metadata.gz: b9242b823d1f132e80dadc98382f09642c788ff0398142ea5ac9aa9a2c230a909d8b3b490dca89ae52333f91c64fe5b9e1b2a69fe9aad81e54fac6ff84a4cfbe
7
+ data.tar.gz: 8ca89dede626c70cf4c00b266cacf819ba3dac7cdf6618056c7f02f8a2ed2603c2de3fcf362c0362c8998f5daa90fa8171ad3f0ad40efd3dcf032ebf2f4b23fb
@@ -17,8 +17,11 @@ module EmmyMachine
17
17
  end
18
18
 
19
19
  def run_block &b
20
- EventMachine.run_block do
21
- fiber_block &b
20
+ EventMachine.run do
21
+ fiber_block do
22
+ yield
23
+ EventMachine.stop
24
+ end
22
25
  end
23
26
  end
24
27
 
@@ -55,9 +58,9 @@ module EmmyMachine
55
58
  # emmy.connect(*emmy.http.get(url))
56
59
  def connect(url, *a, &b)
57
60
  url = URI(url.to_s)
58
- b = a.last if b.nil? && a.size > 0 && a.last.is_a?(Proc)
59
- handler = a.empty? ? Connection : a.first
60
-
61
+ handler = a.empty? ? Connection : a.shift
62
+ b ||= a.shift if a.first.is_a?(Proc) || a.first.is_a?(Method)
63
+
61
64
  case url.scheme
62
65
  when "tcp" then
63
66
  EventMachine.connect(url.host, url.port, handler, *a, &b)
@@ -76,8 +79,8 @@ module EmmyMachine
76
79
  # emmy.bind(* emmy.server.thin("tcp://localhost:4780", app))
77
80
  def bind(url, *a, &b)
78
81
  url = URI(url.to_s)
79
- b = a.last if b.nil? && a.size > 0 && a.last.is_a?(Proc)
80
- handler = a.empty? ? Connection : a.first
82
+ handler = a.empty? ? Connection : a.shift
83
+ b ||= a.shift if a.first.is_a?(Proc) || a.first.is_a?(Method)
81
84
 
82
85
  case url.scheme
83
86
  when "tcp" then
@@ -1,3 +1,3 @@
1
1
  module EmmyMachine
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emmy-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Che
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine