Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
7555556b
Unverified
Commit
7555556b
authored
4 years ago
by
Markus Reiter
Committed by
Sam Ford
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support block in `PageMatch` strategy.
parent
1857e0eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/livecheck/strategy/page_match.rb
+15
-14
15 additions, 14 deletions
Library/Homebrew/livecheck/strategy/page_match.rb
with
15 additions
and
14 deletions
Library/Homebrew/livecheck/strategy/page_match.rb
+
15
−
14
View file @
7555556b
...
...
@@ -46,21 +46,22 @@ module Homebrew
# @param regex [Regexp] a regex used for matching versions in the
# content
# @return [Array]
def
self
.
page_matches
(
url
,
regex
)
def
self
.
page_matches
(
url
,
regex
,
&
block
)
page
=
Strategy
.
page_contents
(
url
)
matches
=
page
.
scan
(
regex
)
regex_names
=
regex
.
names
.
map
(
&
:to_sym
)
if
regex_names
.
count
>
1
matches
.
map
do
|
match
|
match_data
=
regex_names
.
zip
(
match
).
to_h
regex_names
.
sort
.
map
{
|
name
|
match_data
[
name
]
}.
join
(
","
)
end
.
uniq
else
matches
.
map
(
&
:first
).
uniq
if
block
data
=
{
page:
page
}
case
(
value
=
block
.
call
(
data
))
when
String
return
[
value
]
when
Array
return
value
else
raise
TypeError
,
"Return value of `strategy :page_match` block must be a string or array."
end
end
page
.
scan
(
regex
).
map
(
&
:first
).
uniq
end
# Checks the content at the URL for new versions, using the provided
...
...
@@ -69,10 +70,10 @@ module Homebrew
# @param url [String] the URL of the content to check
# @param regex [Regexp] a regex used for matching versions in content
# @return [Hash]
def
self
.
find_versions
(
url
,
regex
)
def
self
.
find_versions
(
url
,
regex
,
&
block
)
match_data
=
{
matches:
{},
regex:
regex
,
url:
url
}
page_matches
(
url
,
regex
).
each
do
|
match
|
page_matches
(
url
,
regex
,
&
block
).
each
do
|
match
|
match_data
[
:matches
][
match
]
=
Version
.
new
(
match
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment