Class: Playgroundbook::ChapterManifestLinter
- Inherits:
-
ManifestLinter
- Object
- AbstractLinter
- ManifestLinter
- Playgroundbook::ChapterManifestLinter
- Defined in:
- lib/linter/chapter_manifest_linter.rb
Overview
A linter for verifying the contents of a chapter’s Manifest.plist
Instance Attribute Summary collapse
-
#cutscene_page_linter ⇒ Object
Returns the value of attribute cutscene_page_linter.
-
#page_linter ⇒ Object
Returns the value of attribute page_linter.
Instance Method Summary collapse
- #chapter_has_manifest_pages? ⇒ Boolean
-
#initialize(page_linter = PageLinter.new, cutscene_page_linter = CutscenePageLinter.new) ⇒ ChapterManifestLinter
constructor
A new instance of ChapterManifestLinter.
- #lint ⇒ Object
- #lint_page(page_directory_name) ⇒ Object
Methods inherited from ManifestLinter
#manifest_file_exists?, #manifest_plist_contents, #name?, #value_defined_in_manifest?
Methods inherited from AbstractLinter
Constructor Details
#initialize(page_linter = PageLinter.new, cutscene_page_linter = CutscenePageLinter.new) ⇒ ChapterManifestLinter
Returns a new instance of ChapterManifestLinter.
10 11 12 13 |
# File 'lib/linter/chapter_manifest_linter.rb', line 10 def initialize(page_linter = PageLinter.new, cutscene_page_linter = CutscenePageLinter.new) @page_linter = page_linter @cutscene_page_linter = cutscene_page_linter end |
Instance Attribute Details
#cutscene_page_linter ⇒ Object
Returns the value of attribute cutscene_page_linter.
8 9 10 |
# File 'lib/linter/chapter_manifest_linter.rb', line 8 def cutscene_page_linter @cutscene_page_linter end |
#page_linter ⇒ Object
Returns the value of attribute page_linter.
8 9 10 |
# File 'lib/linter/chapter_manifest_linter.rb', line 8 def page_linter @page_linter end |
Instance Method Details
#chapter_has_manifest_pages? ⇒ Boolean
39 40 41 |
# File 'lib/linter/chapter_manifest_linter.rb', line 39 def chapter_has_manifest_pages? value_defined_in_manifest?("Pages") end |
#lint ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/linter/chapter_manifest_linter.rb', line 15 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) lint_page page_directory_name end end end |
#lint_page(page_directory_name) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/linter/chapter_manifest_linter.rb', line 29 def lint_page(page_directory_name) Dir.chdir page_directory_name do if page_directory_name =~ /.+\.playgroundpage$/ page_linter.lint elsif page_directory_name =~ /.+\.cutscenepage$/ cutscene_page_linter.lint end end end |