Class: Archaeo::CoverageAnalyzer
- Inherits:
-
Object
- Object
- Archaeo::CoverageAnalyzer
- Defined in:
- lib/archaeo/coverage_analyzer.rb
Overview
Builds a CoverageReport from CDX snapshot data.
Instance Method Summary collapse
- #analyze(url, from: nil, to: nil) ⇒ Object
-
#initialize(cdx_api: nil) ⇒ CoverageAnalyzer
constructor
A new instance of CoverageAnalyzer.
Constructor Details
#initialize(cdx_api: nil) ⇒ CoverageAnalyzer
Returns a new instance of CoverageAnalyzer.
6 7 8 |
# File 'lib/archaeo/coverage_analyzer.rb', line 6 def initialize(cdx_api: nil) @cdx_api = cdx_api end |
Instance Method Details
#analyze(url, from: nil, to: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/archaeo/coverage_analyzer.rb', line 10 def analyze(url, from: nil, to: nil) cdx = @cdx_api || CdxApi.new snapshots = cdx.snapshots(url, from: from, to: to).to_a unique_urls = snapshots.map(&:original_url).uniq status_dist = compute_status_distribution(snapshots) gaps = compute_temporal_gaps(snapshots) CoverageReport.new( url: url, total_urls: unique_urls.size, archived_urls: snapshots.count(&:success?), status_distribution: status_dist, temporal_gaps: gaps, ) end |