Class: Archaeo::CoverageReport

Inherits:
Object
  • Object
show all
Defined in:
lib/archaeo/coverage_report.rb

Overview

Analyzes how thoroughly a site was archived by the Wayback Machine.

Produces coverage statistics including total URLs, archived URLs, coverage percentage, temporal gaps, and status distribution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, total_urls:, archived_urls:, status_distribution: {}, temporal_gaps: [], missing_assets: []) ⇒ CoverageReport

Returns a new instance of CoverageReport.



12
13
14
15
16
17
18
19
20
21
# File 'lib/archaeo/coverage_report.rb', line 12

def initialize(url:, total_urls:, archived_urls:,
               status_distribution: {}, temporal_gaps: [],
               missing_assets: [])
  @url = url
  @total_urls = total_urls
  @archived_urls = archived_urls
  @status_distribution = status_distribution
  @temporal_gaps = temporal_gaps
  @missing_assets = missing_assets
end

Instance Attribute Details

#archived_urlsObject (readonly)

Returns the value of attribute archived_urls.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def archived_urls
  @archived_urls
end

#missing_assetsObject (readonly)

Returns the value of attribute missing_assets.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def missing_assets
  @missing_assets
end

#status_distributionObject (readonly)

Returns the value of attribute status_distribution.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def status_distribution
  @status_distribution
end

#temporal_gapsObject (readonly)

Returns the value of attribute temporal_gaps.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def temporal_gaps
  @temporal_gaps
end

#total_urlsObject (readonly)

Returns the value of attribute total_urls.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def total_urls
  @total_urls
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/archaeo/coverage_report.rb', line 9

def url
  @url
end

Instance Method Details

#as_jsonObject



50
51
52
# File 'lib/archaeo/coverage_report.rb', line 50

def as_json(*)
  to_h
end

#coverage_percentObject



23
24
25
26
27
# File 'lib/archaeo/coverage_report.rb', line 23

def coverage_percent
  return 0.0 if total_urls.zero?

  (archived_urls.to_f / total_urls * 100).round(1)
end

#has_gaps?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/archaeo/coverage_report.rb', line 33

def has_gaps?
  !temporal_gaps.empty?
end

#missing_countObject



29
30
31
# File 'lib/archaeo/coverage_report.rb', line 29

def missing_count
  total_urls - archived_urls
end

#to_hObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/archaeo/coverage_report.rb', line 37

def to_h
  {
    url: @url,
    total_urls: @total_urls,
    archived_urls: @archived_urls,
    coverage_percent: coverage_percent,
    missing_count: missing_count,
    status_distribution: @status_distribution,
    temporal_gaps: @temporal_gaps,
    missing_assets: @missing_assets,
  }
end