Livecheck: Surface cached status in debug output
This commit is contained in:
		
							parent
							
								
									8b5e334be4
								
							
						
					
					
						commit
						d7fa400930
					
				@ -526,6 +526,7 @@ module Homebrew
 | 
			
		||||
          puts "URL (strategy):   #{strategy_data[:url]}" if strategy_data[:url] != url
 | 
			
		||||
          puts "URL (final):      #{strategy_data[:final_url]}" if strategy_data[:final_url]
 | 
			
		||||
          puts "Regex (strategy): #{strategy_data[:regex].inspect}" if strategy_data[:regex] != livecheck_regex
 | 
			
		||||
          puts "Cached?:          Yes" if strategy_data[:cached] == true
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        match_version_map.delete_if do |_match, version|
 | 
			
		||||
@ -568,6 +569,7 @@ module Homebrew
 | 
			
		||||
          version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
 | 
			
		||||
          version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] } if strategies.present?
 | 
			
		||||
          version_info[:meta][:regex] = regex.inspect if regex.present?
 | 
			
		||||
          version_info[:meta][:cached] = true if strategy_data[:cached] == true
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        return version_info
 | 
			
		||||
 | 
			
		||||
@ -89,6 +89,7 @@ module Homebrew
 | 
			
		||||
          match_data = { matches: {}, regex: regex, url: url }
 | 
			
		||||
 | 
			
		||||
          content = if provided_content.is_a?(String)
 | 
			
		||||
            match_data[:cached] = true
 | 
			
		||||
            provided_content
 | 
			
		||||
          else
 | 
			
		||||
            match_data.merge!(Strategy.page_content(url))
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,7 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let(:page_content_matches) { ["2.6.0", "2.5.0", "2.4.0", "2.3.0", "2.2.0", "2.1.0", "2.0.0", "1.9.0"] }
 | 
			
		||||
 | 
			
		||||
  let(:find_versions_return_hash) {
 | 
			
		||||
    {
 | 
			
		||||
      matches: {
 | 
			
		||||
@ -53,6 +54,12 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let(:find_versions_cached_return_hash) {
 | 
			
		||||
    return_hash = find_versions_return_hash
 | 
			
		||||
    return_hash[:cached] = true
 | 
			
		||||
    return_hash
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  describe "::match?" do
 | 
			
		||||
    it "returns true for any URL" do
 | 
			
		||||
      expect(page_match.match?(url)).to be true
 | 
			
		||||
@ -72,7 +79,7 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
 | 
			
		||||
 | 
			
		||||
  describe "::find_versions?" do
 | 
			
		||||
    it "finds versions in provided_content" do
 | 
			
		||||
      expect(page_match.find_versions(url, regex, page_content)).to eq(find_versions_return_hash)
 | 
			
		||||
      expect(page_match.find_versions(url, regex, page_content)).to eq(find_versions_cached_return_hash)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user