Class: CodeUnion::FeedbackRequest
- Inherits:
-
Object
- Object
- CodeUnion::FeedbackRequest
- Defined in:
- lib/codeunion/feedback_request.rb
Overview
Sends feedback requests to CodeUnion for review
Defined Under Namespace
Classes: FeedbackRepository
Constant Summary collapse
- WEB_URL_REGEX =
/\A#{URI.regexp(['http', 'https'])}\z/
- GIT_URL_REGEX =
%r{\A(git://)[email protected]:(.*)(.git)?\z}
- REPO_CAPTURE_INDEX =
1
- MISSING_ARTIFACT =
"You must provide something to provide feedback on"
- INVALID_ARTIFACT =
"The artifact provided was not a web URL. We only provide feedback on code hosted online."
- ISSUE_TITLE =
"Please give my code feedback. Submitted #{Time.now}"
Instance Attribute Summary collapse
-
#artifact ⇒ Object
readonly
Returns the value of attribute artifact.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(artifact, github_token, feedback_repository, options = {}) ⇒ FeedbackRequest
constructor
A new instance of FeedbackRequest.
- #send! ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(artifact, github_token, feedback_repository, options = {}) ⇒ FeedbackRequest
Returns a new instance of FeedbackRequest.
20 21 22 23 24 |
# File 'lib/codeunion/feedback_request.rb', line 20 def initialize(artifact, github_token, feedback_repository, = {}) @github_api = .fetch(:github_api, GithubAPI).new(github_token) @artifact = artifact @feedback_repository = FeedbackRepository.coerce_to_proper_url(feedback_repository) end |
Instance Attribute Details
#artifact ⇒ Object (readonly)
Returns the value of attribute artifact.
18 19 20 |
# File 'lib/codeunion/feedback_request.rb', line 18 def artifact @artifact end |
Instance Method Details
#errors ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/codeunion/feedback_request.rb', line 34 def errors errors = [] errors.push(MISSING_ARTIFACT) if artifact.empty? errors.push(INVALID_ARTIFACT) unless url?(artifact) errors.join("\n") end |
#send! ⇒ Object
26 27 28 |
# File 'lib/codeunion/feedback_request.rb', line 26 def send! @github_api.create_issue(ISSUE_TITLE, @artifact, @feedback_repository) end |
#valid? ⇒ Boolean
30 31 32 |
# File 'lib/codeunion/feedback_request.rb', line 30 def valid? errors.empty? end |