-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output-factory: update livecheck
#172520
output-factory: update livecheck
#172520
Conversation
Version is a beta. Keeping open to stop the version from being merged. |
Casks/o/output-factory.rb
Outdated
livecheck do | ||
url "https://zevrix.com/zsversioncontrol/ZSVersionControl.xml" | ||
strategy :xml do |xml| | ||
elements = xml.get_elements("//dict/key[text()='Output Factory']/following-sibling::dict/key[text()='version']/following-sibling::string") | ||
elements.first.text unless elements.empty? | ||
end | ||
end |
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.
@samford I have no idea what I'm doing with REXML - Copilot gave me this example that works, but hopefully you have a simpler way to do the same thing (except for the line-length style offence)?
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.
Nice timing. I was working on a livecheck
block yesterday that checks a plist file and I ended up with some verbose Ruby code because I wasn't aware that you could do so much with an XPath (I'm used to CSS selectors, so this was a nice reference: https://devhints.io/xpath).
This XPath is a good start. The main thing I would change is to use [1]
to make sure we're only selecting the first dict
after <key>Output Factory 2</key>
. We use an #elements
/#next_element
approach in some other Xml
strategy
blocks (when we only want the first match), so we can follow suit here. [We can technically use /following-sibling::*[1]
at the end of the XPath and omit #next_element
but the latter is a little tidier.]
Past that, we can rework the strategy
block code to avoid the intermediate elements
variable.
One moment and I'll push a commit to take care of these changes (edit: 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.
That cheat sheet is gold. Thanks for the link!
8c2540c
to
bf49015
Compare
Created with
brew bump-cask-pr
.