angelo 0.3.2 → 0.3.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: 6f5dba260998174e061615d20082882201023653
4
- data.tar.gz: 95f76832e3a797bc886e93a822ee541640f18df7
3
+ metadata.gz: bfff4ac5299ee639afca3b56bc130f71b36940fb
4
+ data.tar.gz: bae829642aefa5762ff1f1b612d5bf7cfd707d99
5
5
  SHA512:
6
- metadata.gz: 1cda696fa0204160276711d8927393d680b28149af53d564421a227768e57601e30f6d9e70876c1fb805ffc96df534785965ccee4fa9c825db751ee6af390e0d
7
- data.tar.gz: 1d062a3d517d8c3a463ca339f8344c6b4b501a89d187a201f6ccb6fd243f8559d236605254ec2baae190b62adef5fb9df069dab71eb7f90988d6d3077146643b
6
+ metadata.gz: 100f313a038eb3dd61f1a87542f9339158c7e0e7b8e4f179c01f7ef83b08a7860f1c49db9ce01a7ba14d1765540d556f98c6f4994cb44a6535a3567a0f5e5da9
7
+ data.tar.gz: 29708a62189bb0ee987e84d34d2b31c19a56f710ab7147c304f7575a5a59d1a9b20ce4edb0b3d8b0ac96818a5886ab2de29fd041a3d567777127eb536e2fd243
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - "1.9.3"
@@ -5,4 +6,8 @@ rvm:
5
6
  - "2.1.2"
6
7
  - "2.1.3"
7
8
  - "2.1.5"
9
+ - "rbx-2"
8
10
  script: rake
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: rbx-2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  changelog
2
2
  =========
3
3
 
