Class: Inspec::DirProvider
- Inherits:
-
FileProvider
- Object
- FileProvider
- Inspec::DirProvider
- Defined in:
- lib/inspec/file_provider.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #binread(file) ⇒ Object
-
#initialize(path) ⇒ DirProvider
constructor
A new instance of DirProvider.
- #read(file) ⇒ Object
Methods inherited from FileProvider
Constructor Details
#initialize(path) ⇒ DirProvider
Returns a new instance of DirProvider.
83 84 85 86 87 88 89 90 |
# File 'lib/inspec/file_provider.rb', line 83 def initialize(path) @files = if File.file?(path) [path] else Dir[File.join(Shellwords.shellescape(path), "**", "*")] end @path = path end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
82 83 84 |
# File 'lib/inspec/file_provider.rb', line 82 def files @files end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
82 83 84 |
# File 'lib/inspec/file_provider.rb', line 82 def path @path end |
Instance Method Details
#binread(file) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/inspec/file_provider.rb', line 99 def binread(file) return nil unless files.include?(file) return nil unless File.file?(file) File.binread(file) end |
#read(file) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/inspec/file_provider.rb', line 92 def read(file) return nil unless files.include?(file) return nil unless File.file?(file) File.read(file) end |