Class: Inspec::Targets::ArchiveHelper
- Inherits:
-
Object
- Object
- Inspec::Targets::ArchiveHelper
- Defined in:
- lib/inspec/targets/archive.rb
Instance Method Summary collapse
-
#collect(helper, files, getter) ⇒ Object
FIXME(sr) dedup inspec/targets/folder.
- #resolve(target, _opts = {}) ⇒ Object
Instance Method Details
#collect(helper, files, getter) ⇒ Object
FIXME(sr) dedup inspec/targets/folder
38 39 40 41 |
# File 'lib/inspec/targets/archive.rb', line 38 def collect(helper, files, getter) return [] unless helper.respond_to? getter helper.method(getter).call(files) end |
#resolve(target, _opts = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/inspec/targets/archive.rb', line 10 def resolve(target, _opts = {}) files, rootdir = structure(target) # remove trailing slashes files = files.collect { |f| f.chomp('/') } # remove leading directory files = files.collect { |f| Pathname(f).relative_path_from(Pathname(rootdir)).to_s } helper = DirsHelper.get_handler(files) if helper.nil? fail "Don't know how to handle folder #{target}" end res = { test: collect(helper, files, :get_filenames), library: collect(helper, files, :get_libraries), metadata: collect(helper, files, :get_metadata), }.map { |as, list| content(target, list, rootdir, base_folder: target, as: as) } res.flatten end |