Class: Inspec::ProfileVendor
- Inherits:
-
Object
- Object
- Inspec::ProfileVendor
- Defined in:
- lib/inspec/profile_vendor.rb
Instance Attribute Summary collapse
-
#profile_path ⇒ Object
readonly
Returns the value of attribute profile_path.
Instance Method Summary collapse
- #cache_path ⇒ Object
-
#initialize(path) ⇒ ProfileVendor
constructor
A new instance of ProfileVendor.
- #lockfile ⇒ Object
-
#make_readable ⇒ Object
The URL fetcher uses a Tempfile to retrieve the vendored profile, which creates a file that is only readable by the current user.
- #vendor! ⇒ Object
Constructor Details
#initialize(path) ⇒ ProfileVendor
Returns a new instance of ProfileVendor.
10 11 12 |
# File 'lib/inspec/profile_vendor.rb', line 10 def initialize(path) @profile_path = Pathname.new(File.(path)) end |
Instance Attribute Details
#profile_path ⇒ Object (readonly)
Returns the value of attribute profile_path.
8 9 10 |
# File 'lib/inspec/profile_vendor.rb', line 8 def profile_path @profile_path end |
Instance Method Details
#cache_path ⇒ Object
35 36 37 |
# File 'lib/inspec/profile_vendor.rb', line 35 def cache_path profile_path.join('vendor') end |
#lockfile ⇒ Object
39 40 41 |
# File 'lib/inspec/profile_vendor.rb', line 39 def lockfile profile_path.join('inspec.lock') end |
#make_readable ⇒ Object
The URL fetcher uses a Tempfile to retrieve the vendored profile, which creates a file that is only readable by the current user. In most circumstances, this is likely OK. However, in environments like a Habitat package, these files need to be readable by all users or the Habitat Supervisor may not be able to start InSpec correctly.
This method makes sure all vendored files are mode 644 for this use case. This method is not called by default - the caller vendoring the profile must make the decision as to whether this is necessary.
29 30 31 32 33 |
# File 'lib/inspec/profile_vendor.rb', line 29 def make_readable Dir.glob("#{cache_path}/**/*") do |e| FileUtils.chmod(0644, e) if File.file?(e) end end |
#vendor! ⇒ Object
14 15 16 |
# File 'lib/inspec/profile_vendor.rb', line 14 def vendor! vendor_dependencies end |