apill 1.5.0 → 1.6.0

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: 1a7c0fbca0496aeea124a822878e016588313ce7
4
- data.tar.gz: cec678014649e2cecab809f08b796aed030b4fce
3
+ metadata.gz: c6e916c78acf4e6b77bba21330da5ec51c64dc14
4
+ data.tar.gz: 5a52f7ab6a1ab045168db125dccf391fbde97e5b
5
5
  SHA512:
6
- metadata.gz: 43de00df6f81a48bc49d0eaf567b0d2b6cd0987231bed6a66df0f8ae81fc9625a35b1a5edfbc5238858adc95537d4e682a9811b2405dc57c5733bb4464fd987c
7
- data.tar.gz: f376b8f1f76281cce87392cfd45abeac90c266fbea707b1a70d44b4cdf07bc93ed7fb60de5e061fd3c6679d16c84c66cd40309cdcee0fcdfde8c0340b1afc6c7
6
+ metadata.gz: bbf3a7730599ec3d42223988e7e9732532dd72bde970aff017345c1cb4a3b959c7b7ae441f6b14795cac269fe944d9fbdfd92c2567e2f81ae76383bb523406dd
7
+ data.tar.gz: 882474601d4956b23b8aa815cc2ca91318639de79d26614e94694902db5c119332dfdfafa7b6ddf48ead4dab0a87a657320f0b4fca8d5766a720b39e92a7c07c
@@ -20,19 +20,21 @@ module GenericMatcher
20
20
  private
21
21
 
22
22
  def get_accept_header(raw_header_from_headers:, raw_header_from_params:)
23
- return accept_header_from_header if accept_header_from_header(raw_header_from_headers).valid? || raw_header_from_params.nil?
23
+ header_from_header = accept_header_from_header(raw_header_from_headers)
24
24
 
25
- accept_header_from_params(raw_header_from_params)
25
+ return header_from_header if header_from_header.valid? || raw_header_from_params.nil?
26
+
27
+ accept_header_from_header(raw_header_from_params)
26
28
  end
27
29
 
28
30
  def accept_header_from_header(raw_header_from_headers='')
29
- @accept_header_from_header ||= Apill::AcceptHeader.new(application: application,
30
- header: raw_header_from_headers)
31
+ Apill::AcceptHeader.new(application: application,
32
+ header: raw_header_from_headers)
31
33
  end
32
34
 
33
35
  def accept_header_from_params(raw_header_from_params='')
34
- @accept_header_from_params ||= Apill::AcceptHeader.new(application: application,
35
- header: raw_header_from_params)
36
+ Apill::AcceptHeader.new(application: application,
37
+ header: raw_header_from_params)
36
38
  end
37
39
  end
38
40
  end
@@ -1,3 +1,3 @@
1
1
  module Apill
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
3
3
  end
@@ -7,7 +7,8 @@ module Matchers
7
7
  describe InvalidApiRequestMatcher do
8
8
  it 'is the inverse of whether the accept header matches' do
9
9
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion;version=1.0.0' },
10
- subdomains: [ 'api' ])
10
+ subdomains: [ 'api' ],
11
+ params: {})
11
12
 
12
13
  matcher = InvalidApiRequestMatcher.new(application: 'matrix')
13
14
 
@@ -7,7 +7,8 @@ module Matchers
7
7
  describe VersionMatcher do
8
8
  it 'raises an error when the accept header is not valid' do
9
9
  request = OpenStruct.new(headers: { 'Accept' => 'matrix' },
10
- subdomains: [ 'api' ])
10
+ subdomains: [ 'api' ],
11
+ params: {})
11
12
 
12
13
  matcher = VersionMatcher.new
13
14
 
@@ -17,7 +18,8 @@ describe VersionMatcher do
17
18
  context 'when the version is passed in the accept header' do
18
19
  it 'does not match if the subdomain is not API but the request version is equal to the version constraint' do
19
20
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion;version=10.0' },
20
- subdomains: [ 'not-api' ])
21
+ subdomains: [ 'not-api' ],
22
+ params: {})
21
23
 
22
24
  matcher = VersionMatcher.new(application: 'matrix',
23
25
  version_constraint: '10.0')
@@ -27,7 +29,8 @@ describe VersionMatcher do
27
29
 
28
30
  it 'does not match if the subdomain is API but the requested version does not equal the version constraint' do
29
31
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion;version=10.0' },
30
- subdomains: [ 'api' ])
32
+ subdomains: [ 'api' ],
33
+ params: {})
31
34
 
32
35
  matcher = VersionMatcher.new(application: 'matrix',
33
36
  version_constraint: '10.1')
@@ -37,7 +40,8 @@ describe VersionMatcher do
37
40
 
38
41
  it 'does match if the subdomain is API and the requested version equals the version constraint' do
39
42
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion;version=10.0' },
40
- subdomains: [ 'api' ])
43
+ subdomains: [ 'api' ],
44
+ params: {})
41
45
 
42
46
  matcher = VersionMatcher.new(application: 'matrix',
43
47
  version_constraint: '10.0')
