Class: EnvPullRequest::Base
- Inherits:
-
Object
- Object
- EnvPullRequest::Base
- Includes:
- NaturalNumberString
- Defined in:
- lib/env_pull_request/base.rb
Overview
Pull request information object from environment variables
Instance Attribute Summary collapse
-
#pull_request_id ⇒ Integer?
readonly
Pull request id or nil.
Instance Method Summary collapse
-
#fetch_pull_request_id ⇒ Integer?
Fetch pull request id from environment variables.
-
#initialize ⇒ Base
constructor
Build pull request information object from environment variables.
-
#pull_request? ⇒ Boolean
True if this is pull request.
Constructor Details
Instance Attribute Details
#pull_request_id ⇒ Integer? (readonly)
Returns pull request id or nil.
7 8 9 |
# File 'lib/env_pull_request/base.rb', line 7 def pull_request_id @pull_request_id end |
Instance Method Details
#fetch_pull_request_id ⇒ Integer?
Fetch pull request id from environment variables
travis-ci.org:
ENV['TRAVIS_PULL_REQUEST']
circleci.com:
ENV['CIRCLE_PR_NUMBER']
bitrise.io:
ENV['BITRISE_PULL_REQUEST']
Jenkins GitHub pull request builder plugin:
ENV['ghprbPullId']
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/env_pull_request/base.rb', line 63 def fetch_pull_request_id if positive_integer_string? ENV['TRAVIS_PULL_REQUEST'] ENV['TRAVIS_PULL_REQUEST'].to_i elsif positive_integer_string? ENV['CIRCLE_PR_NUMBER'] ENV['CIRCLE_PR_NUMBER'].to_i elsif positive_integer_string? ENV['BITRISE_PULL_REQUEST'] ENV['BITRISE_PULL_REQUEST'].to_i elsif positive_integer_string? ENV['ghprbPullId'] ENV['ghprbPullId'].to_i end end |
#pull_request? ⇒ Boolean
Returns true if this is pull request.
76 77 78 |
# File 'lib/env_pull_request/base.rb', line 76 def pull_request? !pull_request_id.nil? end |