DEV: Apply syntax_tree formatting to lib/*

This commit is contained in:
David Taylor
2023-01-09 12:10:19 +00:00
parent b0fda61a8e
commit 6417173082
507 changed files with 16550 additions and 12627 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative '../mixins/github_body'
require_relative "../mixins/github_body"
module Onebox
module Engine
@ -9,7 +9,9 @@ module Onebox
include LayoutSupport
include JSON
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/(actions\/runs\/[[:digit:]]+|pull\/[[:digit:]]*\/checks\?check_run_id=[[:digit:]]+)/)
matches_regexp(
%r{^https?://(?:www\.)?(?:(?:\w)+\.)?github\.com/(?<org>.+)/(?<repo>.+)/(actions/runs/[[:digit:]]+|pull/[[:digit:]]*/checks\?check_run_id=[[:digit:]]+)},
)
always_https
def url
@ -29,12 +31,18 @@ module Onebox
def match_url
return if defined?(@match) && defined?(@type)
if match = @url.match(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/actions\/runs\/(?<run_id>[[:digit:]]+)/)
if match =
@url.match(
%r{^https?://(?:www\.)?(?:(?:\w)+\.)?github\.com/(?<org>.+)/(?<repo>.+)/actions/runs/(?<run_id>[[:digit:]]+)},
)
@match = match
@type = :actions_run
end
if match = @url.match(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/pull\/(?<pr_id>[[:digit:]]*)\/checks\?check_run_id=(?<check_run_id>[[:digit:]]+)/)
if match =
@url.match(
%r{^https?://(?:www\.)?(?:(?:\w)+\.)?github\.com/(?<org>.+)/(?<repo>.+)/pull/(?<pr_id>[[:digit:]]*)/checks\?check_run_id=(?<check_run_id>[[:digit:]]+)},
)
@match = match
@type = :pr_run
end
@ -67,18 +75,20 @@ module Onebox
status = "pending"
end
title = if type == :actions_run
raw["head_commit"]["message"].lines.first
elsif type == :pr_run
pr_url = "https://api.github.com/repos/#{match[:org]}/#{match[:repo]}/pulls/#{match[:pr_id]}"
::MultiJson.load(URI.parse(pr_url).open(read_timeout: timeout))["title"]
end
title =
if type == :actions_run
raw["head_commit"]["message"].lines.first
elsif type == :pr_run
pr_url =
"https://api.github.com/repos/#{match[:org]}/#{match[:repo]}/pulls/#{match[:pr_id]}"
::MultiJson.load(URI.parse(pr_url).open(read_timeout: timeout))["title"]
end
{
link: @url,
title: title,
name: raw["name"],
run_number: raw["run_number"],
:link => @url,
:title => title,
:name => raw["name"],
:run_number => raw["run_number"],
status => true,
}
end