regal 0.3.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45ac2e7667747b949959086c13d4e1f9d8aafe68324c2c0124ad52ba34f7f99c
4
- data.tar.gz: f48537179e64376e9d616859883e9ce88f016f79f1b99ece62cd009ec265597c
3
+ metadata.gz: ef206f9aa897e6b16abeb2b835eed4a6ad20709f58fe4be98f7d6f2a43cc8511
4
+ data.tar.gz: 372d5656715377d810b81df4031465303b066762d8bd5d36947168e00ae61ab4
5
5
  SHA512:
6
- metadata.gz: 15d39814b9bc1b8f9b80e1a937c7b6dc5d9f26afd6d228d54dc4fa655e7043d87eeab8d5477d3cd711a7261172e06bba6f4ffb73ffecbfed4a06d2b3966184ff
7
- data.tar.gz: 1f16718c266cbac372fa03c1ad99843de49b75eb15123945194d62f056ac1a8d8749adba34d03d51eeaac216490717c433469ca223d2edd842845843900bb5fb
6
+ metadata.gz: 4cff885e626bd9e3041084832c7732f49e89eb8a54f688080ea74193eed68ef311f7a532e7e24b1b6a1594f59633caecd9898d94961b36fa842d07344b87a5c7
7
+ data.tar.gz: d44c0b141c83ae570703be9b23b1237c0e5bbcd8d8e3c2893dfe7c44d950e600c68c80ced1fa9f5f27c5bb294058bd3cbbe5aa8e88d227fa5982c0cde22d1a40
data/lib/regal/app.rb CHANGED
@@ -355,9 +355,9 @@ module Regal
355
355
  end
356
356
  response
357
357
  elsif matching_route
358
- METHOD_NOT_ALLOWED_RESPONSE
358
+ [405, {}, []]
359
359
  else
360
- NOT_FOUND_RESPONSE
360
+ [404, {}, []]
361
361
  end
362
362
  end
363
363
 
@@ -374,8 +374,6 @@ module Regal
374
374
 
375
375
  private
376
376
 
377
- METHOD_NOT_ALLOWED_RESPONSE = [405, {}.freeze, [].freeze].freeze
378
- NOT_FOUND_RESPONSE = [404, {}.freeze, [].freeze].freeze
379
377
  SLASH = '/'.freeze
380
378
  PATH_INFO_KEY = 'PATH_INFO'.freeze
381
379
  REQUEST_METHOD_KEY = 'REQUEST_METHOD'.freeze
@@ -20,7 +20,7 @@ module Regal
20
20
  # @private
21
21
  def initialize
22
22
  @status = 200
23
- @headers = {}
23
+ @headers = Rack::Headers.new
24
24
  @body = nil
25
25
  @raw_body = nil
26
26
  @finished = false
data/lib/regal/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Regal
2
2
  # @private
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
@@ -126,7 +126,7 @@ module Regal
126
126
 
127
127
  it 'can set response headers' do
128
128
  get '/redirect'
129
- expect(last_response.headers).to include('Location' => 'somewhere/else')
129
+ expect(last_response.headers).to include('location' => 'somewhere/else')
130
130
  end
131
131
  end
132
132
 
@@ -262,11 +262,11 @@ module Regal
262
262
 
263
263
  it 'does not call further handlers or before blocks when the response is marked as finished' do
264
264
  expect(last_response.body).to eq('Go somewhere else')
265
- expect(last_response.headers).to_not have_key('X-HandlerCalled')
265
+ expect(last_response.headers).to_not have_key('x-handlercalled')
266
266
  end
267
267
 
268
268
  it 'calls after blocks' do
269
- expect(last_response.headers).to include('WasAfterCalled' => 'yes')
269
+ expect(last_response.headers).to include('wasaftercalled' => 'yes')
270
270
  end
271
271
  end
272
272
 
@@ -882,28 +882,28 @@ module Regal
882
882
  it 'calls the route\'s parent scope\'s before blocks only' do
883
883
  get '/scoped/1'
884
884
  expect(last_response.status).to eq(200)
885
- expect(last_response.headers).to include('BeforeScope' => '1')
885
+ expect(last_response.headers).to include('beforescope' => '1')
886
886
  get '/scoped/2'
887
887
  expect(last_response.status).to eq(200)
888
- expect(last_response.headers).to include('BeforeScope' => '2', 'BeforeSubScope' => '2')
888
+ expect(last_response.headers).to include('beforescope' => '2', 'beforesubscope' => '2')
889
889
  end
