-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
Casks/vlc-nightly.rb
Outdated
base_url = "https://artifacts.videolan.org/vlc/nightly-macos/" | ||
folder = URI(base_url).open.read.scan(/(\d+-\d+)/).flatten.first | ||
updated_url = "#{base_url}#{folder}/" | ||
file = URI.join(updated_url).open.read.scan(/href="([^"]+.dmg)"/).flatten.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why URI.join
if there is only a single string argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because without it I get the error:
Error: Download failed on Cask 'vlc-nightly' with message: undefined method `call' for URI:Module
Casks/vlc-nightly.rb
Outdated
file = URI(base_url).open.read.scan(/href="([^"]+.dmg)"/).flatten.first | ||
"#{base_url}#{file}" | ||
base_url = "https://artifacts.videolan.org/vlc/nightly-macos/" | ||
folder = URI(base_url).open.read.scan(/(\d+-\d+)/).flatten.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do this for other casks as well, but there’s no point to using scan
if we’re going to use the first result. match
does it fine.
folder = URI(base_url).open.read.scan(/(\d+-\d+)/).flatten.first | |
folder = URI(base_url).open.read.match(/(\d+-\d+)/).to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing can be done below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just .read[/(\d+-\d+)/, 1]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just
.read[/(\d+-\d+)/, 1]
.
That is better -- makes it clear that it is the first match in the list. Thanks @reitermarkus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just
.read[/(\d+-\d+)/, 1]
What’s the , 1
for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just
.read[/(\d+-\d+)/, 1]
What’s the
, 1
for?
First match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First match.
It’s always the first match, there’s only one capture being made. For the 1
to be meaningful, there would need to be more than one set of parenthesis (or any code outside of them). Which we can also remove, because we don’t need a capture group in this case: URI(base_url).read[/\d+-\d+/]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point -- updated.
Thank you @reitermarkus. |
After making all changes to a cask, verify:
brew cask audit --download {{cask_file}}
is error-free.brew cask style --fix {{cask_file}}
reports no offenses.Closes #9700
I have set this up to download the nightly builds of VLC version 4:
https://artifacts.videolan.org/vlc/nightly-macos/
Nightly builds of version 3 are located at:
https://artifacts.videolan.org/vlc-3.0/nightly-macos/
which would change the
base_url
.