apill 1.1.0 → 1.1.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: 8b6e98aa489a5ae613535da00d756a01f5a43a21
4
- data.tar.gz: 701aae7dade873f7fbb73dc58f43654dda96797e
3
+ metadata.gz: 4978fd82cf24f21bcbedf34a5086842fd0c82f8a
4
+ data.tar.gz: 45e18274d4ed90d8d7d377c2746eb0a858ff311d
5
5
  SHA512:
6
- metadata.gz: 04627afe9df9d0af43799c794836461cb70587d3877039469d3cb179843d9ee72cd46ef7544921eeeb05d4ca89a03127b90779398637024ed082557bfdb277a2
7
- data.tar.gz: fd1903a45d3ab8af84448a0f530b63f2d2b97bd2f3a0f3b60d53648a81fd3d0299d2f9bbd656c50e24c0319762a594cab4dc7129afca1dbc8a9491277be2accc
6
+ metadata.gz: 687871c4ad8068fddd8317dc19845677ec74bba3b70700a2a2b1eace782738984944bc440ba864b9fc7eef27d237896856a5de433fdba7e9f94bc34d8d72db28
7
+ data.tar.gz: c22b38830eeaab0fae13aa878258eb4acc7e913cd179a2174da2e09669ed12717f0bbfdac2c5a50730a107eb756833e258243efec5f88ddd1554aca5a7b46b48
@@ -0,0 +1,17 @@
1
+ module Apill
2
+ module Matchers
3
+ class SubdomainMatcher
4
+ def initialize(subdomain: 'api')
5
+ self.subdomain = subdomain
6
+ end
7
+
8
+ def matches?(request)
9
+ request.subdomains.first == subdomain
10
+ end
11
+
12
+ protected
13
+
14
+ attr_accessor :subdomain
15
+ end
16
+ end
17
+ end
@@ -4,12 +4,12 @@ module Apill
4
4
  module Responses
5
5
  class InvalidApiRequestResponse
6
6
  def self.call(env)
7
- error = Apill::Errors::InvalidApiRequestError.new
7
+ error = Apill::Errors::InvalidApiRequestError.new(accept_header: env['HTTP_ACCEPT'])
8
8
 
9
9
  [
10
10
  error.http_status, # HTTP Status Code
11
11
  {}, # Response Headers
12
- error.to_json, # Message
12
+ [ error.to_json ], # Message
13
13
  ]
14
14
  end
15
15
  end
data/lib/apill/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Apill
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/apill.rb CHANGED
@@ -3,5 +3,6 @@ require 'apill/version'
3
3
  require 'apill/matchers/accept_header_matcher'
4
4
  require 'apill/matchers/invalid_api_request_matcher'
5
5
  require 'apill/matchers/version_matcher'
6
+ require 'apill/matchers/subdomain_matcher'
6
7
 
7
8
  require 'apill/responses/invalid_api_request_response'
@@ -0,0 +1,41 @@
1
+ require 'ostruct'
2
+ require 'rspectacular'
3
+ require 'apill/matchers/subdomain_matcher'
4
+
5
+ module Apill
6
+ module Matchers
7
+ describe SubdomainMatcher do
8
+ it 'matches if the subdomain is API' do
9
+ request = OpenStruct.new(subdomains: [ 'api' ])
10
+
11
+ matcher = SubdomainMatcher.new
12
+
13
+ expect(matcher.matches?(request)).to be_truthy
14
+ end
15
+
16
+ it 'matches if the first subdomain is API' do
17
+ request = OpenStruct.new(subdomains: [ 'api', 'matrix' ])
18
+
19
+ matcher = SubdomainMatcher.new
20
+
21
+ expect(matcher.matches?(request)).to be_truthy
22
+ end
23
+
24
+ it 'does not match if the first subdomain is not API' do
25
+ request = OpenStruct.new(subdomains: [ 'matrix' ])
26
+
27
+ matcher = SubdomainMatcher.new
28
+
29
+ expect(matcher.matches?(request)).to be_falsey
30
+ end
31
+
32
+ it 'allows the matched subdomain to be specified' do
33
+ request = OpenStruct.new(subdomains: [ 'matrix' ])
34
+
35
+ matcher = SubdomainMatcher.new(subdomain: 'matrix')
36
+
37
+ expect(matcher.matches?(request)).to be_truthy
38
+ end
39
+ end
40
+ end
41
+ end
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: human_error
@@ -69,6 +69,7 @@ files:
69
69
  - lib/apill/matchers/accept_header_matcher.rb
70
70
  - lib/apill/matchers/generic_matcher.rb
71
71
  - lib/apill/matchers/invalid_api_request_matcher.rb
72
+ - lib/apill/matchers/subdomain_matcher.rb
72
73
  - lib/apill/matchers/version_matcher.rb
73
74
  - lib/apill/responses/invalid_api_request_response.rb
74
75
  - lib/apill/version.rb
@@ -76,6 +77,7 @@ files:
76
77
  - spec/lib/apill/errors/invalid_api_request_error_spec.rb
77
78
  - spec/lib/apill/matchers/accept_header_matcher_spec.rb
78
79
  - spec/lib/apill/matchers/invalid_api_request_matcher_spec.rb
80
+ - spec/lib/apill/matchers/subdomain_matcher_spec.rb
79
81
  - spec/lib/apill/matchers/version_matcher_spec.rb
80
82
  homepage: https://github.com/jfelchner/apill
81
83
  licenses: []
@@ -106,5 +108,6 @@ test_files:
106
108
  - spec/lib/apill/errors/invalid_api_request_error_spec.rb
107
109
  - spec/lib/apill/matchers/accept_header_matcher_spec.rb
108
110
  - spec/lib/apill/matchers/invalid_api_request_matcher_spec.rb
111
+ - spec/lib/apill/matchers/subdomain_matcher_spec.rb
109
112
  - spec/lib/apill/matchers/version_matcher_spec.rb
110
113
  has_rdoc: