angelo 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/angelo.rb +1 -0
- data/lib/angelo/base.rb +7 -3
- data/lib/angelo/responder.rb +7 -0
- data/lib/angelo/version.rb +1 -1
- data/spec/angelo_spec.rb +10 -3
- 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: eace5c23e9adee9dcfd79505ca157123efe2a8d5
|
4
|
+
data.tar.gz: f53fe954693847bb50a5ea88c08904d3313e092b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1970b01b008eabd222cb8b5219ae6783707d5d801ac3b26971fd59f31b0d8683bb0810e48b900199227cfbbbdc95fbbf205b0804d8bb483e0c0491844fcd53b8
|
7
|
+
data.tar.gz: 10d4cec420a5d0e5a441189d996616b2753ee80d69c434aaba780e9bec1c823f8bba8f66b62d30a6df9c97764ab66b3a329a8054166cf275b8ac01f625ca98ce
|
data/CHANGELOG.md
CHANGED
data/lib/angelo.rb
CHANGED
data/lib/angelo/base.rb
CHANGED
@@ -5,7 +5,7 @@ module Angelo
|
|
5
5
|
include Celluloid::Logger
|
6
6
|
|
7
7
|
extend Forwardable
|
8
|
-
def_delegators :@responder, :content_type, :headers, :request
|
8
|
+
def_delegators :@responder, :content_type, :headers, :redirect, :request
|
9
9
|
|
10
10
|
@@addr = DEFAULT_ADDR
|
11
11
|
@@port = DEFAULT_PORT
|
@@ -134,7 +134,7 @@ module Angelo
|
|
134
134
|
|
135
135
|
async :ping_websockets do
|
136
136
|
every(@@ping_time) do
|
137
|
-
websockets.each do |ws|
|
137
|
+
websockets.all.each do |ws|
|
138
138
|
ws.socket << ::WebSocket::Message.ping.to_data
|
139
139
|
end
|
140
140
|
end
|
@@ -145,6 +145,7 @@ module Angelo
|
|
145
145
|
|
146
146
|
@@peeraddrs = {}
|
147
147
|
@@socket_context = {}
|
148
|
+
@@websockets = {}
|
148
149
|
|
149
150
|
def initialize server, context = nil
|
150
151
|
@context, @server = context, server
|
@@ -181,10 +182,13 @@ module Angelo
|
|
181
182
|
|
182
183
|
def [] context
|
183
184
|
raise ArgumentError.new "symbol required" unless Symbol === context
|
184
|
-
@@websockets ||= {}
|
185
185
|
@@websockets[context] ||= self.class.new @server, context
|
186
186
|
end
|
187
187
|
|
188
|
+
def all
|
189
|
+
a = self + @@websockets.values.flatten
|
190
|
+
end
|
191
|
+
|
188
192
|
end
|
189
193
|
|
190
194
|
end
|
data/lib/angelo/responder.rb
CHANGED
@@ -128,6 +128,13 @@ module Angelo
|
|
128
128
|
handle_error e, :internal_server_error, false
|
129
129
|
end
|
130
130
|
|
131
|
+
def redirect url
|
132
|
+
Angelo.log @connection, @request, nil, :moved_permanently, 0
|
133
|
+
@connection.respond :moved_permanently, headers(LOCATION_HEADER_KEY => url), ''
|
134
|
+
rescue => e
|
135
|
+
handle_error e, :internal_server_error, false
|
136
|
+
end
|
137
|
+
|
131
138
|
end
|
132
139
|
|
133
140
|
end
|
data/lib/angelo/version.rb
CHANGED
data/spec/angelo_spec.rb
CHANGED
@@ -26,6 +26,10 @@ describe Angelo::Base do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
get '/redirect' do
|
30
|
+
redirect '/'
|
31
|
+
end
|
32
|
+
|
29
33
|
end
|
30
34
|
|
31
35
|
it 'responds to http requests properly' do
|
@@ -45,6 +49,12 @@ describe Angelo::Base do
|
|
45
49
|
last_response_should_be_json obj
|
46
50
|
end
|
47
51
|
|
52
|
+
it 'redirects' do
|
53
|
+
get '/redirect'
|
54
|
+
expect(last_response.status).to eq(301)
|
55
|
+
expect(last_response.headers['Location']).to eq('/')
|
56
|
+
end
|
57
|
+
|
48
58
|
end
|
49
59
|
|
50
60
|
describe 'before filter' do
|
@@ -305,7 +315,4 @@ describe Angelo::Base do
|
|
305
315
|
|
306
316
|
end
|
307
317
|
|
308
|
-
describe 'websockets helper' do
|
309
|
-
end
|
310
|
-
|
311
318
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angelo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reel
|