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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b034c03ba6c0b50e1d31e5ee1c0bd043b70d8d2e
4
- data.tar.gz: b4e9ba5af2b009a7fa292f97d6a8b2a3831ec709
3
+ metadata.gz: eace5c23e9adee9dcfd79505ca157123efe2a8d5
4
+ data.tar.gz: f53fe954693847bb50a5ea88c08904d3313e092b
5
5
  SHA512:
6
- metadata.gz: 64b482cc286556b98b03f211134bed314d2c3b3564640aca4b9d2882d4b31d157760d7ef476d7fcb257d3065152f38c4573a24226d3de19f1309136c9a3f8730
7
- data.tar.gz: 000d06333538e664c71d40e6f0371d6d946c586efe2f1cb3dd42c08d510cb459faa772cacef57c3135315609f85387c70bc147cd0a26f16e8cb0eb8c62e1c632
6
+ metadata.gz: 1970b01b008eabd222cb8b5219ae6783707d5d801ac3b26971fd59f31b0d8683bb0810e48b900199227cfbbbdc95fbbf205b0804d8bb483e0c0491844fcd53b8
7
+ data.tar.gz: 10d4cec420a5d0e5a441189d996616b2753ee80d69c434aaba780e9bec1c823f8bba8f66b62d30a6df9c97764ab66b3a329a8054166cf275b8ac01f625ca98ce
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  changelog
2
2
  =========
3
3
 
4
+ ### 0.1.5 31 mar 2014
5
+
6
+ * add WebsocketsArray#all
7
+ * fix websockets pinging to ping all connected sockets
8
+ * add Responder#redirect
9
+
4
10
  ### 0.1.4 26 mar 2014
5
11
 
6
12
  * add Base.async, Base.on_pong, and Base#async
data/lib/angelo.rb CHANGED
@@ -24,6 +24,7 @@ module Angelo
24
24
  DEFAULT_CONTENT_DISPOSITION = 'attachment'
25
25
  ETAG_HEADER_KEY = 'ETag'
26
26
  IF_NONE_MATCH_HEADER_KEY = 'If-None-Match'
27
+ LOCATION_HEADER_KEY = 'Location'
27
28
 
28
29
  HTML_TYPE = 'text/html'
29
30
  JSON_TYPE = 'application/json'
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Angelo
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
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
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-26 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel