Class: Dependabot::Nuget::AnalysisJsonReader
- Inherits:
-
Object
- Object
- Dependabot::Nuget::AnalysisJsonReader
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nuget/analysis/analysis_json_reader.rb
Class Method Summary collapse
- .analysis_file_path(dependency_name:) ⇒ Object
- .analysis_json(dependency_name:) ⇒ Object
- .temp_directory ⇒ Object
Instance Method Summary collapse
- #dependency_analysis ⇒ Object
-
#initialize(analysis_json:) ⇒ AnalysisJsonReader
constructor
A new instance of AnalysisJsonReader.
Constructor Details
#initialize(analysis_json:) ⇒ AnalysisJsonReader
Returns a new instance of AnalysisJsonReader.
39 40 41 |
# File 'lib/dependabot/nuget/analysis/analysis_json_reader.rb', line 39 def initialize(analysis_json:) @analysis_json = analysis_json end |
Class Method Details
.analysis_file_path(dependency_name:) ⇒ Object
21 22 23 |
# File 'lib/dependabot/nuget/analysis/analysis_json_reader.rb', line 21 def self.analysis_file_path(dependency_name:) File.join(temp_directory, "#{dependency_name}.json") end |
.analysis_json(dependency_name:) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/nuget/analysis/analysis_json_reader.rb', line 26 def self.analysis_json(dependency_name:) file_path = analysis_file_path(dependency_name: dependency_name) return unless File.exist?(file_path) DependencyFile.new( name: Pathname.new(file_path).cleanpath.to_path, directory: temp_directory, type: "file", content: File.read(file_path) ) end |
.temp_directory ⇒ Object
16 17 18 |
# File 'lib/dependabot/nuget/analysis/analysis_json_reader.rb', line 16 def self.temp_directory File.join(NativeDiscoveryJsonReader.temp_directory, "analysis") end |
Instance Method Details
#dependency_analysis ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dependabot/nuget/analysis/analysis_json_reader.rb', line 44 def dependency_analysis @dependency_analysis ||= T.let(begin raise Dependabot::DependencyFileNotParseable, analysis_json.path unless analysis_json.content Dependabot.logger.info("#{File.basename(analysis_json.path)} analysis content: #{analysis_json.content}") parsed_json = T.let(JSON.parse(T.must(analysis_json.content)), T::Hash[String, T.untyped]) DependencyAnalysis.from_json(parsed_json) end, T.nilable(DependencyAnalysis)) rescue JSON::ParserError raise Dependabot::DependencyFileNotParseable, analysis_json.path end |