mirror of
https://github.com/inspec/inspec
synced 2024-11-24 13:43:09 +00:00
47 lines
991 B
Ruby
47 lines
991 B
Ruby
# encoding: utf-8
|
|
|
|
module Vulcano::Targets
|
|
module DirsHelper
|
|
class ChefAuditDir
|
|
def handles?(paths)
|
|
paths.include?('recipes') and paths.include?('metadata.rb')
|
|
end
|
|
|
|
def get_filenames(paths)
|
|
paths.find_all do |x|
|
|
x.start_with? 'recipes/' and x.end_with? '.rb'
|
|
end
|
|
end
|
|
end
|
|
|
|
class ServerspecDir
|
|
def handles?(paths)
|
|
paths.include?('spec')
|
|
end
|
|
|
|
def get_filenames(paths)
|
|
paths.find_all do |path|
|
|
path.start_with? 'spec' and path.end_with? '_spec.rb'
|
|
end
|
|
end
|
|
end
|
|
|
|
class FlatDir
|
|
def handles?(paths)
|
|
get_filenames(paths).empty? == false
|
|
end
|
|
|
|
def get_filenames(paths)
|
|
paths.find_all { |x| x.end_with?('.rb') and !x.include?('/') }
|
|
end
|
|
end
|
|
|
|
HANDLERS = [
|
|
ChefAuditDir, ServerspecDir, FlatDir
|
|
].map { |x| x.new }
|
|
|
|
def self.getHandler(paths)
|
|
HANDLERS.find { |x| x.handles? paths }
|
|
end
|
|
end
|
|
end
|