Class: Playgroundbook::Linter

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

Overview

A linter for verifying a playground book

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractLinter

#fail_lint, #message

Constructor Details

#initialize(playground_file_name, contents_linter = ContentsLinter.new) ⇒ Linter

Returns a new instance of Linter.



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

def initialize(playground_file_name, contents_linter = ContentsLinter.new)
  @playground_file_name = playground_file_name
  @contents_linter = contents_linter
end

Instance Attribute Details

#contents_linterObject

Returns the value of attribute contents_linter.



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

def contents_linter
  @contents_linter
end

#playground_file_nameObject

Returns the value of attribute playground_file_name.



9
10
11
# File 'lib/linter/playgroundbook_lint.rb', line 9

def playground_file_name
  @playground_file_name
end

Instance Method Details

#contents_dir_exists?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/linter/playgroundbook_lint.rb', line 27

def contents_dir_exists?
  Dir.exist?(playground_file_name + "/Contents")
end

#lintObject



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

def lint
  message "Validating #{playground_file_name.yellow}..."

  fail_lint "No Contents directory" unless contents_dir_exists?

  Dir.chdir playground_file_name do
    contents_linter.lint
  end
end