Class: Danger::RequestSources::GitHubSource::Review
- Inherits:
-
Object
- Object
- Danger::RequestSources::GitHubSource::Review
- Includes:
- Helpers::CommentsHelper
- Defined in:
- lib/danger/request_sources/github/github_review.rb
Constant Summary collapse
- EVENT_APPROVE =
"APPROVE".freeze
- EVENT_REQUEST_CHANGES =
"REQUEST_CHANGES".freeze
- EVENT_COMMENT =
"COMMENT".freeze
- STATUS_APPROVED =
Current review status, if the review has not been submitted yet -> STATUS_PENDING
"APPROVED".freeze
- STATUS_REQUESTED_CHANGES =
"CHANGES_REQUESTED".freeze
- STATUS_COMMENTED =
"COMMENTED".freeze
- STATUS_PENDING =
"PENDING".freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#review_json ⇒ Object
readonly
Returns the value of attribute review_json.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #fail(message, sticky = true, file = nil, line = nil) ⇒ Object
- #generated_by_danger?(danger_id = "danger") ⇒ Boolean
-
#initialize(client, ci_source, review_json = nil) ⇒ Review
constructor
A new instance of Review.
- #markdown(message, file = nil, line = nil) ⇒ Object
- #message(message, sticky = true, file = nil, line = nil) ⇒ Object
-
#start ⇒ Object
Starts the new review process.
-
#submit ⇒ Object
Submits the prepared review.
- #warn(message, sticky = true, file = nil, line = nil) ⇒ Object
Methods included from Helpers::CommentsHelper
#apply_template, #generate_comment, #generate_description, #generate_inline_comment_body, #generate_inline_markdown_body, #generate_message_group_comment, #markdown_link_to_message, #markdown_parser, #messages_are_equivalent, #process_markdown, #random_compliment, #table
Methods included from Helpers::CommentsParsingHelper
#parse_comment, #parse_message_from_row, #parse_tables_from_comment, #table_kind_from_title, #violations_from_table
Constructor Details
#initialize(client, ci_source, review_json = nil) ⇒ Review
Returns a new instance of Review.
28 29 30 31 32 |
# File 'lib/danger/request_sources/github/github_review.rb', line 28 def initialize(client, ci_source, review_json = nil) @ci_source = ci_source @client = client @review_json = review_json end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
26 27 28 |
# File 'lib/danger/request_sources/github/github_review.rb', line 26 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/danger/request_sources/github/github_review.rb', line 26 def id @id end |
#review_json ⇒ Object (readonly)
Returns the value of attribute review_json.
26 27 28 |
# File 'lib/danger/request_sources/github/github_review.rb', line 26 def review_json @review_json end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/danger/request_sources/github/github_review.rb', line 26 def status @status end |
Instance Method Details
#fail(message, sticky = true, file = nil, line = nil) ⇒ Object
83 84 85 |
# File 'lib/danger/request_sources/github/github_review.rb', line 83 def fail(, sticky = true, file = nil, line = nil) @errors << Violation.new(, sticky, file, line) end |
#generated_by_danger?(danger_id = "danger") ⇒ Boolean
71 72 73 |
# File 'lib/danger/request_sources/github/github_review.rb', line 71 def generated_by_danger?(danger_id = "danger") self.review_json["body"].include?("generated_by_#{danger_id}") end |
#markdown(message, file = nil, line = nil) ⇒ Object
87 88 89 |
# File 'lib/danger/request_sources/github/github_review.rb', line 87 def markdown(, file = nil, line = nil) @markdowns << Markdown.new(, file, line) end |
#message(message, sticky = true, file = nil, line = nil) ⇒ Object
75 76 77 |
# File 'lib/danger/request_sources/github/github_review.rb', line 75 def (, sticky = true, file = nil, line = nil) @messages << Violation.new(, sticky, file, line) end |
#start ⇒ Object
Starts the new review process
53 54 55 56 57 58 |
# File 'lib/danger/request_sources/github/github_review.rb', line 53 def start @warnings = [] @errors = [] @messages = [] @markdowns = [] end |
#submit ⇒ Object
Submits the prepared review
61 62 63 64 65 66 67 68 69 |
# File 'lib/danger/request_sources/github/github_review.rb', line 61 def submit general_violations = generate_general_violations submission_body = generate_body # If the review resolver says that there is nothing to submit we skip submission return unless ReviewResolver.should_submit?(self, submission_body) @review_json = @client.create_pull_request_review(@ci_source.repo_slug, @ci_source.pull_request_id, event: generate_event(general_violations), body: submission_body) end |