@@ -49,7 +53,8 @@ describe VersionMatcher do
49
53
  context 'when the version is not passed in the accept header' do
50
54
  it 'does not match if the subdomain is not API but the request version is equal to the version constraint' do
51
55
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion' },
52
- subdomains: [ 'not-api' ])
56
+ subdomains: [ 'not-api' ],
57
+ params: {})
53
58
 
54
59
  matcher = VersionMatcher.new(application: 'matrix',
55
60
  version_constraint: '10.0',
@@ -60,7 +65,8 @@ describe VersionMatcher do
60
65
 
61
66
  it 'does not match if the subdomain is API but the requested version does not equal the version constraint' do
62
67
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion' },
63
- subdomains: [ 'api' ])
68
+ subdomains: [ 'api' ],
69
+ params: {})
64
70
 
65
71
  matcher = VersionMatcher.new(application: 'matrix',
66
72
  version_constraint: '10.1',
@@ -71,7 +77,8 @@ describe VersionMatcher do
71
77
 
72
78
  it 'does match if the subdomain is API and the requested version equals the version constraint' do
73
79
  request = OpenStruct.new(headers: { 'Accept' => 'application/vnd.matrix+zion' },
74
- subdomains: [ 'api' ])
80
+ subdomains: [ 'api' ],
81
+ params: {})
75
82
 
76
83
  matcher = VersionMatcher.new(application: 'matrix',
77
84
  version_constraint: '10.0',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-26 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: human_error
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.11'
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
- version: '1.7'
26
+ version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -71,7 +71,6 @@ files:
71
71
  - lib/apill/matchers/invalid_api_request_matcher.rb
72
72
  - lib/apill/matchers/subdomain_matcher.rb
73
73
  - lib/apill/matchers/version_matcher.rb
74
- - lib/apill/rescuable_resource.rb
75
74
  - lib/apill/responses/invalid_api_request_response.rb
76
75
  - lib/apill/version.rb
77
76
  - spec/lib/apill/accept_header_spec.rb
@@ -80,7 +79,6 @@ files:
80
79
  - spec/lib/apill/matchers/invalid_api_request_matcher_spec.rb
81
80
  - spec/lib/apill/matchers/subdomain_matcher_spec.rb
82
81
  - spec/lib/apill/matchers/version_matcher_spec.rb
83
- - spec/lib/apill/rescuable_resource_spec.rb
84
82
  homepage: https://github.com/jfelchner/apill
85
83
  licenses: []
86
84
  metadata: {}
@@ -101,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
99
  version: '0'
102
100
  requirements: []
103
101
  rubyforge_project: apill
104
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.3.0
105
103
  signing_key:
106
104
  specification_version: 4
107
105
  summary: Common API functionality
@@ -112,4 +110,4 @@ test_files:
112
110
  - spec/lib/apill/matchers/invalid_api_request_matcher_spec.rb
113
111
  - spec/lib/apill/matchers/subdomain_matcher_spec.rb
114
112
  - spec/lib/apill/matchers/version_matcher_spec.rb
115
- - spec/lib/apill/rescuable_resource_spec.rb
113
+ has_rdoc:
@@ -1,59 +0,0 @@
1
- require 'human_error'
2
-
3
- module Apill
4
- module RescuableResource
5
- module ClassMethods
6
- def rescue_resource(resource_name, from:, via:)
7
- lookup_library = via
8
-
9
- if from.include? 'persistence'
10
- rescue_from HumanError::Errors::ResourcePersistenceError do |e|
11
- error = lookup_library.fetch(
12
- 'ResourcePersistenceError',
13
- resource_name: e.resource_name,
14
- attributes: e.attributes,
15
- errors: e.errors,
16
- action: action_name)
17
-
18
- render json: error,
19
- status: error.http_status
20
- end
21
- end
22
-
23
- if from.include? 'not_found'
24
- rescue_from HumanError::Errors::ResourceNotFoundError do |e|
25
-
26
- resource_id = e.resource_id.is_a?(Array) ? e.resource_id : [e.resource_id]
27
-
28
- error = lookup_library.fetch(
29
- 'ResourceNotFoundError',
30
- resource_name: e.resource_name,
31
- resource_id: resource_id,
32
- action: action_name)
33
-
34
- render json: error,
35
- status: error.http_status
36
- end
37
- end
38
-
39
- if from.include? 'association'
40
- rescue_from HumanError::Errors::AssociationError do |e|
41
- error = lookup_library.fetch(
42
- 'AssociationError',
43
- resource_name: e.resource_name,
44
- association_name: e.association_name,
45
- association_id: e.association_id,
46
- attributes: e.attributes)
47
-
48
- render json: error,
49
- status: error.http_status
50
- end
51
- end
52
- end
53
- end
54
-
55
- def self.included(base)
56
- base.extend ClassMethods
57
- end
58
- end
59
- end
@@ -1,7 +0,0 @@
1
- require 'rspectacular'
2
- require 'apill/rescuable_resource'
3
-
4
- module Apill
5
- describe RescuableResource do
6
- end
7
- end