rack-auditor 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWMwOGQ5NjU5ZWJlNWFlYWU1OWI0MTczZTYzODYzOGJkN2Q2ODZhZg==
4
+ NzQ4NTRlM2QwYTllMzk5OWY2YWQxZDliMzMxNzkyMmVkZTgyYmM0YQ==
5
5
  data.tar.gz: !binary |-
6
- MzQxNjI5OTA3NjcxZWU2NDg3ZGU1YWI2MDczMjUzNjg0YjJkZDEwNQ==
6
+ NmI4NDhiZDEzZTEwNTg4MWU3ZjI2ZmI2NDlkNjFjYmVjMGQwNjIzZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Mzk2M2M0Y2NhMjhlZjdjODY0NzA2YWEyY2E2MWY0YTcyOTc2Mzg5MWQwZWU0
10
- ZGExNzU5YTUyYzk4N2ZhYjFlZDhmZjI0NTM2ZmFlMzQ2Mzk2MGNiYjIzYzY2
11
- OTA5MWM0YzZhYjgzYWUzN2Y3ZjBhNjUwMjQ5MDZkMzk5Nzc5NzA=
9
+ YWQ4ZTYyMGYzNTM5NTU4ODEyODE0MDFiYzJkODhjNTViZWVlMjBmOWEzMWEy
10
+ NzE3MDc4MzMyMWMwMzMzYTQwMDBlYTdhYzBhZjZiNDhmODRmYjEzMDA3YzRl
11
+ NTI1YzY5YTRjNWMxMjQ4YTRmYjlkZTY3ZDNiODM4YzRhYjNhZTE=
12
12
  data.tar.gz: !binary |-
13
- MjI4MDU2MmRlODExMjkzNzJlYWNkYWE4ZWVhYjEyYmZkODU5ZjY4MTVjMmE3
14
- OGU0NDQxYTAwYjA4ZjlmNDBiZGJmNzJjZDRjMzc1MDNiNjFmNGNlNDkwMDYy
15
- ZTU3YmY5ZGU2NjkxZTk5MmVjNWU0NzgxNzdlNzMxMDkxYzMxYTk=
13
+ NWQ3OWM0ZWE0MzU4YzQzYTBjNzk0NTA3Y2Q1NWQ2YzRmNjVhYzQ2OGJjMGZi
14
+ MTY3OTdmYmFjNzI1YzA3ODljOWU4NTEzZjI5ZTBmMjM2ZTI4YWZkN2JiMTAw
15
+ MTIxMzZjNDRlNmE3ODUwMzM3Y2VjYzEzMDU5NzdkYTZmNDJmODQ=
data/lib/rack/auditor.rb CHANGED
@@ -9,33 +9,31 @@ module Rack
9
9
  end
10
10
 
11
11
  def call(env)
12
- audit(env) unless @dev_mode
12
+ unless @dev_mode
13
+ key = env['HTTP_X_API_KEY']
14
+ secret = env['HTTP_X_API_SECRET']
15
+
16
+ return forbidden unless key && secret
17
+
18
+ response = HTTParty.get "#{@root_uri}?api_key=#{key}&api_secret=#{secret}"
19
+
20
+ case response.code
21
+ when 403
22
+ forbidden
23
+ when 404
24
+ error_code(404, 'Not Found')
25
+ when 500
26
+ error_code(500, 'Server Error')
27
+ when 503
28
+ error_code(503, 'Maintenance')
29
+ when 504
30
+ error_code(504, 'System Down')
31
+ end
32
+ end
13
33
 
14
34
  @app.call(env)
15
35
  end
16
36
 
17
- def audit(env)
18
- key = env['HTTP_X_API_KEY']
19
- secret = env['HTTP_X_API_SECRET']
20
-
21
- return forbidden unless key && secret
22
-
23
- response = HTTParty.get "#{@root_uri}?api_key=#{key}&api_secret=#{secret}"
24
-
25
- case response.code
26
- when 403
27
- forbidden
28
- when 404
29
- error_code(404, 'Not Found')
30
- when 500
31
- error_code(500, 'Server Error')
32
- when 503
33
- error_code(503, 'Maintenance')
34
- when 504
35
- error_code(504, 'System Down')
36
- end
37
- end
38
-
39
37
  private
40
38
  def forbidden
41
39
  error_code(403, 'Unauthorized')
data/rack-auditor.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack-auditor"
3
- s.version = "0.2.0"
3
+ s.version = "0.2.1"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Patrick Robertson"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Robertson