Sha256: bcddb19357e6fe7848e33944cbc80fb7a383b11e8f643423aa29d7e31f6de611

Contents?: true

Size: 951 Bytes

Versions: 7

Compression:

Stored size: 951 Bytes

Contents

require "plist"
require "linter/manifest_linter"
require "linter/chapter_linter"

module Playgroundbook
  # A linter for verifying the contents of a playground book's root manifest
  class RootManifestLinter < ManifestLinter
    attr_accessor :chapter_linter

    def initialize(chapter_linter = ChapterLinter.new)
      @chapter_linter = chapter_linter
    end

    def lint
      super()

      fail_lint "No Chapters directory" unless chapters_directory_exist?
      fail_lint "No Chapters specified" unless chapters_exist?

      # Go into Chapters/ and then each chapter directory, then lint it.
      Dir.chdir "Chapters" do
        manifest_plist_contents["Chapters"].each do |chapter_directory_name|
          chapter_linter.lint(chapter_directory_name)
        end
      end
    end

    def chapters_directory_exist?
      Dir.exist? "Chapters"
    end

    def chapters_exist?
      value_defined_in_manifest?("Chapters")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
playgroundbook-1.2.0 lib/linter/root_manifest_linter.rb
playgroundbook-1.1.1 lib/linter/root_manifest_linter.rb
playgroundbook-1.1.0 lib/linter/root_manifest_linter.rb
playgroundbook-1.0.0 lib/linter/root_manifest_linter.rb
playgroundbook-0.6.0 lib/linter/root_manifest_linter.rb
playgroundbook-0.5.0 lib/linter/root_manifest_linter.rb
playgroundbook-0.4.0 lib/linter/root_manifest_linter.rb