hara 0.2.2 → 0.3.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 +7 -0
- data/README.md +45 -18
- data/hara.gemspec +5 -4
- data/lib/hara/app.rb +16 -48
- data/lib/hara/client_interaction.rb +26 -0
- data/lib/hara/default_filter.rb +9 -0
- data/lib/hara/filter.rb +60 -0
- data/lib/hara/server.rb +11 -23
- data/lib/hara/version.rb +1 -1
- data/lib/hara.rb +40 -2
- data/spec/app_spec.rb +8 -8
- data/spec/filter_spec.rb +51 -0
- data/spec/hara_spec.rb +0 -4
- data/spec/spec_helper.rb +14 -2
- metadata +34 -28
- data/lib/hara/base.rb +0 -3
- data/lib/hara/main.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f83818ae52c8a4eb9db097c057149a4b1c4078e
|
4
|
+
data.tar.gz: ba02fe00a42900cea3af4d7ee8a60aa74ecb31f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b60a714370f02384741883e26995d5f3136166e7df01236691502b3a739510e49d0eea863e487f21711bbdb87dcfd6c2aba7300a84449119edc386ad330e7b3
|
7
|
+
data.tar.gz: f33ffb17c068aab2a9cb35b02b8f17a98084884e7700113474ad3d4d52f507a573e94f85964084efb15e1df4a9e0fb868f91cd2f128d7f703c8fd7d6e2e70372
|
data/README.md
CHANGED
@@ -3,13 +3,11 @@
|
|
3
3
|
[](http://badge.fury.io/rb/hara)
|
4
4
|
[](https://travis-ci.org/jjyr/hara)
|
5
5
|
|
6
|
-
Hara is a
|
6
|
+
Hara is a websocket based application framework, build upon [em-websocket](https://github.com/igrigorik/em-websocket).
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Seems eventmachine and celluloid work well together :smile:
|
8
|
+
* Simple, easy to use.
|
9
|
+
* OO, Actor model(Celluloid).
|
10
|
+
* Event-io(em-websocket).
|
13
11
|
|
14
12
|
## Installation
|
15
13
|
|
@@ -25,26 +23,28 @@ Or install it yourself as:
|
|
25
23
|
|
26
24
|
$ gem install hara
|
27
25
|
|
28
|
-
##
|
26
|
+
## Basic Usage
|
29
27
|
|
30
28
|
*server*
|
31
29
|
```ruby
|
32
30
|
#test.rb
|
33
31
|
require 'hara'
|
34
32
|
|
35
|
-
class Echo
|
33
|
+
class Echo
|
36
34
|
include Hara::App
|
37
35
|
|
38
36
|
define_action :echo do |str|
|
39
|
-
|
37
|
+
send_msg str
|
40
38
|
end
|
41
39
|
end
|
40
|
+
|
41
|
+
Hara::Server.start 'localhost', '3000'
|
42
42
|
```
|
43
43
|
|
44
44
|
*client*
|
45
45
|
```javascript
|
46
46
|
var msg = JSON.stringify({action: 'echo',args:['hello world']})
|
47
|
-
var ws = new WebSocket('ws://localhost:
|
47
|
+
var ws = new WebSocket('ws://localhost:3000')
|
48
48
|
ws.onmessage = function(msg){alert(msg.data)}
|
49
49
|
|
50
50
|
//after a while
|
@@ -60,11 +60,11 @@ ws.send(msg)
|
|
60
60
|
## Full Usages
|
61
61
|
|
62
62
|
```ruby
|
63
|
-
require 'hara
|
63
|
+
require 'hara'
|
64
64
|
|
65
|
-
class Echo
|
66
|
-
#include Hara::App
|
67
|
-
#
|
65
|
+
class Echo
|
66
|
+
#include Hara::App make your Echo class become Celluloid::Actor,
|
67
|
+
#hara use actor per connection
|
68
68
|
include Hara::App
|
69
69
|
|
70
70
|
#Hara::App provide some callbacks
|
@@ -80,8 +80,8 @@ class Echo
|
|
80
80
|
|
81
81
|
define_action :echo do |str|
|
82
82
|
puts "#{client_ip} #{client_port}"
|
83
|
-
#send message to
|
84
|
-
|
83
|
+
#send message to client
|
84
|
+
send_msg str
|
85
85
|
end
|
86
86
|
|
87
87
|
define_action :exit do
|
@@ -95,7 +95,7 @@ class Echo
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def action_missing action, *args
|
98
|
-
|
98
|
+
send_msg 'error'
|
99
99
|
super
|
100
100
|
end
|
101
101
|
|
@@ -104,7 +104,34 @@ class Echo
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
#
|
107
|
+
# you can pass some options to start
|
108
|
+
server_options = {
|
109
|
+
#...some options, same as EM::Websocket.run
|
110
|
+
}
|
111
|
+
Hara::Server.start 'localhost', '3000', server_options
|
112
|
+
|
113
|
+
|
114
|
+
# Hara::Filter
|
115
|
+
# Filter can help you filter some connections before dispatched to app actor.
|
116
|
+
# Example: use Filter to authentication
|
117
|
+
require 'cgi/cookie'
|
118
|
+
|
119
|
+
class Echo
|
120
|
+
include Hara::App
|
121
|
+
#..some code
|
122
|
+
end
|
123
|
+
|
124
|
+
#class name is not matter
|
125
|
+
class Authentication
|
126
|
+
include Hara::Filter
|
127
|
+
|
128
|
+
# You must implement filter method, return value should be ture or false
|
129
|
+
def filter
|
130
|
+
# You can use some helper methods(headers, client_ip, send_msg...), just like Hara::App
|
131
|
+
CGI::Cookie.parse(headers['cookie'])['foo'] == ['bar']
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
108
135
|
Hara::Server.start 'localhost', '3000'
|
109
136
|
```
|
110
137
|
|
data/hara.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Hara::VERSION
|
9
9
|
spec.authors = ["jjy"]
|
10
10
|
spec.email = ["jjyruby@gmail.com"]
|
11
|
-
spec.description = %q{Hara
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{Hara is a websocket based application framework.}
|
12
|
+
spec.summary = %q{Hara build upon em-websocket, easy to use.}
|
13
13
|
spec.homepage = "http://github.com/jjyr/hara"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -19,8 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
|
22
|
-
spec.add_dependency "em-websocket", "
|
23
|
-
spec.add_dependency "
|
22
|
+
spec.add_dependency "em-websocket", ">= 0.5.0"
|
23
|
+
spec.add_dependency "eventmachine"
|
24
|
+
spec.add_dependency "celluloid", ">= 0.14.1"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
27
|
spec.add_development_dependency "rake"
|
data/lib/hara/app.rb
CHANGED
@@ -1,52 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require 'hara/client_interaction'
|
2
2
|
require 'celluloid'
|
3
3
|
require 'socket'
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
module Hara
|
7
|
-
class << self
|
8
|
-
def env
|
9
|
-
@_env ||= (ENV['APP_ENV'] || :development).to_sym
|
10
|
-
end
|
11
|
-
|
12
|
-
def env= env
|
13
|
-
@_env = env
|
14
|
-
end
|
15
|
-
|
16
|
-
#decode message, return action and args
|
17
|
-
def decode_msg msg
|
18
|
-
msg = JSON.parse(msg)
|
19
|
-
msg.values_at 'action', 'args'
|
20
|
-
end
|
21
|
-
|
22
|
-
def encode_msg action, *args
|
23
|
-
{action: action, args: args}.to_json
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
7
|
module App
|
28
|
-
|
8
|
+
include ClientInteraction
|
29
9
|
|
30
10
|
Actions = {}
|
31
11
|
|
32
12
|
class << self
|
33
13
|
def included klass
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
14
|
+
klass.send :include, Celluloid
|
15
|
+
klass.send :include, Celluloid::Logger
|
16
|
+
klass.send :finalizer, :app_finalizer
|
17
|
+
klass.send :extend, ClassMethods
|
18
|
+
::Hara.const_set :Application, klass
|
39
19
|
end
|
40
20
|
end
|
41
21
|
|
42
22
|
module ClassMethods
|
43
23
|
def define_action action, &block
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
24
|
+
action = action.to_s
|
25
|
+
warn "Action #{action} duplication defined" if Actions.has_key? action
|
26
|
+
Hara::Application.send :define_method, action, &block
|
27
|
+
method = Hara::Application.send :instance_method, action
|
28
|
+
Hara::Application.send :remove_method, action
|
29
|
+
Actions[action] = method
|
50
30
|
end
|
51
31
|
end
|
52
32
|
|
@@ -72,22 +52,10 @@ module Hara
|
|
72
52
|
raise NoMethodError, "undefined action '#{action}' for #{self}:#{self.class}"
|
73
53
|
end
|
74
54
|
|
75
|
-
#get client headers
|
76
|
-
def headers
|
77
|
-
handshake.headers_downcased
|
78
|
-
end
|
79
|
-
|
80
|
-
# close connection
|
81
|
-
def close code = nil, body = nil
|
82
|
-
@socket.close code, body
|
83
|
-
end
|
84
|
-
|
85
55
|
#below are internal functions(should not been overriding)
|
86
56
|
|
87
57
|
def initialize handshake, socket
|
88
|
-
|
89
|
-
@socket = socket
|
90
|
-
@client_port, @client_ip = Socket.unpack_sockaddr_in(socket.get_peername) #to get ip address of user
|
58
|
+
socket_setup handshake, socket
|
91
59
|
async.hara_setup
|
92
60
|
end
|
93
61
|
|
@@ -109,9 +77,9 @@ module Hara
|
|
109
77
|
|
110
78
|
def call_action action, *args
|
111
79
|
if Actions.has_key? action
|
112
|
-
|
80
|
+
Actions[action].bind(self).call *args
|
113
81
|
else
|
114
|
-
|
82
|
+
action_missing action, *args
|
115
83
|
end
|
116
84
|
end
|
117
85
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Hara
|
2
|
+
module ClientInteraction
|
3
|
+
attr_reader :socket, :handshake, :client_ip, :client_port
|
4
|
+
|
5
|
+
def socket_setup handshake, socket
|
6
|
+
@handshake = handshake
|
7
|
+
@socket = socket
|
8
|
+
@client_port, @client_ip = Socket.unpack_sockaddr_in(socket.get_peername) #to get ip address of user
|
9
|
+
end
|
10
|
+
|
11
|
+
# get client headers
|
12
|
+
def headers
|
13
|
+
handshake.headers_downcased
|
14
|
+
end
|
15
|
+
|
16
|
+
# send msg to client
|
17
|
+
def send_msg msg
|
18
|
+
socket.send msg
|
19
|
+
end
|
20
|
+
|
21
|
+
# close connection
|
22
|
+
def close code = nil, body = nil
|
23
|
+
@socket.close code, body
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/hara/filter.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'celluloid'
|
2
|
+
require 'hara/client_interaction'
|
3
|
+
|
4
|
+
module Hara
|
5
|
+
module Filter
|
6
|
+
include ClientInteraction
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def included klass
|
10
|
+
klass.send :include, Celluloid
|
11
|
+
klass.send :include, Celluloid::Logger
|
12
|
+
Hara.filter_class = klass
|
13
|
+
klass.send :extend, ClassMethods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def pool_size= size
|
19
|
+
Hara.filter_pool_size = size
|
20
|
+
end
|
21
|
+
|
22
|
+
def pool_size
|
23
|
+
Hara.filter_pool_size
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup_socket_callbacks handshake, ws
|
28
|
+
actor = Hara::Application.new handshake, ws
|
29
|
+
|
30
|
+
ws.onclose { |close_info = {}|
|
31
|
+
begin
|
32
|
+
actor.async.set_close_info close_info
|
33
|
+
actor.terminate! if actor.alive?
|
34
|
+
rescue Celluloid::DeadActorError => e
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
ws.onmessage { |msg|
|
39
|
+
actor.async.process_msg msg
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def run_filter handshake, socket
|
44
|
+
exclusive do
|
45
|
+
socket_setup handshake, socket
|
46
|
+
pass = self.filter
|
47
|
+
if pass
|
48
|
+
setup_socket_callbacks handshake, socket
|
49
|
+
else
|
50
|
+
close
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# you should implement this method and return true or false
|
56
|
+
def filter
|
57
|
+
raise NotImplementedError, 'You must implement method filter, return value can be true or false.'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/hara/server.rb
CHANGED
@@ -1,34 +1,22 @@
|
|
1
1
|
require 'em-websocket'
|
2
2
|
require 'eventmachine'
|
3
|
-
require 'hara/base'
|
4
3
|
|
5
4
|
module Hara
|
6
5
|
class Server
|
7
6
|
class << self
|
8
|
-
def start host, port
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
actor = nil
|
7
|
+
def start host, port, options = {}
|
8
|
+
puts "Server starting on #{host}:#{port}"
|
9
|
+
options = options.merge(host: host, port: port)
|
10
|
+
EM.epoll
|
11
|
+
EM.run do
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
EM::WebSocket.run(options) do |ws|
|
14
|
+
ws.onopen { |handshake|
|
15
|
+
Hara.filter_pool.async.run_filter handshake, ws
|
16
|
+
}
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
begin
|
21
|
-
actor.async.set_close_info close_info
|
22
|
-
actor.terminate! if actor.alive?
|
23
|
-
rescue Celluloid::DeadActorError => e
|
24
|
-
end
|
25
|
-
}
|
26
|
-
|
27
|
-
ws.onmessage { |msg|
|
28
|
-
actor.async.process_msg msg
|
29
|
-
}
|
30
|
-
end
|
31
|
-
}
|
19
|
+
end
|
32
20
|
end
|
33
21
|
end
|
34
22
|
end
|
data/lib/hara/version.rb
CHANGED
data/lib/hara.rb
CHANGED
@@ -1,2 +1,40 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require "hara/version"
|
2
|
+
|
3
|
+
module Hara
|
4
|
+
class << self
|
5
|
+
#decode message, return action and args
|
6
|
+
def decode_msg msg
|
7
|
+
msg = JSON.parse(msg)
|
8
|
+
msg.values_at 'action', 'args'
|
9
|
+
end
|
10
|
+
|
11
|
+
def encode_msg action, *args
|
12
|
+
{action: action, args: args}.to_json
|
13
|
+
end
|
14
|
+
|
15
|
+
def filter_class
|
16
|
+
@filter_class || DefaultFilter
|
17
|
+
end
|
18
|
+
|
19
|
+
def filter_class= klass
|
20
|
+
@filter_class = klass
|
21
|
+
end
|
22
|
+
|
23
|
+
def filter_pool_size= size
|
24
|
+
@filter_pool_size = size
|
25
|
+
end
|
26
|
+
|
27
|
+
def filter_pool_size
|
28
|
+
@filter_pool_size || 10
|
29
|
+
end
|
30
|
+
|
31
|
+
def filter_pool
|
32
|
+
@filter_pool ||= filter_class.pool(size: filter_pool_size)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'hara/app'
|
38
|
+
require 'hara/filter'
|
39
|
+
require 'hara/default_filter'
|
40
|
+
require 'hara/server'
|
data/spec/app_spec.rb
CHANGED
@@ -6,35 +6,35 @@ describe Hara::App do
|
|
6
6
|
include Hara::App
|
7
7
|
|
8
8
|
def after_connect
|
9
|
-
|
9
|
+
@states = []
|
10
10
|
end
|
11
11
|
|
12
12
|
def before_action action, *args
|
13
|
-
|
13
|
+
@states << [:before_action, action, args]
|
14
14
|
end
|
15
15
|
|
16
16
|
def after_action action, *args
|
17
|
-
|
17
|
+
@states << [:after_action, action, args]
|
18
18
|
end
|
19
19
|
|
20
20
|
def on_close close_info
|
21
|
-
|
21
|
+
@states << :closed
|
22
22
|
end
|
23
23
|
|
24
24
|
def action_missing action, *args
|
25
|
-
|
25
|
+
send_msg [:action_missing, action, args]
|
26
26
|
end
|
27
27
|
|
28
28
|
define_action :hello do |msg|
|
29
|
-
|
29
|
+
send_msg "hello#{msg}"
|
30
30
|
end
|
31
31
|
|
32
32
|
define_action :exit do
|
33
|
-
|
33
|
+
close 3333, "Bye"
|
34
34
|
end
|
35
35
|
|
36
36
|
def states
|
37
|
-
|
37
|
+
@states
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/spec/filter_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hara::Filter do
|
4
|
+
before :all do
|
5
|
+
@filter = Class.new do
|
6
|
+
include Hara::Filter
|
7
|
+
self.pool_size = 3
|
8
|
+
|
9
|
+
def filter
|
10
|
+
socket.remote_ip == 'localhost'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'Hara.filter_class should be set' do
|
16
|
+
Hara.filter_class.should == @filter
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'Hara.filter_pool_size should be set' do
|
20
|
+
Hara.filter_pool_size.should == 3
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Hara.filter_pool should work' do
|
24
|
+
wait_until{Hara.filter_pool}
|
25
|
+
Hara.filter_pool.nil?.should == false
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'filter' do
|
29
|
+
before :each do
|
30
|
+
@handshake = FayeHandshake.new
|
31
|
+
@socket = FayeSocket.new
|
32
|
+
@socket.alive = true
|
33
|
+
wait_until{Hara.filter_pool}
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'filter should close socket if not pass' do
|
37
|
+
@socket.remote_ip = '127.0.0.1'
|
38
|
+
Hara.filter_pool.run_filter @handshake, @socket
|
39
|
+
wait_until{!@socket.alive?}
|
40
|
+
@socket.alive?.should == false
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'filter should set callbacks on socket if pass' do
|
44
|
+
@socket.remote_ip = 'localhost'
|
45
|
+
Hara.filter_pool.run_filter @handshake, @socket
|
46
|
+
wait_until{@socket.onclose_block}
|
47
|
+
@socket.onmessage_block.should.is_a? Proc
|
48
|
+
@socket.onclose_block.should.is_a? Proc
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/hara_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'hara
|
1
|
+
require 'hara'
|
2
2
|
|
3
3
|
Celluloid.logger = nil
|
4
4
|
|
@@ -33,6 +33,10 @@ class FayeSocket
|
|
33
33
|
defined?(JRuby) ? @jruby_peername : @mri_peername
|
34
34
|
end
|
35
35
|
|
36
|
+
def alive= alive
|
37
|
+
@alive = alive
|
38
|
+
end
|
39
|
+
|
36
40
|
def alive?
|
37
41
|
@alive
|
38
42
|
end
|
@@ -41,7 +45,7 @@ class FayeSocket
|
|
41
45
|
if @alive
|
42
46
|
@close_info = [code, body]
|
43
47
|
@alive = false
|
44
|
-
@app.terminate!
|
48
|
+
@app.terminate! if @app
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
@@ -52,4 +56,12 @@ class FayeSocket
|
|
52
56
|
def client_read
|
53
57
|
@client_messages.shift
|
54
58
|
end
|
59
|
+
|
60
|
+
[:onclose, :onmessage, :onopen].each do |method|
|
61
|
+
attribute = "#{method}_block".to_sym
|
62
|
+
attr_accessor attribute
|
63
|
+
define_method method do |&blk|
|
64
|
+
__send__ "#{attribute}=", blk
|
65
|
+
end
|
66
|
+
end
|
55
67
|
end
|
metadata
CHANGED
@@ -1,52 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- jjy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: em-websocket
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.5.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: eventmachine
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: celluloid
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - '>='
|
36
46
|
- !ruby/object:Gem::Version
|
37
47
|
version: 0.14.1
|
38
48
|
type: :runtime
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - '>='
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: 0.14.1
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: bundler
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
59
|
- - ~>
|
52
60
|
- !ruby/object:Gem::Version
|
@@ -54,7 +62,6 @@ dependencies:
|
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
66
|
- - ~>
|
60
67
|
- !ruby/object:Gem::Version
|
@@ -62,20 +69,18 @@ dependencies:
|
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: rake
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - '>='
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - '>='
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
|
-
description: Hara
|
83
|
+
description: Hara is a websocket based application framework.
|
79
84
|
email:
|
80
85
|
- jjyruby@gmail.com
|
81
86
|
executables: []
|
@@ -91,40 +96,41 @@ files:
|
|
91
96
|
- hara.gemspec
|
92
97
|
- lib/hara.rb
|
93
98
|
- lib/hara/app.rb
|
94
|
-
- lib/hara/
|
95
|
-
- lib/hara/
|
99
|
+
- lib/hara/client_interaction.rb
|
100
|
+
- lib/hara/default_filter.rb
|
101
|
+
- lib/hara/filter.rb
|
96
102
|
- lib/hara/server.rb
|
97
103
|
- lib/hara/version.rb
|
98
104
|
- spec/app_spec.rb
|
105
|
+
- spec/filter_spec.rb
|
99
106
|
- spec/hara_spec.rb
|
100
107
|
- spec/spec_helper.rb
|
101
108
|
homepage: http://github.com/jjyr/hara
|
102
109
|
licenses:
|
103
110
|
- MIT
|
111
|
+
metadata: {}
|
104
112
|
post_install_message:
|
105
113
|
rdoc_options: []
|
106
114
|
require_paths:
|
107
115
|
- lib
|
108
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
117
|
requirements:
|
111
|
-
- -
|
118
|
+
- - '>='
|
112
119
|
- !ruby/object:Gem::Version
|
113
120
|
version: '0'
|
114
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
122
|
requirements:
|
117
|
-
- -
|
123
|
+
- - '>='
|
118
124
|
- !ruby/object:Gem::Version
|
119
125
|
version: '0'
|
120
126
|
requirements: []
|
121
127
|
rubyforge_project:
|
122
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.0.5
|
123
129
|
signing_key:
|
124
|
-
specification_version:
|
125
|
-
summary:
|
126
|
-
help you write applications easily.
|
130
|
+
specification_version: 4
|
131
|
+
summary: Hara build upon em-websocket, easy to use.
|
127
132
|
test_files:
|
128
133
|
- spec/app_spec.rb
|
134
|
+
- spec/filter_spec.rb
|
129
135
|
- spec/hara_spec.rb
|
130
136
|
- spec/spec_helper.rb
|
data/lib/hara/base.rb
DELETED
data/lib/hara/main.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'hara/base'
|
2
|
-
|
3
|
-
start_options = {host: 'localhost', port: 3210}
|
4
|
-
|
5
|
-
#like sinatra..
|
6
|
-
if ARGV.any?
|
7
|
-
require 'optparse'
|
8
|
-
OptionParser.new { |op|
|
9
|
-
op.on('-p port', "set the port (default is #{start_options[:port]})") { |val| start_options[:port] = val.to_i }
|
10
|
-
op.on('-o addr', "set the host (default is #{start_options[:host]})") { |val| srart_options[:host] = val }
|
11
|
-
op.on('-e env', 'set the environment (default is development)') { |val| Hara.env = val.to_sym }
|
12
|
-
}.parse!(ARGV.dup)
|
13
|
-
end
|
14
|
-
|
15
|
-
at_exit { Hara::Server.start(start_options[:host], start_options[:port]) if $!.nil? }
|