19 Commits

Author SHA1 Message Date
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
26eda5a303
git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
Sam Ford
bc2ce97e5d
Sparkle: Move sorting/filtering into methods
We need to be able to replicate the `Sparkle` strategy's sorting
and filtering behavior in a related cask audit, so this extracts
the logic into reusable methods.

This also stores `item.minimum_system_version` as a `MacOSVersion`
object (instead of a string), so we can do proper version comparison
(instead of naive string comparison) wherever needed.
2023-11-16 12:05:24 -05:00
Sam Ford
86c702abcd
Sparkle: Surface more Item values
Historically, the `Sparkle` strategy's `Item` struct has only
included basic values from the appcast that are commonly useful.
Over time we've selectively added/surfaced more values as we've
encountered outliers that require use of different values in a
`strategy` block.

We now need to use `minimumSystemValue`, so this expands the `Item`
struct to include any appcast value that we could conceivably want
to use in the future. This will hopefully save us from having to make
more modifications to the struct (and related tests) before we can
use a previously-unused value in a `strategy` block.
2023-10-28 14:55:47 -04:00
Douglas Eichelberger
9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger
ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long
3a83b5492c
rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00
Tim Visher
fc31d5560c livecheck/strategy/sparkle.rb: Add macos to the candidate os values list
As can be seen by TextExpander's Sparkle Feed, `macos` is a possible
value.

```
$ date -u '+%FT%T%z' && xmlstarlet sel -t -v '//rss//channel//item//enclosure/@*[name()="url" or name()="sparkle:version" or name()="sparkle:shortVersionString" or name()="sparkle:os"]' <(curl --location --silent https://textexpander.com/appcast/TextExpander-macOS.xml)
2022-10-22T17:07:06+0000
https://cdn.textexpander.com/mac/731.2/TextExpander_7.3.1.dmg
731.2
7.3.1
macos
https://cdn.textexpander.com/mac/720.16/TextExpander_7.2.dmg
720.16
7.2
macos
https://cdn.textexpander.com/mac/710.6/TextExpander_7.1.dmg
710.6
7.1
macos
https://cdn.textexpander.com/mac/702.2/TextExpander_7.0.2.dmg
702.2
7.0.2
macos
https://cdn.textexpander.com/mac/701.2/TextExpander_7.0.1.dmg
701.2
7.0.1
macos
https://cdn.textexpander.com/mac/700.33/TextExpander_7.0.dmg
700.33
7.0
macos
https://cdn.textexpander.com/mac/685.6/TextExpander_6.8.5.zip
685.6
6.8.5
https://cdn.textexpander.com/mac/684.8/TextExpander_6.8.4.zip
684.8
6.8.4
https://cdn.textexpander.com/mac/683.2/TextExpander_6.8.3.zip
683.2
6.8.3
https://cdn.textexpander.com/mac/682.10/TextExpander_6.8.2.zip
682.10
6.8.2
https://cdn.textexpander.com/mac/681.3/TextExpander_6.8.1.zip
681.3
6.8.1
https://cdn.textexpander.com/mac/680.30/TextExpander_6.8.zip
680.30
6.8
https://cdn.textexpander.com/mac/TextExpander_6.5.6.zip
656.3
6.5.6
https://cdn.textexpander.com/mac/TextExpander_6.5.5.zip
655.0
6.5.5
https://cdn.textexpander.com/mac/TextExpander_6.5.4.zip
654.3
6.5.4
https://cdn.textexpander.com/mac/TextExpander_6.5.3.zip
653.3
6.5.3
https://cdn.textexpander.com/mac/TextExpander_6.5.2.zip
652.0
6.5.2
https://smilesoftware.com/downloads/test/TextExpander_6.5.1.zip
651.5
6.5.1
```

Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2022-12-04 14:21:27 -05:00
Sam Ford
71906c7f89
Tidy up Sparkle tests a bit 2022-06-02 10:36:33 -04:00
Sam Ford
c6907f911f
Sparkle: Provide channel information in Item
Making `channel` information available in the `Item` is necessary
to be able to filter out unstable items using a `strategy` block. If
an item doesn't specify a channel, then it uses the default channel
(this is what Sparkle itself uses for updates). Channels like `beta`
are something we want to avoid for stable casks and this allows for
that type of [cask-specific] filtering.

