From d48b2d40967fdee5d345519bf74ba6dd22b73441 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 12 Jun 2017 13:00:19 +0200 Subject: [PATCH] bugfix: reading tgz files with binread (#1920) This is currently failing because both `alias` and `alias_method` create method imprints in the FileProvider. This leads to a failure where the TarProvider assumes it doesn't implement `binread`, which in fact it does, since it just calls `read`. Signed-off-by: Dominik Richter --- lib/inspec/file_provider.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/inspec/file_provider.rb b/lib/inspec/file_provider.rb index fddd75fa6..a88a895d8 100644 --- a/lib/inspec/file_provider.rb +++ b/lib/inspec/file_provider.rb @@ -24,6 +24,13 @@ module Inspec def initialize(_path) end + # List all files that are offered. + # + # @return [Array[String]] list of file paths that are included + def files + raise "Fetcher #{self} does not implement `files()`. This is required." + end + # Read the contents of a file. This will typically refer to a text # file reading a string. # @@ -37,10 +44,9 @@ module Inspec # It will default to #read if not defined. For most streams that implement # it, it will be the same. For some special cases, it will add change the # way in which encoding of the returned data structure is handled. - alias binread read - - def files - raise "Fetcher #{self} does not implement `files()`. This is required." + # Does not work with alias nor alias_method. + def binread(file) + read(file) end def relative_provider