Class: Chef::Cookbook::SyntaxCheck::PersistentSet
- Inherits:
-
Object
- Object
- Chef::Cookbook::SyntaxCheck::PersistentSet
- Defined in:
- lib/chef/cookbook/syntax_check.rb
Overview
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.
Instance Attribute Summary collapse
-
#cache_path ⇒ Object
readonly
Returns the value of attribute cache_path.
Instance Method Summary collapse
-
#add(value) ⇒ Object
Adds
value
to the set’s collection. -
#include?(value) ⇒ Boolean
Returns true if the set includes
value
. -
#initialize(cache_path = Chef::Config[:syntax_check_cache_path]) ⇒ PersistentSet
constructor
Create a new PersistentSet.
Constructor Details
#initialize(cache_path = Chef::Config[:syntax_check_cache_path]) ⇒ PersistentSet
Create a new PersistentSet. Values in the set are persisted by creating a file in the cache_path
directory.
45 46 47 48 |
# 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 |
Instance Attribute Details
#cache_path ⇒ Object (readonly)
Returns the value of attribute cache_path.
41 42 43 |
# File 'lib/chef/cookbook/syntax_check.rb', line 41 def cache_path @cache_path end |
Instance Method Details
#add(value) ⇒ Object
Adds value
to the set’s collection.
51 52 53 54 |
# File 'lib/chef/cookbook/syntax_check.rb', line 51 def add(value) ensure_cache_path_created FileUtils.touch(File.join(cache_path, value)) end |
#include?(value) ⇒ Boolean
Returns true if the set includes value
57 58 59 |
# File 'lib/chef/cookbook/syntax_check.rb', line 57 def include?(value) File.exist?(File.join(cache_path, value)) end |