mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
lint targets
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
46b300f409
commit
07cb7efe36
7 changed files with 20 additions and 17 deletions
|
@ -7,8 +7,8 @@ module Vulcano
|
|||
extend Modulator
|
||||
|
||||
def self.__resolve(items)
|
||||
items.map do |item|
|
||||
|
||||
items.map do |_|
|
||||
# @TODO
|
||||
end.flatten
|
||||
end
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ module Vulcano::Targets
|
|||
|
||||
HANDLERS = [
|
||||
ChefAuditDir, ServerspecDir, FlatDir
|
||||
].map { |x| x.new }
|
||||
].map(&:new)
|
||||
|
||||
def self.getHandler(paths)
|
||||
def self.get_handler(paths)
|
||||
HANDLERS.find { |x| x.handles? paths }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Vulcano::Targets
|
|||
def resolve(target)
|
||||
{
|
||||
content: File.read(target),
|
||||
ref: target
|
||||
ref: target,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Vulcano::Targets
|
|||
# remove the prefix
|
||||
files = files.map { |x| x[target.length + 1..-1] }
|
||||
# get the dirs helper
|
||||
helper = DirsHelper.getHandler(files)
|
||||
helper = DirsHelper.get_handler(files)
|
||||
if helper.nil?
|
||||
fail "Don't know how to handle folder #{target}"
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module Vulcano::Targets
|
|||
def structure(input)
|
||||
files = []
|
||||
Gem::Package::TarReader.new(Zlib::GzipReader.open input) do |tar|
|
||||
files = tar.map{|entry| entry.full_name }
|
||||
files = tar.map(&:full_name)
|
||||
end
|
||||
files
|
||||
end
|
||||
|
|
|
@ -13,10 +13,11 @@ module Vulcano::Targets
|
|||
end
|
||||
|
||||
def resolve(target)
|
||||
if target.start_with? 'https://github.com' and target.end_with? '.git'
|
||||
url = target.sub(/.git$/, '') + '/archive/master.zip'
|
||||
return resolve_zip(url)
|
||||
end
|
||||
return nil unless target.start_with? 'https://github.com' and
|
||||
target.end_with? '.git'
|
||||
|
||||
url = target.sub(/.git$/, '') + '/archive/master.zip'
|
||||
resolve_zip(url)
|
||||
end
|
||||
|
||||
def resolve_zip(url)
|
||||
|
|
|
@ -4,14 +4,15 @@ require 'vulcano/targets/dir'
|
|||
|
||||
module Vulcano::Targets
|
||||
class ZipHelper
|
||||
def content(input, filter)
|
||||
def content(input, _filter)
|
||||
content = []
|
||||
::Zip::InputStream.open(input) do |io|
|
||||
while (entry = io.get_next_entry)
|
||||
content.push({
|
||||
h = {
|
||||
content: io.read,
|
||||
ref: File.join(input, entry.name)
|
||||
})
|
||||
ref: File.join(input, entry.name),
|
||||
}
|
||||
content.push(h)
|
||||
end
|
||||
end
|
||||
content
|
||||
|
@ -29,12 +30,13 @@ module Vulcano::Targets
|
|||
|
||||
def resolve(path)
|
||||
files = structure(path)
|
||||
helper = DirsHelper.getHandler(files)
|
||||
helper = DirsHelper.get_handler(files)
|
||||
if helper.nil?
|
||||
fail "Don't know how to handle folder #{path}"
|
||||
end
|
||||
# get all file contents
|
||||
file_handler = Vulcano::Targets.modules['file']
|
||||
# @TODO
|
||||
_file_handler = Vulcano::Targets.modules['file']
|
||||
test_files = helper.get_filenames(files)
|
||||
content(path, test_files)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue