459 lines
18 KiB
Ruby
Raw Normal View History

2020-12-19 01:11:45 -05:00
# frozen_string_literal: true
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-10 11:09:55 -04:00
require "livecheck/strategy"
require "bundle_version"
2020-12-19 01:11:45 -05:00
RSpec.describe Homebrew::Livecheck::Strategy::Sparkle do
2020-12-19 01:11:45 -05:00
subject(:sparkle) { described_class }
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-10-22 12:25:53 -04:00
def create_appcast_xml(items_str = "")
<<~EOS
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<channel>
<title>Example Changelog</title>
<link>#{appcast_url}</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
#{items_str}
</channel>
</rss>
EOS
end
let(:appcast_url) { "https://www.example.com/example/appcast.xml" }
let(:non_http_url) { "ftp://brew.sh/" }
2020-12-19 01:11:45 -05:00
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-10-22 12:25:53 -04:00
# The `item_hashes` data is used to create test appcast XML and expected
# `Sparkle::Item` objects.
let(:item_hashes) do
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-10-22 12:25:53 -04:00
{
# The 1.2.4 version is only used in tests as the basis for an item that
# should be excluded (after modifications).
v124: {
title: "Version 1.2.4",
release_notes_link: "https://www.example.com/example/1.2.4.html",
pub_date: "Fri, 02 Jan 2021 01:23:45 +0000",
url: "https://www.example.com/example/example-1.2.4.tar.gz",
short_version: "1.2.4",
version: "124",
minimum_system_version: "10.10",
},
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-10-22 12:25:53 -04:00
v123: {
title: "Version 1.2.3",
release_notes_link: "https://www.example.com/example/1.2.3.html",
pub_date: "Fri, 01 Jan 2021 01:23:45 +0000",
url: "https://www.example.com/example/example-1.2.3.tar.gz",
short_version: "1.2.3",
version: "123",
minimum_system_version: "10.10",
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-05-31 13:18:40 -04:00
},
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-10-22 12:25:53 -04:00
v122: {
title: "Version 1.2.2",
release_notes_link: "https://www.example.com/example/1.2.2.html",
pub_date: "Not a parseable date string",
link: "https://www.example.com/example/example-1.2.2.tar.gz",
short_version: "1.2.2",
version: "122",
minimum_system_version: "10.10",
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-05-31 13:18:40 -04:00
},
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-10-22 12:25:53 -04:00
v121: {
title: "Version 1.2.1",
release_notes_link: "https://www.example.com/example/1.2.1.html",
pub_date: "Thu, 31 Dec 2020 01:23:45 +0000",
os: "osx",
url: "https://www.example.com/example/example-1.2.1.tar.gz",
short_version: "1.2.1",
version: "121",
minimum_system_version: "10.10",
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-10-22 12:25:53 -04:00
},
v120: {
title: "Version 1.2.0",
release_notes_link: "https://www.example.com/example/1.2.0.html",
pub_date: "Wed, 30 Dec 2020 01:23:45 +0000",
os: "macos",
url: "https://www.example.com/example/example-1.2.0.tar.gz",
short_version: "1.2.0",
version: "120",
minimum_system_version: "10.10",
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-10-22 12:25:53 -04:00
},
}
end
2020-12-20 01:56:54 -05:00
let(:xml) do
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-10-22 12:25:53 -04:00
v123_item = <<~EOS
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-05-31 13:18:40 -04:00
<item>
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-10-22 12:25:53 -04:00
<title>#{item_hashes[:v123][:title]}</title>
<sparkle:minimumSystemVersion>#{item_hashes[:v123][:minimum_system_version]}</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>#{item_hashes[:v123][:release_notes_link]}</sparkle:releaseNotesLink>
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-10-22 12:25:53 -04:00
<pubDate>#{item_hashes[:v123][:pub_date]}</pubDate>
<enclosure url="#{item_hashes[:v123][:url]}" sparkle:shortVersionString="#{item_hashes[:v123][:short_version]}" sparkle:version="#{item_hashes[:v123][:version]}" length="12345678" type="application/octet-stream" sparkle:dsaSignature="ABCDEF+GHIJKLMNOPQRSTUVWXYZab/cdefghijklmnopqrst/uvwxyz1234567==" />
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-05-31 13:18:40 -04:00
</item>
EOS
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-10-22 12:25:53 -04:00
v122_item = <<~EOS
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-05-31 13:18:40 -04:00
<item>
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-10-22 12:25:53 -04:00
<title>#{item_hashes[:v122][:title]}</title>
<link>#{item_hashes[:v122][:link]}</link>
<sparkle:minimumSystemVersion>#{item_hashes[:v122][:minimum_system_version]}</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>#{item_hashes[:v122][:release_notes_link]}</sparkle:releaseNotesLink>
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-10-22 12:25:53 -04:00
<pubDate>#{item_hashes[:v122][:pub_date]}</pubDate>
<sparkle:version>#{item_hashes[:v122][:version]}</sparkle:version>
<sparkle:shortVersionString>#{item_hashes[:v122][:short_version]}</sparkle:shortVersionString>
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-05-31 13:18:40 -04:00
</item>
EOS
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-10-22 12:25:53 -04:00
v121_item_with_osx_os = <<~EOS
2022-06-02 10:36:33 -04:00
<item>
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-10-22 12:25:53 -04:00
<title>#{item_hashes[:v121][:title]}</title>
<sparkle:minimumSystemVersion>#{item_hashes[:v121][:minimum_system_version]}</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>#{item_hashes[:v121][:release_notes_link]}</sparkle:releaseNotesLink>
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-10-22 12:25:53 -04:00
<pubDate>#{item_hashes[:v121][:pub_date]}</pubDate>
<enclosure os="#{item_hashes[:v121][:os]}" url="#{item_hashes[:v121][:url]}" sparkle:shortVersionString="#{item_hashes[:v121][:short_version]}" sparkle:version="#{item_hashes[:v121][:version]}" length="12345678" type="application/octet-stream" sparkle:dsaSignature="ABCDEF+GHIJKLMNOPQRSTUVWXYZab/cdefghijklmnopqrst/uvwxyz1234567==" />
2022-06-02 10:36:33 -04:00
</item>
EOS
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-10-22 12:25:53 -04:00
v120_item_with_macos_os = <<~EOS
<item>
<title>#{item_hashes[:v120][:title]}</title>
<sparkle:minimumSystemVersion>#{item_hashes[:v120][:minimum_system_version]}</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>#{item_hashes[:v120][:release_notes_link]}</sparkle:releaseNotesLink>
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-10-22 12:25:53 -04:00
<pubDate>#{item_hashes[:v120][:pub_date]}</pubDate>
<enclosure os="#{item_hashes[:v120][:os]}" url="#{item_hashes[:v120][:url]}" sparkle:shortVersionString="#{item_hashes[:v120][:short_version]}" sparkle:version="#{item_hashes[:v120][:version]}" length="12345678" type="application/octet-stream" sparkle:dsaSignature="ABCDEF+GHIJKLMNOPQRSTUVWXYZab/cdefghijklmnopqrst/uvwxyz1234567==" />
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-10-22 12:25:53 -04:00
</item>
2020-12-20 01:56:54 -05:00
EOS
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-05-31 13:18:40 -04:00
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-10-22 12:25:53 -04:00
# This main `appcast` data is intended as a relatively normal example.
# As such, it also serves as a base for some other test data.
appcast = create_appcast_xml <<~EOS
#{v123_item}
#{v122_item}
#{v121_item_with_osx_os}
#{v120_item_with_macos_os}
EOS
omitted_items = create_appcast_xml <<~EOS
#{v123_item.sub(%r{<(enclosure[^>]+?)\s*?/>}, '<\1 os="not-osx-or-macos" />')}
#{v123_item.sub(/(<sparkle:minimumSystemVersion>)[^<]+?</m, '\1100<')}
<item>
</item>
EOS
# Set the first item in a copy of `appcast` to a bad `minimumSystemVersion`
# value, to test `MacOSVersion::Error` handling.
bad_macos_version = appcast.sub(
v123_item,
v123_item.sub(
/(<sparkle:minimumSystemVersion>)[^<]+?</m,
'\1Not a macOS version<',
),
)
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-10-22 12:25:53 -04:00
# Set the first item in a copy of `appcast` to the "beta" channel, to test
# filtering items by channel using a `strategy` block.
2022-06-02 10:36:33 -04:00
beta_channel_item = appcast.sub(
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-10-22 12:25:53 -04:00
v123_item,
v123_item.sub(
"</title>",
"</title>\n<sparkle:channel>beta</sparkle:channel>",
),
)
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-10-22 12:25:53 -04:00
no_versions_item = create_appcast_xml <<~EOS
<item>
<title>Version</title>
<sparkle:minimumSystemVersion>#{item_hashes[:v123][:minimum_system_version]}</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>#{item_hashes[:v123][:release_notes_link]}</sparkle:releaseNotesLink>
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-10-22 12:25:53 -04:00
<pubDate>#{item_hashes[:v123][:pub_date]}</pubDate>
<enclosure url="#{item_hashes[:v123][:url]}" length="12345678" type="application/octet-stream" sparkle:dsaSignature="ABCDEF+GHIJKLMNOPQRSTUVWXYZab/cdefghijklmnopqrst/uvwxyz1234567==" />
</item>
EOS
no_items = create_appcast_xml
undefined_namespace = appcast.sub(/\s*xmlns:sparkle="[^"]+"/, "")
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-05-31 13:18:40 -04:00
{
2022-06-02 10:36:33 -04:00
appcast: appcast,
omitted_items: omitted_items,
bad_macos_version: bad_macos_version,
2022-06-02 10:36:33 -04:00
beta_channel_item: beta_channel_item,
no_versions_item: no_versions_item,
no_items: no_items,
undefined_namespace: undefined_namespace,
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-05-31 13:18:40 -04:00
}
end
2020-12-20 01:56:54 -05:00
let(:title_regex) { /Version\s+v?(\d+(?:\.\d+)+)\s*$/i }
let(:items) do
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-10-22 12:25:53 -04:00
{
v124: Homebrew::Livecheck::Strategy::Sparkle::Item.new(
title: item_hashes[:v124][:title],
release_notes_link: item_hashes[:v124][:release_notes_link],
pub_date: Time.parse(item_hashes[:v124][:pub_date]),
url: item_hashes[:v124][:url],
bundle_version: Homebrew::BundleVersion.new(
item_hashes[:v124][:short_version],
item_hashes[:v124][:version],
),
minimum_system_version: MacOSVersion.new(item_hashes[:v124][:minimum_system_version]),
),
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-10-22 12:25:53 -04:00
v123: Homebrew::Livecheck::Strategy::Sparkle::Item.new(
title: item_hashes[:v123][:title],
release_notes_link: item_hashes[:v123][:release_notes_link],
pub_date: Time.parse(item_hashes[:v123][:pub_date]),
url: item_hashes[:v123][:url],
bundle_version: Homebrew::BundleVersion.new(
item_hashes[:v123][:short_version],
item_hashes[:v123][:version],
),
minimum_system_version: MacOSVersion.new(item_hashes[:v123][:minimum_system_version]),
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-10-22 12:25:53 -04:00
),
v122: Homebrew::Livecheck::Strategy::Sparkle::Item.new(
title: item_hashes[:v122][:title],
link: item_hashes[:v122][:link],
release_notes_link: item_hashes[:v122][:release_notes_link],
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-10-22 12:25:53 -04:00
# `#items_from_content` falls back to a default `pub_date` when
# one isn't provided or can't be successfully parsed.
pub_date: Time.new(0),
url: item_hashes[:v122][:link],
bundle_version: Homebrew::BundleVersion.new(
item_hashes[:v122][:short_version],
item_hashes[:v122][:version],
),
minimum_system_version: MacOSVersion.new(item_hashes[:v122][:minimum_system_version]),
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-10-22 12:25:53 -04:00
),
v121: Homebrew::Livecheck::Strategy::Sparkle::Item.new(
title: item_hashes[:v121][:title],
release_notes_link: item_hashes[:v121][:release_notes_link],
pub_date: Time.parse(item_hashes[:v121][:pub_date]),
os: item_hashes[:v121][:os],
url: item_hashes[:v121][:url],
bundle_version: Homebrew::BundleVersion.new(
item_hashes[:v121][:short_version],
item_hashes[:v121][:version],
),
minimum_system_version: MacOSVersion.new(item_hashes[:v121][:minimum_system_version]),
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-10-22 12:25:53 -04:00
),
v120: Homebrew::Livecheck::Strategy::Sparkle::Item.new(
title: item_hashes[:v120][:title],
release_notes_link: item_hashes[:v120][:release_notes_link],
pub_date: Time.parse(item_hashes[:v120][:pub_date]),
os: item_hashes[:v120][:os],
url: item_hashes[:v120][:url],
bundle_version: Homebrew::BundleVersion.new(
item_hashes[:v120][:short_version],
item_hashes[:v120][:version],
),
minimum_system_version: MacOSVersion.new(item_hashes[:v120][:minimum_system_version]),
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-10-22 12:25:53 -04:00
),
}
end
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-10-22 12:25:53 -04:00
let(:item_arrays) do
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-10-22 12:25:53 -04:00
item_arrays = {
appcast: [
items[:v123],
items[:v122],
items[:v121],
items[:v120],
],
appcast_sorted: [
items[:v123],
items[:v121],
items[:v120],
items[:v122],
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-05-31 13:18:40 -04:00
],
}
bad_macos_version_item = items[:v123].clone
bad_macos_version_item.minimum_system_version = nil
item_arrays[:bad_macos_version] = [
bad_macos_version_item,
items[:v122],
items[:v121],
items[:v120],
]
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-10-22 12:25:53 -04:00
beta_channel_item = items[:v123].clone
beta_channel_item.channel = "beta"
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-10-22 12:25:53 -04:00
item_arrays[:beta_channel_item] = [
beta_channel_item,
items[:v122],
items[:v121],
items[:v120],
]
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-10-22 12:25:53 -04:00
no_versions_item = items[:v123].clone
2022-06-02 10:36:33 -04:00
no_versions_item.title = "Version"
no_versions_item.bundle_version = nil
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-10-22 12:25:53 -04:00
item_arrays[:no_versions_item] = [no_versions_item]
2022-06-02 10:36:33 -04:00
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-10-22 12:25:53 -04:00
item_arrays
end
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-10 11:09:55 -04:00
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-10-22 12:25:53 -04:00
let(:versions) { [items[:v123].nice_version] }
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-10 11:09:55 -04:00
2020-12-19 01:11:45 -05:00
describe "::match?" do
it "returns true for an HTTP URL" do
expect(sparkle.match?(appcast_url)).to be true
end
it "returns false for a non-HTTP URL" do
expect(sparkle.match?(non_http_url)).to be false
2020-12-19 01:11:45 -05:00
end
end
2020-12-20 01:56:54 -05:00
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-05-31 13:18:40 -04:00
describe "::items_from_content" do
2022-06-02 10:36:33 -04:00
let(:items_from_appcast) { sparkle.items_from_content(xml[:appcast]) }
2020-12-20 01:56:54 -05:00
it "returns nil if content is blank" do
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-05-31 13:18:40 -04:00
expect(sparkle.items_from_content("")).to eq([])
2020-12-20 01:56:54 -05:00
end
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-05-31 13:18:40 -04:00
it "returns an array of Items when given XML data" do
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-10-22 12:25:53 -04:00
expect(items_from_appcast).to eq(item_arrays[:appcast])
expect(items_from_appcast[0].title).to eq(item_hashes[:v123][:title])
expect(items_from_appcast[0].pub_date).to eq(Time.parse(item_hashes[:v123][:pub_date]))
expect(items_from_appcast[0].url).to eq(item_hashes[:v123][:url])
expect(items_from_appcast[0].short_version).to eq(item_hashes[:v123][:short_version])
expect(items_from_appcast[0].version).to eq(item_hashes[:v123][:version])
expect(sparkle.items_from_content(xml[:bad_macos_version])).to eq(item_arrays[:bad_macos_version])
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-10-22 12:25:53 -04:00
expect(sparkle.items_from_content(xml[:beta_channel_item])).to eq(item_arrays[:beta_channel_item])
expect(sparkle.items_from_content(xml[:no_versions_item])).to eq(item_arrays[:no_versions_item])
2020-12-20 01:56:54 -05:00
end
end
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-10 11:09:55 -04:00
describe "::filter_items" do
let(:items_non_mac_os) do
item = items[:v124].clone
item.os = "not-osx-or-macos"
item_arrays[:appcast] + [item]
end
let(:items_prerelease_minimum_system_version) do
item = items[:v124].clone
item.minimum_system_version = MacOSVersion.new("100")
item_arrays[:appcast] + [item]
end
it "removes items with a non-mac OS" do
expect(sparkle.filter_items(items_non_mac_os)).to eq(item_arrays[:appcast])
end
it "removes items with a prerelease minimumSystemVersion" do
expect(sparkle.filter_items(items_prerelease_minimum_system_version)).to eq(item_arrays[:appcast])
end
end
describe "::sort_items" do
it "returns a sorted array of items" do
expect(sparkle.sort_items(item_arrays[:appcast])).to eq(item_arrays[:appcast_sorted])
end
end
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-10-22 12:25:53 -04:00
# `#versions_from_content` sorts items by `pub_date` and `bundle_version`, so
# these tests have to account for this behavior in the expected output.
# For example, the version 122 item doesn't have a parseable `pub_date` and
# the substituted default will cause it to be sorted last.
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-10 11:09:55 -04:00
describe "::versions_from_content" do
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-10-22 12:25:53 -04:00
let(:subbed_items) { item_arrays[:appcast_sorted].map { |item| item.nice_version.sub("1", "0") } }
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-05-31 13:18:40 -04:00
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-10 11:09:55 -04:00
it "returns an array of version strings when given content" do
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-05-31 13:18:40 -04:00
expect(sparkle.versions_from_content(xml[:appcast])).to eq(versions)
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-10-22 12:25:53 -04:00
expect(sparkle.versions_from_content(xml[:omitted_items])).to eq([])
expect(sparkle.versions_from_content(xml[:beta_channel_item])).to eq(versions)
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-05-31 13:18:40 -04:00
expect(sparkle.versions_from_content(xml[:no_versions_item])).to eq([])
expect(sparkle.versions_from_content(xml[:undefined_namespace])).to eq(versions)
end
it "returns an empty array if no items are found" do
expect(sparkle.versions_from_content(xml[:no_items])).to eq([])
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-10 11:09:55 -04:00
end
it "returns an array of version strings when given content and a block" do
# Returning a string from block
expect(
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-05-31 13:18:40 -04:00
sparkle.versions_from_content(xml[:appcast]) do |item|
item.nice_version&.sub("1", "0")
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-10 11:09:55 -04:00
end,
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-05-31 13:18:40 -04:00
).to eq([subbed_items[0]])
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-10 11:09:55 -04:00
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-05-31 13:18:40 -04:00
# Returning an array of strings from block
expect(
sparkle.versions_from_content(xml[:appcast]) do |items|
items.map { |item| item.nice_version&.sub("1", "0") }
end,
).to eq(subbed_items)
expect(
sparkle.versions_from_content(xml[:beta_channel_item]) do |items|
items.find { |item| item.channel.nil? }&.nice_version
end,
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-10-22 12:25:53 -04:00
).to eq([items[:v121].nice_version])
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-10 11:09:55 -04:00
end
it "returns an array of version strings when given content, a regex, and a block" do
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-05-31 13:18:40 -04:00
# Returning a string from the block
expect(
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-05-31 13:18:40 -04:00
sparkle.versions_from_content(xml[:appcast], title_regex) do |item, regex|
item.title[regex, 1]
end,
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-10-22 12:25:53 -04:00
).to eq([item_hashes[:v123][:short_version]])
expect(
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-05-31 13:18:40 -04:00
sparkle.versions_from_content(xml[:appcast], title_regex) do |items, regex|
next if (item = items[0]).blank?
match = item&.title&.match(regex)
next if match.blank?
"#{match[1]},#{item.version}"
end,
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-10-22 12:25:53 -04:00
).to eq(["#{item_hashes[:v123][:short_version]},#{item_hashes[:v123][:version]}"])
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-05-31 13:18:40 -04:00
# Returning an array of strings from the block
expect(
sparkle.versions_from_content(xml[:appcast], title_regex) do |item, regex|
[item.title[regex, 1]]
end,
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-10-22 12:25:53 -04:00
).to eq([item_hashes[:v123][:short_version]])
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-05-31 13:18:40 -04:00
expect(
sparkle.versions_from_content(xml[:appcast], &:short_version),
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-10-22 12:25:53 -04:00
).to eq([item_hashes[:v123][:short_version]])
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-05-31 13:18:40 -04:00
expect(
sparkle.versions_from_content(xml[:appcast], title_regex) do |items, regex|
items.map { |item| item.title[regex, 1] }
end,
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-10-22 12:25:53 -04:00
).to eq(item_arrays[:appcast_sorted].map(&:short_version))
end
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-10 11:09:55 -04:00
it "allows a nil return from a block" do
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-05-31 13:18:40 -04:00
expect(
sparkle.versions_from_content(xml[:appcast]) do |item|
_ = item # To appease `brew style` without modifying arg name
next
end,
).to eq([])
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-10 11:09:55 -04:00
end
it "errors on an invalid return type from a block" do
expect do
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-05-31 13:18:40 -04:00
sparkle.versions_from_content(xml[:appcast]) do |item|
_ = item # To appease `brew style` without modifying arg name
123
end
end.to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG)
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-05-31 13:18:40 -04:00
end
it "errors if the first block argument uses an unhandled name" do
expect { sparkle.versions_from_content(xml[:appcast]) { |something| something } }
.to raise_error("First argument of Sparkle `strategy` block must be `item` or `items`")
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-10 11:09:55 -04:00
end
end
2020-12-19 01:11:45 -05:00
end