4
+ ### 0.3.3 16 jan 2015
5
+
6
+ thanks: @mighe, @tarcieri, @jc00ke, @gunnarmarten, @tommay
7
+
8
+ * RuntimeError if Angelo::Tilt::ERB is included and Tilt is < 2.0
9
+ * add deprecation warning - plan for Tilt inclusion by default
10
+ * fix/simplify routing hash (#27)
11
+ * Base.run, Base.run! now accept an options hash to pass to Reel (#26)
12
+ * update tests for 2.2.0 URI.parse (https://bugs.ruby-lang.org/issues/10669)
13
+ * `public_dir` accessor forwarded from base now
14
+ * `redirect` returns nil
15
+ * travis tests against rbx (#23)
16
+
4
17
  ### 0.3.2 27 nov 2014 ¡gracias!
5
18
 
6
19
  thanks: @mighe, @artworx
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gem 'tilt', '~>2.0'
5
5
  gem 'mime-types', '~>2.4'
6
6
  gem 'websocket-driver', '~>0.3'
7
7
 
8
- platform :ruby_21 do
8
+ platform :ruby_21, :ruby_22 do
9
9
  gem 'mustermann', '~>0.4'
10
10
  end
11
11
 
data/README.md CHANGED
@@ -93,7 +93,7 @@ class Foo < Angelo::Base
93
93
 
94
94
  end
95
95
 
96
- Foo.run
96
+ Foo.run!
97
97
  ```
98
98
 
99
99
  In this case, any clients that connected to a websocket at the path '/' would be stashed in the
data/lib/angelo.rb CHANGED
@@ -14,7 +14,6 @@ module Angelo
14
14
  DELETE = 'DELETE'
15
15
  OPTIONS = 'OPTIONS'
16
16
 
17
- ROUTABLE = [:get, :post, :put, :delete, :options, :websocket]
18
17
  HTTPABLE = [:get, :post, :put, :delete, :options]
19
18
  STATICABLE = [:get, :head]
20
19
 
@@ -59,6 +58,9 @@ module Angelo
59
58
  DASH = '-'
60
59
  EMPTY_STRING = ''
61
60
  NEWLINE = "\n"
61
+ SEMICOLON = ';'
62
+ EQUALS = '='
63
+ AMPERSAND = '&'
62
64
 
63
65
  HALT_STRUCT = Struct.new :status, :body
64
66
 
data/lib/angelo/base.rb CHANGED
@@ -6,7 +6,7 @@ module Angelo
6
6
 
7
7
  extend Forwardable
8
8
  def_delegators :@responder, :content_type, :headers, :redirect, :request, :transfer_encoding
9
- def_delegators :@klass, :report_errors?, :sse_event, :sse_message, :sses, :websockets
9
+ def_delegators :@klass, :public_dir, :report_errors?, :sse_event, :sse_message, :sses, :websockets
10
10
 
11
11
  attr_accessor :responder
12
12
 
@@ -88,11 +88,7 @@ module Angelo
88
88
  end
89
89
 
90
90
  def routes
91
- @routes ||= {}
92
- ROUTABLE.each do |m|
93
- @routes[m] ||= {}
94
- end
95
- @routes
91
+ @routes ||= Hash.new{|h,k| h[k] = {}}
96
92
  end
97
93
 
98
94
  def filters
@@ -164,13 +160,13 @@ module Angelo
164
160
  Responder.content_type type
165
161
  end
166
162
 
167
- def run! _addr = addr, _port = port
168
- run _addr, _port, true
163
+ def run! _addr = addr, _port = port, options = {}
164
+ run _addr, _port, options, true
169
165
  end
170
166
 
171
- def run _addr = addr, _port = port, blocking = false
167
+ def run _addr = addr, _port = port, options = {}, blocking = false
172
168
  Celluloid.logger.level = log_level
173
- @server = Angelo::Server.new self, _addr, _port
169
+ @server = Angelo::Server.new self, _addr, _port, options
174
170
  @server.async.ping_websockets
175
171
  if blocking
176
172
  trap "INT" do
@@ -39,11 +39,7 @@ module Angelo
39
39
  end
40
40
 
41
41
  def routes
42
- @routes ||= {}
43
- ROUTABLE.each do |m|
44
- @routes[m] ||= RouteMap.new
45
- end
46
- @routes
42
+ @routes ||= Hash.new{|h,k| h[k] = RouteMap.new}
47
43
  end
48
44
 
49
45
  def filter_by which, path, meth
@@ -7,9 +7,6 @@ module Angelo
7
7
  module ParamsParser
8
8
 
9
9
  EMPTY_JSON = '{}'
10
- SEMICOLON = ';'
11
- EQUALS = '='
12
- AMPERSAND = '&'
13
10
 
14
11
  def parse_formencoded str
15
12
  str.split(AMPERSAND).reduce(Responder.symhash) do |p, kv|
@@ -20,7 +17,7 @@ module Angelo
20
17
  end
21
18
 
22
19
  def parse_query_string
23
- parse_formencoded(request.query_string || '')
20
+ parse_formencoded(request.query_string || EMPTY_STRING)
24
21
  end
25
22
 
26
23
  def parse_post_body
@@ -199,6 +199,7 @@ module Angelo
199
199
 
200
200
  def redirect url
201
201
  @redirect = url
202
+ nil
202
203
  end
203
204
 
204
205
  def on_close= on_close
data/lib/angelo/server.rb CHANGED
@@ -11,13 +11,13 @@ module Angelo
11
11
 
12
12
  attr_reader :base
13
13
 
14
- def initialize base, addr = nil, port = nil
14
+ def initialize base, addr = nil, port = nil, options = {}
15
15
  @base = base
16
16
  addr ||= @base.addr
17
17
  port ||= @base.port
18
18
  info "Angelo #{VERSION}"
19
19
  info "listening on #{addr}:#{port}"
20
- super addr, port, &method(:on_connection)
20
+ super addr, port, options, &method(:on_connection)
21
21
  end
22
22
 
23
23
  def on_connection connection
@@ -56,7 +56,7 @@ module Angelo
56
56
  end
57
57
 
58
58
  def route! meth, connection, request
59
- if @base.routes[meth] and rs = @base.routes[meth][request.path]
59
+ if rs = @base.routes[meth][request.path]
60
60
  responder = rs.dup
61
61
  responder.reset!
62
62
  responder.base = @base.new responder
@@ -13,6 +13,11 @@ module Angelo
13
13
  # hrm, sneaky
14
14
  #
15
15
  def self.included base
16
+
17
+ # TODO: remove at 0.4
18
+ warn "[DEPRECATED] Angelo::Tilt::ERB will be included by default in angelo >= 0.4"
19
+ raise "Angelo requires Tilt >= 2.0, you have #{::Tilt::VERSION}" unless ::Tilt::VERSION.to_i >= 2
20
+
16
21
  base.extend ClassMethods
17
22
  end
18
23
 
@@ -1,3 +1,3 @@
1
1
  module Angelo
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
data/test/angelo_spec.rb CHANGED
@@ -91,7 +91,7 @@ describe Angelo::Base do
91
91
 
92
92
  it 'does not crash when receiving invalid uri' do
93
93
  s = TCPSocket.new Angelo::DEFAULT_ADDR, Angelo::DEFAULT_PORT
94
- s.write 'GET /?file=<SCRIPT>window.alert</SCRIPT>' + "\n\n"
94
+ s.write 'GET /?file=<SCRIPT>window.alert&*(#%)(^&*</SCRIPT>' + "\n\n"
95
95
  r = s.read
96
96
  s.close
97
97
  assert @server.alive?
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.3.2
4
+ version: 0.3.3
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-11-27 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.4.4
110
+ rubygems_version: 2.4.5
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A Sinatra-esque DSL for Reel