Class: AbideDevUtils::XCCDF::Utils::FileDir
- Inherits:
-
Object
- Object
- AbideDevUtils::XCCDF::Utils::FileDir
- Defined in:
- lib/abide_dev_utils/xccdf/utils.rb
Overview
Class for working with directories that contain XCCDF files
Constant Summary collapse
- CIS_FILE_NAME_PARTS_PATTERN =
/^CIS_(?<subject>[A-Za-z0-9._()-]+)_Benchmark_v(?<version>[0-9.]+)-xccdf$/.freeze
Instance Method Summary collapse
- #files ⇒ Object
- #fuzzy_find(label, value) ⇒ Object
- #fuzzy_reject(label, value) ⇒ Object
- #fuzzy_select(label, value) ⇒ Object
-
#initialize(path) ⇒ FileDir
constructor
A new instance of FileDir.
- #label?(label) ⇒ Boolean
- #no_label?(label) ⇒ Boolean
Constructor Details
#initialize(path) ⇒ FileDir
Returns a new instance of FileDir.
11 12 13 14 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 11 def initialize(path) @path = File.(path) AbideDevUtils::Validate.directory(@path) end |
Instance Method Details
#files ⇒ Object
16 17 18 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 16 def files @files ||= Dir.glob(File.join(@path, '*-xccdf.xml')).map { |f| FileNameData.new(f) } end |
#fuzzy_find(label, value) ⇒ Object
20 21 22 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 20 def fuzzy_find(label, value) files.find { |f| f.fuzzy_match?(label, value) } end |
#fuzzy_reject(label, value) ⇒ Object
28 29 30 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 28 def fuzzy_reject(label, value) files.reject { |f| f.fuzzy_match?(label, value) } end |
#fuzzy_select(label, value) ⇒ Object
24 25 26 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 24 def fuzzy_select(label, value) files.select { |f| f.fuzzy_match?(label, value) } end |
#label?(label) ⇒ Boolean
32 33 34 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 32 def label?(label) files.select { |f| f.has?(label) } end |
#no_label?(label) ⇒ Boolean
36 37 38 |
# File 'lib/abide_dev_utils/xccdf/utils.rb', line 36 def no_label?(label) files.reject { |f| f.has?(label) } end |