Class: Playgroundbook::ManifestLinter
Overview
A base inplementation of a linter for verifying the contents of manifest files.
Instance Method Summary
collapse
#fail_lint, #message
Instance Method Details
#lint ⇒ Object
TODO: Should load manifest file in initialize instead of lazily.
12
13
14
15
|
# File 'lib/linter/manifest_linter.rb', line 12
def lint
fail_lint "No Manifest file in #{Dir.pwd}" unless manifest_file_exists?
fail_lint "Manifest file missing Name in #{Dir.pwd}" unless name?
end
|
#manifest_file_exists? ⇒ Boolean
17
18
19
|
# File 'lib/linter/manifest_linter.rb', line 17
def manifest_file_exists?
File.exist? MANIFEST_FILE_NAME
end
|
#manifest_plist_contents ⇒ Object
21
22
23
24
25
26
|
# File 'lib/linter/manifest_linter.rb', line 21
def manifest_plist_contents
return @manifest_plist_contents unless @manifest_plist_contents.nil?
require "plist"
@manifest_plist_contents = Plist.parse_xml(MANIFEST_FILE_NAME)
@manifest_plist_contents
end
|
#name? ⇒ Boolean
28
29
30
|
# File 'lib/linter/manifest_linter.rb', line 28
def name?
value_defined_in_manifest?("Name")
end
|
#value_defined_in_manifest?(key) ⇒ Boolean
32
33
34
35
36
37
|
# File 'lib/linter/manifest_linter.rb', line 32
def value_defined_in_manifest?(key)
return false if manifest_plist_contents.nil?
return false if manifest_plist_contents[key].nil?
return false if manifest_plist_contents[key].empty?
true
end
|