It's technically possible to automatically filter out items that
aren't using the default channel (i.e., `channel != nil`) in
`#items_from_content` but some casks use an unstable version, so we
can't do this internally. That is to say, we wouldn't be able to
override internal filtering in a `strategy` block, as any omitted
items wouldn't be provided to the block. Conversely, if we pass all
items to a `strategy` block, we can easily filter by channel there.
We haven't been filtering by channel internally and we've only found
one cask where this has been a problem, so it seems fine for now.
2022-06-02 10:35:00 -04:00
Sam Ford
b4cb47815f
Sparkle: Pass all items into strategy block
It's sometimes necessary to work with all the items in a Sparkle feed
to be able to correctly identify the newest version but livecheck's
`Sparkle` strategy only passes the `item` it views as newest into a
`strategy` block.

This updates the `Sparkle` strategy to optionally pass all items into
a `strategy` block, so we can manipulate them (e.g., filtering,
sorting). This is enabled by naming the first argument of the
strategy block `items` instead of `item`. `Sparkle` `strategy` blocks
where the first argument is `item` will continue to work as expected.

This necessarily updates `#item_from_content` (now
`items_from_content`) to return all items. I've decided to move the
sorting out of `#items_from_content`, so it simply returns the items
in the order they appear. If there is ever an exceptional situation
where we need the original order, this will technically allow for it.

The sorting has instead been moved into the `#versions_from_content`
method, to maintain the existing behavior. I thought about passing
the items into the `strategy` block in their original order but it
feels like sorting by default is the better approach for now (partly
from the perspective of maintaining existing behavior) and we can
always revisit this in the future if a cask ever requires the
original order.

Lastly, this expands the `Sparkle` tests to increase coverage. The
only untested parts are `#find_versions` (which currently
requires a network request) and a couple safeguard `raise` calls
when there's a `REXML::UndefinedNamespaceException` (which shouldn't
be encountered unless something is broken).
2022-06-01 18:29:37 -04:00
Issy Long
6b76fd012a
Fix (auto-correct) RuboCop RSpec/BeNil offenses 2022-03-01 00:10:10 +00:00
Sam Ford
9e8900fb6e
Allow regex to be passed into all strategy blocks
This modifies cask-related livecheck strategies to allow passing a
regex into a `strategy` block, when appropriate. These strategies
were outliers that explicitly rejected a regex even if a `strategy`
block was used, forcing any regex to be inlined in the `strategy`
block (instead of being defined using `#regex`).

With these changes, all `strategy` blocks will be able to accept a
regex, further simplifying the mental model. This also helps to
better align the various `find_versions` and `versions_from_*`
methods across strategies.
2021-11-19 23:58:54 -05:00
Sam Ford
7e07010f06
Improve standardization of strategy tests 2021-08-11 19:05:59 -04:00
Sam Ford
56dd89114d
Standardize valid strategy block return types
Valid `strategy` block return types currently vary between
strategies. Some only accept a string whereas others accept a string
or array of strings. [`strategy` blocks also accept a `nil` return
(to simplify early returns) but this was already standardized across
strategies.]

While some strategies only identify one version by default (where a
string is an appropriate return type), it could be that a strategy
block identifies more than one version. In this situation, the
strategy would need to be modified to accept (and work with) an
array from a `strategy` block.

Rather than waiting for this to become a problem, this modifies all
strategies to standardize on allowing `strategy` blocks to return a
string or array of strings (even if only one of these is currently
used in practice). Standardizing valid return types helps to further
simplify the mental model for `strategy` blocks and reduce cognitive
load.

This commit extracts related logic from `#find_versions` into
methods like `#versions_from_content`, which is conceptually similar
to `PageMatch#page_matches` (renamed to `#versions_from_content`
for consistency). This allows us to write tests for the related code
without having to make network requests (or stub them) at this point.
In general, this also helps to better align the structure of
strategies and how the various `#find_versions` methods work with
versions.

There's still more planned work to be done here but this is a step
in the right direction.
2021-08-11 19:05:57 -04:00
Markus Reiter
a210b1a04e
Add extract_plist strategy. 2021-04-07 04:58:31 +02:00
Sam Ford
99ea95c28d
Sparkle: Expand tests 2020-12-20 01:56:54 -05:00
Sam Ford
740d5d3bcd
Sparkle: Add test 2020-12-19 19:34:26 -05:00