Class: Inspec::RelativeFileProvider
- Inherits:
-
Object
- Object
- Inspec::RelativeFileProvider
- Defined in:
- lib/inspec/file_provider.rb
Constant Summary collapse
- BLACKLIST_FILES =
[ '/pax_global_header', 'pax_global_header', ].freeze
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #abs_path(file) ⇒ Object
- #binread(file) ⇒ Object
-
#initialize(parent_provider) ⇒ RelativeFileProvider
constructor
A new instance of RelativeFileProvider.
- #read(file) ⇒ Object
Constructor Details
#initialize(parent_provider) ⇒ RelativeFileProvider
Returns a new instance of RelativeFileProvider.
179 180 181 182 183 184 185 186 187 |
# File 'lib/inspec/file_provider.rb', line 179 def initialize(parent_provider) @parent = parent_provider @prefix = get_prefix(parent.files) if @prefix.nil? raise "Could not determine path prefix for #{parent}" end @files = parent.files.find_all { |x| x.start_with?(prefix) && x != prefix } .map { |x| x[prefix.length..-1] } end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
175 176 177 |
# File 'lib/inspec/file_provider.rb', line 175 def files @files end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
177 178 179 |
# File 'lib/inspec/file_provider.rb', line 177 def parent @parent end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
176 177 178 |
# File 'lib/inspec/file_provider.rb', line 176 def prefix @prefix end |
Instance Method Details
#abs_path(file) ⇒ Object
189 190 191 192 |
# File 'lib/inspec/file_provider.rb', line 189 def abs_path(file) return nil if file.nil? prefix + file end |
#binread(file) ⇒ Object
198 199 200 |
# File 'lib/inspec/file_provider.rb', line 198 def binread(file) parent.binread(abs_path(file)) end |
#read(file) ⇒ Object
194 195 196 |
# File 'lib/inspec/file_provider.rb', line 194 def read(file) parent.read(abs_path(file)) end |