lib/inspec/dependencies/requirement.rb in inspec-1.4.0 vs lib/inspec/dependencies/requirement.rb in inspec-1.4.1

- old
+ new

@@ -12,20 +12,20 @@ def self.from_metadata(dep, cache, opts) fail 'Cannot load empty dependency.' if dep.nil? || dep.empty? new(dep[:name], dep[:version], cache, opts[:cwd], opts.merge(dep)) end - def self.from_lock_entry(entry, cwd, cache, backend) + def self.from_lock_entry(entry, cwd, cache, backend, opts = {}) req = new(entry[:name], entry[:version_constraints], cache, cwd, - entry[:resolved_source].merge(backend: backend)) + entry[:resolved_source].merge(backend: backend).merge(opts)) locked_deps = [] Array(entry[:dependencies]).each do |dep_entry| - locked_deps << Inspec::Requirement.from_lock_entry(dep_entry, cwd, cache, backend) + locked_deps << Inspec::Requirement.from_lock_entry(dep_entry, cwd, cache, backend, opts) end req.lock_deps(locked_deps) req end @@ -83,22 +83,23 @@ def fetcher @fetcher ||= Inspec::CachedFetcher.new(opts, @cache) end + # load dependencies of the dependency def dependencies @dependencies ||= profile.metadata.dependencies.map do |r| Inspec::Requirement.from_metadata(r, @cache, cwd: @cwd, backend: @backend) end end def to_s name end + # load the profile for the requirement def profile return @profile if ! @profile.nil? - opts = @opts.dup opts[:backend] = @backend if !@dependencies.nil? opts[:dependencies] = Inspec::DependencySet.from_array(@dependencies, @cwd, @cache, @backend) end