angelo 0.5.0 → 0.5.1

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: 29657358947009a8401893f8db01b0c3522706ed
4
- data.tar.gz: 721f0e9ef56f280f761518a620aa2a7ef562ae57
3
+ metadata.gz: d83f66477be36fa5bdc6978464fe7e83570abdb0
4
+ data.tar.gz: 485caaa3bee9162a898ae98fba958ba71340fd82
5
5
  SHA512:
6
- metadata.gz: 6519c472ea84aa9098fd2bb186323a21b7c216d7e3b6e4927666b77f0226bb57c379159784a38d83305cf64908defb2d9c3ebcfb0d126c59916ec35c00ea5069
7
- data.tar.gz: 110fffc25ad3e75c459aa0a484f52b2c73b8b9a318b5c8c904ec45135abfdd5aca658219910a0d993c6befe1493e9286e76b895528eeadd0fe79eeb74be58c30
6
+ metadata.gz: 2fa7bd072ee33247abe3c7057bb0228d0299179fa1bb936c50f48d07929ef5824e80e7701e15f742d7d56307dd5303a5aa885c49ba6c31de38a61056e1df9015
7
+ data.tar.gz: 486387e0ce869192c93e2b0181598229c043d8a210f469fd399731015d11e541f76b61aff0e27a86cd4b51b9dbb36c330d1d7fcac0d73fb2ff9ccf39a8ccb8cf
@@ -1,6 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - "2.2.4"
5
- - "2.3.0"
6
- script: rake
4
+ - "2.2.8"
5
+ - "2.3.5"
6
+ - "2.4.2"
7
+ script: bundle exec rake
@@ -1,6 +1,14 @@
1
1
  changelog
2
2
  =========
3
3
 
