class Caramelize::HealthCheck

Constants

DEFAULT_GOLLUM_HOME_TITLE

Attributes

options[R]
wiki_path[R]

Public Class Methods

new(wiki_path, options={}) click to toggle source
# File lib/caramelize/health_check.rb, line 7
def initialize(wiki_path, options={})
  @wiki_path = wiki_path
  @options = options
end

Public Instance Methods

execute() click to toggle source
# File lib/caramelize/health_check.rb, line 12
def execute
  #puts page_paths.sort.inspect

  check_pages

  #puts intra_wiki_paths.sort.inspect

  puts "\n # Pages not linked within Wiki:"
  puts page_paths_without_intra_wiki_path.sort.inspect
end

Private Instance Methods

check_home_page() click to toggle source
# File lib/caramelize/health_check.rb, line 77
def check_home_page
  puts "Home.md missing" if File.exist?('wiki-export/Home.md')
end
check_page(page) click to toggle source
# File lib/caramelize/health_check.rb, line 42
def check_page(page)
  intra_wiki_links = intra_wiki_links(page.text_data)
  available = 0
  intra_wiki_links.each do |link|
    intra_wiki_link = page.path.split('/').first == page.path ? link : [page.path.split('/').first, link].join('/')
    if !page_paths.include?(intra_wiki_link)
      puts "#{intra_wiki_link} expected, but missing"
    else
      available += 1
      intra_wiki_paths << intra_wiki_link
    end
  end
  puts "#{available}/#{intra_wiki_links.count} available"
end
check_pages() click to toggle source
# File lib/caramelize/health_check.rb, line 35
def check_pages
  pages.each do |page|
    puts "\n## #{page.path}"
    check_page(page)
  end
end
file_names() click to toggle source
# File lib/caramelize/health_check.rb, line 29
def file_names
  files.map do |file|
    file.gsub("#{wiki_path}/", '').split('.').first
  end
end
files() click to toggle source
# File lib/caramelize/health_check.rb, line 25
def files
  @files ||= Dir.glob([wiki_path, '**/*.md'].join('/'))
end
gollum() click to toggle source
# File lib/caramelize/health_check.rb, line 81
def gollum
  @gollum ||= ::Gollum::Wiki.new(wiki_path)
end
intra_wiki_paths() click to toggle source
# File lib/caramelize/health_check.rb, line 69
def intra_wiki_paths
  @intra_wiki_paths ||= []
end
page_paths() click to toggle source
# File lib/caramelize/health_check.rb, line 65
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_check.rb, line 73
def page_paths_without_intra_wiki_path
  page_paths - intra_wiki_paths
end
pages() click to toggle source
# File lib/caramelize/health_check.rb, line 61
def pages
  gollum.pages
end