class Chef::Cookbook::SyntaxCheck::PersistentSet
Chef::Cookbook::SyntaxCheck::PersistentSet
¶ ↑
Implements set behavior with disk-based persistence. Objects in the set are expected to be strings containing only characters that are valid in filenames.
This class is used to track which files have been syntax checked so that known good files are not rechecked.
Attributes
Public Class Methods
Source
# File lib/chef/cookbook/syntax_check.rb, line 45 def initialize(cache_path = Chef::Config[:syntax_check_cache_path]) @cache_path = cache_path @cache_path_created = false end
Create a new PersistentSet
. Values in the set are persisted by creating a file in the cache_path
directory.
Public Instance Methods
Source
# File lib/chef/cookbook/syntax_check.rb, line 51 def add(value) ensure_cache_path_created FileUtils.touch(File.join(cache_path, value)) end
Adds value
to the set’s collection.
Source
# File lib/chef/cookbook/syntax_check.rb, line 57 def include?(value) File.exist?(File.join(cache_path, value)) end
Returns true if the set includes value
Private Instance Methods
Source
# File lib/chef/cookbook/syntax_check.rb, line 63 def ensure_cache_path_created return true if @cache_path_created FileUtils.mkdir_p(cache_path) @cache_path_created = true end