4
+ ### 0.5.1 nov 2017
5
+
6
+ thanks: @Mask, @tommay, @tenyo
7
+
8
+ * dumps backtraces to configured logger (#66)
9
+ * use Forwardable/def_delegators on main's eigenclass instead of instance (#67, #68)
10
+ * add support for PATCH routes (#79)
11
+
4
12
  ### 0.5.0 mar 2016
5
13
 
6
14
  thanks: @tommay, @gunnarmarten, @nagius
@@ -28,7 +36,7 @@ thanks: @tommay, @kyledrake, @katjaeinsfeld
28
36
  * refactor UnboundMethod -> instance_exec (#38)
29
37
  * add angelo/main for sinatra-like top-level DSL (#37)
30
38
  * make SymHash.new recurse array values
31
- * remove 'layouts_' from view_dir/layouts/*
39
+ * remove 'layouts\_' from view_dir/layouts/\*
32
40
  * return anything that respond_to? :to_json when content_type :json
33
41
  * remove event restriction to SSE stash contexts
34
42
  * add reload_templates! DSL method
data/Gemfile CHANGED
@@ -1,12 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'reel', '~>0.6.1'
4
3
  gemspec
5
4
 
6
- group :development do
7
- gem 'pry', '~>0.10'
8
- end
9
-
10
5
  group :profile do
11
6
  platform :mri do
12
7
  gem 'ruby-prof', '~>0.15'
@@ -14,9 +9,6 @@ group :profile do
14
9
  end
15
10
 
16
11
  group :test do
17
- gem 'httpclient', '~>2.5'
18
- gem 'minitest', '~>5.4'
19
-
20
12
  platform :mri do
21
13
  gem 'simplecov', '~>0.11'
22
14
  end
@@ -4,7 +4,8 @@ require File.expand_path('../lib/angelo/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Kenichi Nakamura"]
6
6
  gem.email = ["kenichi.nakamura@gmail.com"]
7
- gem.description = gem.summary = "A Sinatra-like DSL for Reel"
7
+ gem.summary = "A Sinatra-like DSL for Reel"
8
+ gem.description = "A Sinatra-like DSL for Reel that supports websockets and SSE"
8
9
  gem.homepage = "https://github.com/kenichi/angelo"
9
10
  gem.files = `git ls-files | grep -Ev '^example'`.split("\n")
10
11
  gem.test_files = `git ls-files -- spec/*`.split("\n")
@@ -12,9 +13,16 @@ Gem::Specification.new do |gem|
12
13
  gem.require_paths = ["lib"]
13
14
  gem.version = Angelo::VERSION
14
15
  gem.license = 'apache'
16
+
15
17
  gem.required_ruby_version = '>= 2.1.0'
16
- gem.add_runtime_dependency 'reel', '~>0.6.1'
18
+
19
+ gem.add_runtime_dependency 'reel', '>= 0.6.1'
17
20
  gem.add_runtime_dependency 'tilt', '~>2.0'
18
21
  gem.add_runtime_dependency 'mustermann', '~>0.4'
19
- gem.add_runtime_dependency 'mime-types', '~>2.4'
22
+ gem.add_runtime_dependency 'mime-types', '~>3.1'
23
+
24
+ gem.add_development_dependency 'rake', '~>12.0'
25
+ gem.add_development_dependency 'pry', '~>0.10'
26
+ gem.add_development_dependency 'httpclient', '~>2.5'
27
+ gem.add_development_dependency 'minitest', '~>5.4'
20
28
  end
@@ -11,14 +11,15 @@ require 'mustermann'
11
11
  module Angelo
12
12
 
13
13
  GET = 'GET'
14
+ PATCH = 'PATCH'
14
15
  POST = 'POST'
15
16
  PUT = 'PUT'
16
17
  DELETE = 'DELETE'
17
18
  OPTIONS = 'OPTIONS'
18
19
 
19
- HTTPABLE = [:get, :post, :put, :delete, :options]
20
+ HTTPABLE = [:get, :patch, :post, :put, :delete, :options]
20
21
  STATICABLE = [:get, :head]
21
- POST_OVERRIDABLE = [:put, :delete]
22
+ POST_OVERRIDABLE = [:patch, :put, :delete]
22
23
 
23
24
  ACCEPT_REQUEST_HEADER_KEY = 'Accept'
24
25
 
@@ -242,7 +242,7 @@ module Angelo
242
242
  @params ||= case request.method
243
243
  when GET, DELETE, OPTIONS
244
244
  parse_query_string
245
- when POST, PUT
245
+ when PATCH, POST, PUT
246
246
  parse_query_string_and_post_body
247
247
  end.merge mustermann.params(request.path)
248
248
  end
@@ -31,10 +31,13 @@ end
31
31
  if self.to_s == "main"
32
32
  # We are probably at the top level.
33
33
 
34
- require "forwardable"
35
- self.extend Forwardable
36
34
  @angelo_app = Class.new(Angelo::Base)
37
- self.def_delegators :@angelo_app, *Angelo::Base::DSL.instance_methods
35
+
36
+ class << self
37
+ require "forwardable"
38
+ extend Forwardable
39
+ def_delegators :@angelo_app, *Angelo::Base::DSL.instance_methods
40
+ end
38
41
 
39
42
  at_exit do
40
43
  # Don't run @angelo_app on uncaught exceptions including exit
@@ -65,7 +65,7 @@ module Angelo
65
65
  end
66
66
  private :http_req
67
67
 
68
- [:get, :post, :put, :delete, :options, :head].each do |m|
68
+ [:get, :patch, :post, :put, :delete, :options, :head].each do |m|
69
69
  define_method m do |path, params = {}, headers = {}, &block|
70
70
  hc_req m, path, params, headers, &block
71
71
  end
@@ -73,10 +73,7 @@ module Angelo
73
73
  Angelo.log @method, @connection, @request, nil, type, err_msg.size
74
74
  @connection.respond type, headers, err_msg
75
75
  @connection.close
76
- if report
77
- error "#{_error.class} - #{_error.message}"
78
- ::STDERR.puts _error.backtrace
79
- end
76
+ error _error if report
80
77
  end
81
78
 
82
79
  def error_message _error
@@ -1,3 +1,3 @@
1
1
  module Angelo
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  # Having to require this sucks because tilt is an implementation
2
2
  # detail we shouldn't have to know about. But this avoids a "tilt
3
- # autoloading 'tilt/erb' in a non thread-safe way" wanring.
3
+ # autoloading 'tilt/erb' in a non thread-safe way" warning.
4
4
  #
5
5
  require 'tilt/erb'
6
6
 
@@ -12,7 +12,7 @@ describe Angelo::Base do
12
12
  @set_by_before = params
13
13
  end
14
14
 
15
- [:get, :post, :put].each do |m|
15
+ [:get, :patch, :post, :put].each do |m|
16
16
  __send__ m, '/before' do
17
17
  content_type :json
18
18
  @set_by_before
@@ -26,7 +26,7 @@ describe Angelo::Base do
26
26
  get '/before', obj
27
27
  last_response_must_be_json obj_s
28
28
 
29
- [:post, :put].each do |m|
29
+ [:patch, :post, :put].each do |m|
30
30
  __send__ m, '/before', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
31
31
  last_response_must_be_json obj
32
32
  end
@@ -51,7 +51,7 @@ describe Angelo::Base do
51
51
  @bat = params[:bat] if @bar
52
52
  end
53
53
 
54
- [:get, :post, :put].each do |m|
54
+ [:get, :patch, :post, :put].each do |m|
55
55
  __send__ m, '/before' do
56
56
  content_type :json
57
57
  { foo: @foo, bar: @bar, bat: @bat }
@@ -65,7 +65,7 @@ describe Angelo::Base do
65
65
  get '/before', obj
66
66
  last_response_must_be_json obj_s
67
67
 
68
- [:post, :put].each do |m|
68
+ [:patch, :post, :put].each do |m|
69
69
  __send__ m, '/before', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
70
70
  last_response_must_be_json obj
71
71
  end
@@ -94,7 +94,7 @@ describe Angelo::Base do
94
94
  @id = params[:id].to_i
95
95
  end
96
96
 
97
- [:get, :post, :put].each do |m|
97
+ [:get, :patch, :post, :put].each do |m|
98
98
 
99
99
  __send__ m, '/before' do
100
100
  content_type :json
@@ -124,7 +124,7 @@ describe Angelo::Base do
124
124
  get '/before', obj
125
125
  last_response_must_be_json obj_s.select {|k,v| k == 'foo'}
126
126
 
127
- [:post, :put].each do |m|
127
+ [:patch, :post, :put].each do |m|
128
128
  __send__ m, '/before', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
129
129
  last_response_must_be_json obj.select {|k,v| k == 'foo'}
130
130
  end
@@ -136,7 +136,7 @@ describe Angelo::Base do
136
136
  get '/before_bar', obj
137
137
  last_response_must_be_json obj_s.select {|k,v| ['foo','bar'].include? k}
138
138
 
139
- [:post, :put].each do |m|
139
+ [:patch, :post, :put].each do |m|
140
140
  __send__ m, '/before_bar', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
141
141
  last_response_must_be_json obj.select {|k,v| ['foo','bar'].include? k}
142
142
  end
@@ -144,7 +144,7 @@ describe Angelo::Base do
144
144
  get '/before_bat', obj
145
145
  last_response_must_be_json obj_s.select {|k,v| ['foo','bat'].include? k}
146
146
 
147
- [:post, :put].each do |m|
147
+ [:patch, :post, :put].each do |m|
148
148
  __send__ m, '/before_bat', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
149
149
  last_response_must_be_json obj.select {|k,v| ['foo','bat'].include? k}
150
150
  end
@@ -152,7 +152,7 @@ describe Angelo::Base do
152
152
  end
153
153
 
154
154
  it 'matches regexes' do
155
- [:get, :post, :put].each do |m|
155
+ [:get, :patch, :post, :put].each do |m|
156
156
  id = rand 1000
157
157
  __send__ m, "/before/#{id}"
158
158
  last_response_must_be_json({'id' => id})
@@ -188,8 +188,8 @@ describe Angelo::Base do
188
188
  end
189
189
 
190
190
  it 'runs after filters after routes' do
191
- a = %w[2 6 14 30 62]
192
- b = [4, 12, 28, 60, 124]
191
+ a = %w[2 6 14 30 62 126]
192
+ b = [4, 12, 28, 60, 124, 252]
193
193
 
194
194
  Angelo::HTTPABLE.each_with_index do |m,i|
195
195
  __send__ m, '/after', obj
@@ -227,8 +227,8 @@ describe Angelo::Base do
227
227
  end
228
228
 
229
229
  it 'runs after filters in order' do
230
- a = %w[0 2 6 14 30]
231
- b = [2, 6, 14, 30, 62]
230
+ a = %w[0 2 6 14 30 62]
231
+ b = [2, 6, 14, 30, 62, 126]
232
232
 
233
233
  Angelo::HTTPABLE.each_with_index do |m,i|
234
234
  __send__ m, '/after', obj
@@ -275,8 +275,8 @@ describe Angelo::Base do
275
275
 
276
276
  it 'runs default and specific after filters' do
277
277
 
278
- a = %w[0 2 4 6 8]
279
- b = [2, 4, 6, 8, 10]
278
+ a = %w[0 2 4 6 8 10]
279
+ b = [2, 4, 6, 8, 10, 12]
280
280
 
281
281
  Angelo::HTTPABLE.each_with_index do |m,i|
282
282
  __send__ m, '/after', obj
@@ -284,8 +284,9 @@ describe Angelo::Base do
284
284
  invoked.must_equal b[i]
285
285
  end
286
286
 
287
- c = %w[10 24 52 108 220]
288
- d = [24, 52, 108, 220, 444]
287
+ c = %w[12 28 60 124 252 508]
288
+ d = [28, 60, 124, 252, 508, 1020]
289
+
289
290
 
290
291
  Angelo::HTTPABLE.each_with_index do |m,i|
291
292
  __send__ m, '/after_bar', obj
@@ -293,8 +294,8 @@ describe Angelo::Base do
293
294
  invoked.must_equal d[i]
294
295
  end
295
296
 
296
- e = %w[444 442 440 438 436]
297
- f = [442, 440, 438, 436, 434]
297
+ e = %w[1020 1018 1016 1014 1012 1010]
298
+ f = [1018, 1016, 1014, 1012, 1010, 1008]
298
299
 
299
300
  Angelo::HTTPABLE.each_with_index do |m,i|
300
301
  __send__ m, '/after_bat', obj
@@ -16,7 +16,7 @@ if RUBY_VERSION =~ /^2\.(\d)/ and $1.to_i > 0 and RUBY_PLATFORM != 'java'
16
16
  params
17
17
  end
18
18
 
19
- [:post, :put].each do |m|
19
+ [:patch, :post, :put].each do |m|
20
20
  __send__ m, pattern do
21
21
  params
22
22
  end
@@ -39,7 +39,7 @@ if RUBY_VERSION =~ /^2\.(\d)/ and $1.to_i > 0 and RUBY_PLATFORM != 'java'
39
39
  it 'overrides post body params' do
40
40
  path = '/some/things/are_good'
41
41
  headers = {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
42
- [:post, :put].each do |m|
42
+ [:patch, :post, :put].each do |m|
43
43
  __send__ m, path, {foo: 'other', bar: 'are_bad'}.to_json, headers
44
44
  last_response_must_be_json mm_pattern.params(path)
45
45
  end
@@ -101,7 +101,7 @@ HTML
101
101
 
102
102
  content_type :json
103
103
 
104
- [:get, :post, :put].each do |m|
104
+ [:get, :patch, :post, :put].each do |m|
105
105
  __send__ m, '/before/:bar' do
106
106
  { bar: params[:bar], foo: params[:foo], foo_from_before: @foo }
107
107
  end
@@ -110,7 +110,7 @@ HTML
110
110
  end
111
111
 
112
112
  it 'does not infect route block params with filter pattern params' do
113
- [:get, :post, :put].each do |m|
113
+ [:get, :patch, :post, :put].each do |m|
114
114
  __send__ m, '/before/hi'
115
115
  last_response_must_be_json 'bar' => 'hi', 'foo' => nil, 'foo_from_before' => 'hi'
116
116
  end
@@ -131,7 +131,7 @@ HTML
131
131
  @bat = params[:bat] if @foo
132
132
  end
133
133
 
134
- [:get, :post, :put].each do |m|
134
+ [:get, :patch, :post, :put].each do |m|
135
135
 
136
136
  __send__ m, '/before' do
137
137
  content_type :json
@@ -156,7 +156,7 @@ HTML
156
156
  get '/before_bar', obj
157
157
  last_response_must_be_json obj_s
158
158
 
159
- [:post, :put].each do |m|
159
+ [:patch, :post, :put].each do |m|
160
160
  __send__ m, '/before_bar', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
161
161
  last_response_must_be_json obj
162
162
  end
@@ -164,7 +164,7 @@ HTML
164
164
  get '/before_bat', obj
165
165
  last_response_must_be_json obj_s
166
166
 
167
- [:post, :put].each do |m|
167
+ [:patch, :post, :put].each do |m|
168
168
  __send__ m, '/before_bat', obj.to_json, {Angelo::CONTENT_TYPE_HEADER_KEY => Angelo::JSON_TYPE}
169
169
  last_response_must_be_json obj
170
170
  end
@@ -32,6 +32,9 @@ describe Angelo::Base do
32
32
  nil
33
33
  end
34
34
 
35
+ get '/responder_test' do
36
+ end
37
+
35
38
  end
36
39
 
37
40
  it 'responds to http requests properly' do
@@ -94,7 +97,7 @@ describe Angelo::Base do
94
97
  end
95
98
 
96
99
  it 'does not crash when receiving unknown http request type' do
97
- r = HTTP.patch(url('/'))
100
+ r = HTTP.trace(url('/'))
98
101
  assert @server.alive?
99
102
  r.status.must_equal 404
100
103
  end
@@ -108,6 +111,10 @@ describe Angelo::Base do
108
111
  r.must_match /400 Bad Request/
109
112
  end
110
113
 
114
+ it 'does not append responders to on_close array if on_close is not set' do
115
+ get '/responder_test', Angelo::SSE_HEADER
116
+ end
117
+
111
118
  end
112
119
 
113
120
  describe 'headers helper' do
@@ -350,7 +357,7 @@ describe Angelo::Base do
350
357
  last_response_must_be_json({})
351
358
  end
352
359
 
353
- (Angelo::HTTPABLE - [:post, :put]).each do |m|
360
+ (Angelo::HTTPABLE - [:patch, :post, :put]).each do |m|
354
361
  it "returns a populated hash for #{m.to_s.upcase} requests" do
355
362
  send m, '/json?foo=bar'
356
363
  last_response_must_be_json('foo' => 'bar')
@@ -7,6 +7,8 @@ if RUBY_ENGINE == "ruby" && ENV['TRAVIS'] != 'true'
7
7
  SimpleCov.command_name 'minitest'
8
8
  end
9
9
 
10
+ $VERBOSE=nil # disable warnings turned on by default in rake 11.x
11
+
10
12
  require 'bundler'
11
13
  require 'celluloid/current'
12
14
  Bundler.require :default, :development, :test
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angelo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.6.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.6.1
27
27
  - !ruby/object:Gem::Dependency
@@ -58,15 +58,71 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.4'
61
+ version: '3.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.4'
69
- description: A Sinatra-like DSL for Reel
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '12.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '12.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httpclient
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '5.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '5.4'
125
+ description: A Sinatra-like DSL for Reel that supports websockets and SSE
70
126
  email:
71
127
  - kenichi.nakamura@gmail.com
72
128
  executables: []
@@ -140,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
196
  version: '0'
141
197
  requirements: []
142
198
  rubyforge_project:
143
- rubygems_version: 2.5.1
199
+ rubygems_version: 2.6.12
144
200
  signing_key:
145
201
  specification_version: 4
146
202
  summary: A Sinatra-like DSL for Reel