Rubocop auto-correct (#16181)

This commit is contained in:
Michael Kohl 2022-01-19 21:04:43 +07:00 committed by GitHub
parent 3685530969
commit 2533a438f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,17 @@
class CodepenTag < LiquidTagBase
PARTIAL = "liquids/codepen".freeze
# rubocop:disable Layout/LineLength
REGISTRY_REGEXP =
%r{\A(http|https)://(codepen\.io|codepen\.io/team)/[a-zA-Z0-9_\-]{1,30}/(pen|embed)(/preview)?/([a-zA-Z0-9]{5,32})/{0,1}\z}
# rubocop:enable Layout/LineLength
def initialize(_tag_name, link, _parse_context)
super
link = CGI.unescape_html(link)
@link = parse_link(link)
valid_options = parse_options(link)
@build_options = valid_options.gsub(/height=\d{3,4}&(amp;)?/, '')
@height = (valid_options[/height=(\d{3,4})/, 1] || '600').to_i
@build_options = valid_options.gsub(/height=\d{3,4}&(amp;)?/, "")
@height = (valid_options[/height=(\d{3,4})/, 1] || "600").to_i
end
def render(_context)
@ -27,9 +29,9 @@ class CodepenTag < LiquidTagBase
def valid_option(option)
option.match(/(default-tab=\w+(,\w+)?)/) ||
option.match(/(theme-id=\d{1,7})/) ||
option.match(/(editable=true)/) ||
option.match(/(height=\d{3,4})/)
option.match(/(theme-id=\d{1,7})/) ||
option.match(/(editable=true)/) ||
option.match(/(height=\d{3,4})/)
end
def parse_options(input)
@ -66,4 +68,4 @@ end
Liquid::Template.register_tag("codepen", CodepenTag)
UnifiedEmbed.register(CodepenTag, regexp: CodepenTag::REGISTRY_REGEXP)
UnifiedEmbed.register(CodepenTag, regexp: CodepenTag::REGISTRY_REGEXP)