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
b8bafe4e
Unverified
Commit
b8bafe4e
authored
4 years ago
by
Sam Ford
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8156 from samford/add-strategy-to-livecheck-dsl
Add strategy to livecheck DSL
parents
c3eada09
72985277
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/livecheck.rb
+18
-0
18 additions, 0 deletions
Library/Homebrew/livecheck.rb
Library/Homebrew/test/livecheck_spec.rb
+26
-1
26 additions, 1 deletion
Library/Homebrew/test/livecheck_spec.rb
with
44 additions
and
1 deletion
Library/Homebrew/livecheck.rb
+
18
−
0
View file @
b8bafe4e
...
...
@@ -15,6 +15,7 @@ class Livecheck
@regex
=
nil
@skip
=
false
@skip_msg
=
nil
@strategy
=
nil
@url
=
nil
end
...
...
@@ -40,6 +41,22 @@ class Livecheck
@skip
end
# Sets the strategy instance variable to the provided symbol or returns the
# strategy instance variable when no argument is provided. The strategy
# symbols use snake case (e.g., `:page_match`) and correspond to the strategy
# file name.
# @param symbol [Symbol] symbol for the desired strategy
def
strategy
(
symbol
=
nil
)
case
symbol
when
nil
@strategy
when
Symbol
@strategy
=
symbol
else
raise
TypeError
,
"Livecheck#strategy expects a Symbol"
end
end
# Sets the url instance variable to the argument given, returns the url
# instance variable when no argument is given.
def
url
(
val
=
nil
)
...
...
@@ -61,6 +78,7 @@ class Livecheck
"regex"
=>
@regex
,
"skip"
=>
@skip
,
"skip_msg"
=>
@skip_msg
,
"strategy"
=>
@strategy
,
"url"
=>
@url
,
}
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/livecheck_spec.rb
+
26
−
1
View file @
b8bafe4e
...
...
@@ -44,6 +44,23 @@ describe Livecheck do
end
end
describe
"#strategy"
do
it
"returns nil if not set"
do
expect
(
livecheckable
.
strategy
).
to
be
nil
end
it
"returns the Symbol if set"
do
livecheckable
.
strategy
(
:page_match
)
expect
(
livecheckable
.
strategy
).
to
eq
(
:page_match
)
end
it
"raises a TypeError if the argument isn't a Symbol"
do
expect
{
livecheckable
.
strategy
(
"page_match"
)
}.
to
raise_error
(
TypeError
,
"Livecheck#strategy expects a Symbol"
)
end
end
describe
"#url"
do
it
"returns nil if unset"
do
expect
(
livecheckable
.
url
).
to
be
nil
...
...
@@ -57,7 +74,15 @@ describe Livecheck do
describe
"#to_hash"
do
it
"returns a Hash of all instance variables"
do
expect
(
livecheckable
.
to_hash
).
to
eq
({
"regex"
=>
nil
,
"skip"
=>
false
,
"skip_msg"
=>
nil
,
"url"
=>
nil
})
expect
(
livecheckable
.
to_hash
).
to
eq
(
{
"regex"
=>
nil
,
"skip"
=>
false
,
"skip_msg"
=>
nil
,
"strategy"
=>
nil
,
"url"
=>
nil
,
},
)
end
end
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