Class: Shipit::GitHubApp::Token
- Inherits:
-
Object
- Object
- Shipit::GitHubApp::Token
- Defined in:
- lib/shipit/github_app.rb
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#refresh_at ⇒ Object
readonly
Returns the value of attribute refresh_at.
Class Method Summary collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(token, expires_at) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(token, expires_at) ⇒ Token
Returns a new instance of Token.
18 19 20 21 22 23 24 |
# File 'lib/shipit/github_app.rb', line 18 def initialize(token, expires_at) @token = token @expires_at = expires_at # This needs to be lower than the token's lifetime, but higher than the cache expiry setting. @refresh_at = expires_at - GITHUB_TOKEN_REFRESH_WINDOW end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
12 13 14 |
# File 'lib/shipit/github_app.rb', line 12 def expires_at @expires_at end |
#refresh_at ⇒ Object (readonly)
Returns the value of attribute refresh_at.
12 13 14 |
# File 'lib/shipit/github_app.rb', line 12 def refresh_at @refresh_at end |
Class Method Details
.from_github(github_response) ⇒ Object
7 8 9 |
# File 'lib/shipit/github_app.rb', line 7 def from_github(github_response) new(github_response.token, github_response.expires_at) end |
Instance Method Details
#blank? ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/shipit/github_app.rb', line 26 def blank? # Old tokens missing @refresh_at may be used upon deploy, so we should auto-correct for now. # TODO: Remove this assignment at a later date. @refresh_at ||= @expires_at - GITHUB_TOKEN_REFRESH_WINDOW @refresh_at.past? end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/shipit/github_app.rb', line 14 def to_s @token end |