Class: Rack::Auth::Travis::Request
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- Rack::Auth::Travis::Request
- Defined in:
- lib/rack/auth/travis.rb
Constant Summary collapse
- JSON_REGEXP =
/^application\/([\w!#\$%&\*`\-\.\^~]*\+)?json$/i
Instance Method Summary collapse
-
#initialize(env, authenticators = Travis.default_authenticators) ⇒ Request
constructor
A new instance of Request.
- #json? ⇒ Boolean
- #name ⇒ Object
- #owner_name ⇒ Object
- #repo_slug ⇒ Object
- #token ⇒ Object
- #travis? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(env, authenticators = Travis.default_authenticators) ⇒ Request
Returns a new instance of Request.
96 97 98 99 |
# File 'lib/rack/auth/travis.rb', line 96 def initialize(env, authenticators = Travis.default_authenticators) super(env) @authenticators = authenticators || [] end |
Instance Method Details
#json? ⇒ Boolean
105 106 107 |
# File 'lib/rack/auth/travis.rb', line 105 def json? request.env['CONTENT_TYPE'] =~ JSON_REGEXP end |
#name ⇒ Object
121 122 123 |
# File 'lib/rack/auth/travis.rb', line 121 def name @name ||= repository['name'] end |
#owner_name ⇒ Object
117 118 119 |
# File 'lib/rack/auth/travis.rb', line 117 def owner_name @owner ||= repository['owner_name'] end |
#repo_slug ⇒ Object
125 126 127 |
# File 'lib/rack/auth/travis.rb', line 125 def repo_slug [owner_name, name].join('/') end |
#token ⇒ Object
129 130 131 |
# File 'lib/rack/auth/travis.rb', line 129 def token @token ||= parts.first.to_s end |
#travis? ⇒ Boolean
101 102 103 |
# File 'lib/rack/auth/travis.rb', line 101 def travis? token =~ /[\da-f]{64}/i end |
#valid? ⇒ Boolean
109 110 111 112 113 114 115 |
# File 'lib/rack/auth/travis.rb', line 109 def valid? return false unless provided? && travis? && json? @authenticators.each do |authenticator| return true if authenticator.valid?(self) end false end |