890
890
 
891
891
  it 'calls the route\'s parent scope\'s after blocks only' do
892
892
  get '/scoped/1'
893
893
  expect(last_response.status).to eq(200)
894
- expect(last_response.headers).to include('AfterScope' => '1')
894
+ expect(last_response.headers).to include('afterscope' => '1')
895
895
  get '/scoped/2'
896
896
  expect(last_response.status).to eq(200)
897
- expect(last_response.headers).to include('AfterScope' => '2')
897
+ expect(last_response.headers).to include('afterscope' => '2')
898
898
  end
899
899
 
900
900
  it 'calls the common before and after blocks' do
901
901
  get '/scoped/1'
902
902
  expect(last_response.status).to eq(200)
903
- expect(last_response.headers).to include('CommonBefore' => 'yes', 'CommonAfter' => 'yes')
903
+ expect(last_response.headers).to include('commonbefore' => 'yes', 'commonafter' => 'yes')
904
904
  get '/scoped/2'
905
905
  expect(last_response.status).to eq(200)
906
- expect(last_response.headers).to include('CommonBefore' => 'yes', 'CommonAfter' => 'yes')
906
+ expect(last_response.headers).to include('commonbefore' => 'yes', 'commonafter' => 'yes')
907
907
  end
908
908
  end
909
909
 
@@ -1412,7 +1412,7 @@ module Regal
1412
1412
 
1413
1413
  it 'calls after blocks when errors are handled' do
1414
1414
  get '/handled'
1415
- expect(last_response.headers['WasAfterCalled']).to eq('yes')
1415
+ expect(last_response.headers['wasaftercalled']).to eq('yes')
1416
1416
  end
1417
1417
 
1418
1418
  it 'lets them bubble all the way up when there are no matching error handlers' do
@@ -1428,12 +1428,12 @@ module Regal
1428
1428
 
1429
1429
  it 'delegates them to matching error handlers at the same level, not below' do
1430
1430
  get '/handled/at-the-right-level/level-3/level-4'
1431
- expect(last_response.headers).to include('HandledAtLevel' => '3')
1431
+ expect(last_response.headers).to include('handledatlevel' => '3')
1432
1432
  end
1433
1433
 
1434
1434
  it 'calls after blocks when errors are handled' do
1435
1435
  get '/handled/from-before'
1436
- expect(last_response.headers['WasAfterCalled']).to eq('yes')
1436
+ expect(last_response.headers['wasaftercalled']).to eq('yes')
1437
1437
  end
1438
1438
 
1439
1439
  end
@@ -1446,8 +1446,8 @@ module Regal
1446
1446
 
1447
1447
  it 'calls the rest of the after blocks when errors are handled' do
1448
1448
  get '/handled/from-after'
1449
- expect(last_response.headers['NextAfterWasCalled']).to eq('yes')
1450
- expect(last_response.headers['WasAfterCalled']).to eq('yes')
1449
+ expect(last_response.headers['nextafterwascalled']).to eq('yes')
1450
+ expect(last_response.headers['wasaftercalled']).to eq('yes')
1451
1451
  end
1452
1452
  end
1453
1453
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rack
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.0'
18
+ version: '3.0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '2.0'
25
+ version: '3.0'
27
26
  description: ''
28
27
  email:
29
28
  - theo@iconara.net
@@ -46,7 +45,6 @@ homepage: http://github.com/iconara/regal
46
45
  licenses:
47
46
  - BSD-3-Clause
48
47
  metadata: {}
49
- post_install_message:
50
48
  rdoc_options: []
51
49
  require_paths:
52
50
  - lib
@@ -54,19 +52,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
52
  requirements:
55
53
  - - ">="
56
54
  - !ruby/object:Gem::Version
57
- version: 1.9.3
55
+ version: 2.4.0
58
56
  required_rubygems_version: !ruby/object:Gem::Requirement
59
57
  requirements:
60
58
  - - ">="
61
59
  - !ruby/object:Gem::Version
62
60
  version: '0'
63
61
  requirements: []
64
- rubygems_version: 3.0.1
65
- signing_key:
62
+ rubygems_version: 3.6.9
66
63
  specification_version: 4
67
64
  summary: ''
68
65
  test_files:
69
- - spec/spec_helper.rb
66
+ - spec/regal/app_spec.rb
70
67
  - spec/regal/request_spec.rb
71
68
  - spec/regal/response_spec.rb
72
- - spec/regal/app_spec.rb
69
+ - spec/spec_helper.rb