Sha256: 73fa7b3a74598af4b00f5698a297e54619daac0c67e92e4c9e6972790acec90f

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

require 'playground_book_lint/manifest_linter'
require 'playground_book_lint/page_linter'

module PlaygroundBookLint
  class ChapterManifestLinter < ManifestLinter
    attr_accessor :page_linter

    def initialize(page_linter = PageLinter.new())
      @page_linter = page_linter
    end

    def lint
      super()

      fail_lint "Chapter has no pages in #{Dir.pwd}" unless chapter_has_manifest_pages?

      manifest_plist_contents['Pages'].each do |page_directory_name|
        # All pages exist inside the /Pages subdirectory, we need to chdir to there first.
        Dir.chdir PAGES_DIRECTORY_NAME do
          fail_lint "Chapter page directory #{page_directory_name} missing in #{Dir.pwd}" unless Dir.exist?(page_directory_name)
          
          Dir.chdir page_directory_name do
            page_linter.lint()
          end
        end
      end
    end

    def chapter_has_manifest_pages?
      value_defined_in_manifest?('Pages')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playground-book-lint-0.0.1 lib/playground_book_lint/chapter_manifest_linter.rb