Class: Playgroundbook::ChapterLinter

Inherits:
AbstractLinter show all
Defined in:
lib/linter/chapter_linter.rb

Overview

A linter for verifying a chapter directory

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractLinter

#fail_lint, #message

Constructor Details

#initialize(chapter_manifest_linter = ChapterManifestLinter.new) ⇒ ChapterLinter

Returns a new instance of ChapterLinter.



12
13
14
# File 'lib/linter/chapter_linter.rb', line 12

def initialize(chapter_manifest_linter = ChapterManifestLinter.new)
  @chapter_manifest_linter = chapter_manifest_linter
end

Instance Attribute Details

#chapter_manifest_linterObject

Returns the value of attribute chapter_manifest_linter.



10
11
12
# File 'lib/linter/chapter_linter.rb', line 10

def chapter_manifest_linter
  @chapter_manifest_linter
end

Instance Method Details

#chapter_directory_exists?(chapter_directory_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/linter/chapter_linter.rb', line 26

def chapter_directory_exists?(chapter_directory_name)
  Dir.exist? chapter_directory_name
end

#lint(chapter_directory_name) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/linter/chapter_linter.rb', line 16

def lint(chapter_directory_name)
  fail_lint "Chapter specified in manifest does not exist: #{chapter_directory_name}." unless chapter_directory_exists?(chapter_directory_name)

  Dir.chdir chapter_directory_name do
    fail_lint "Pages directory in chapter does not exist: #{chapter_directory_name}." unless pages_directory_exists?

    chapter_manifest_linter.lint
  end
end

#pages_directory_exists?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/linter/chapter_linter.rb', line 30

def pages_directory_exists?
  Dir.exist? PAGES_DIRECTORY_NAME
end