class Caramelize::HealthChecks::OrphanedPagesCheck

Attributes

all_intra_wiki_paths[R]
gollum[R]
intra_wiki_paths[R]

Public Class Methods

new(gollum) click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 8
def initialize(gollum)
  @gollum = gollum
  @intra_wiki_paths = []
  @all_intra_wiki_paths = []
end

Public Instance Methods

check() click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 14
def check
  puts "\n # Pages not linked within Wiki:"
  puts page_paths_without_intra_wiki_path.sort.inspect
end

Private Instance Methods

check_page(page) click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 21
def check_page(page)
  0.tap do |available_count|
    page.intra_wiki_links.each do |intra_wiki_path|
      if page_paths.include?(intra_wiki_path)
        available_count += 1
        intra_wiki_paths << intra_wiki_path
      else
        puts "#{intra_wiki_path} expected, but missing"
      end
    end
    puts "#{available_count}/#{intra_wiki_links.count} available"
  end
end
check_pages() click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 39
def check_pages
  pages.map do |page|
    check_page(page)
  end
end
page_paths() click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 35
def page_paths
  pages.map(&:path).map { |path| path.split('.').first }
end
page_paths_without_intra_wiki_path() click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 51
def page_paths_without_intra_wiki_path
  page_paths - intra_wiki_paths
end
pages() click to toggle source
# File lib/caramelize/health_checks/orphaned_pages_check.rb, line 45
def pages
  @pages ||= gollum.pages.map do |gollum_page|
    HealthChecks::Page.new(gollum_page)
  end
end