em-midori 0.0.2 → 0.0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/em-midori.rb +3 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3e3650adfc72cb61299f0a17fc198087ef4060
|
4
|
+
data.tar.gz: 057a29b2566249c006041761657b9e820a9242ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecbaabf8339e974cd6e4d7f68f80acfaa5f23ce9d22066cdb821dfae2e82f29ab8efbcba69b6c708b47973ff2c8535fb589ec8deee778deaa8041d1570fea68f
|
7
|
+
data.tar.gz: d60691596b34375a6d4f1d7a4256328ae9974bdb90e69169684c3d2a8d7a1eb7746a5ecc4dddf81610e77f49cf3020fde42501ee7aad8711f48c388793878148
|
data/lib/em-midori.rb
CHANGED
@@ -1,56 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
module Midori
|
5
|
-
def self.run(api=(Midori::API), ip=nil, port=nil)
|
6
|
-
ip ||= '127.0.0.1'
|
7
|
-
port ||= 8081
|
8
|
-
EventMachine.run {
|
9
|
-
route = api.new
|
10
|
-
puts "Midori Server Running on #{ip} at #{port}"
|
11
|
-
EventMachine.start_server ip, port, Midori::Server
|
12
|
-
}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module Midori::Server
|
17
|
-
def receive_data(data)
|
18
|
-
port, ip = Socket.unpack_sockaddr_in(get_peername)
|
19
|
-
puts "from #{ip}:#{port} comes a message:"
|
20
|
-
#puts data
|
21
|
-
send_data 'Hello World'
|
22
|
-
close_connection_after_writing
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class Midori::API
|
27
|
-
def self.get(route)
|
28
|
-
yield
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.post(route)
|
32
|
-
yield
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.put(route)
|
36
|
-
yield
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.delete(route)
|
40
|
-
yield
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.options(route)
|
44
|
-
yield
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.link(route)
|
48
|
-
yield
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.unlink(route)
|
52
|
-
yield
|
53
|
-
end
|
54
|
-
end
|
1
|
+
require 'em-midori/em-midori'
|
2
|
+
require 'em-midori/api'
|
3
|
+
require 'em-midori/server'
|
55
4
|
|
56
5
|
# Midori.run(Midori::API, '0.0.0.0', 8080)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-midori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HeckPsi Lab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|