Sha256: f860a897f9d9573548b64a66dafd8364dfda34d16f4782ed5f9bdae6e7502480
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true require 'tempfile' require_relative 'gemfile_health_score' module Polariscope module Scanner class CodebaseHealthScore def initialize(gemfile_content:, gemfile_lock_content:, bundler_audit_config_content:) @gemfile_content = gemfile_content @gemfile_lock_content = gemfile_lock_content @bundler_audit_config_content = bundler_audit_config_content end def health_score return nil if blank?(gemfile_content) || blank?(gemfile_lock_content) begin GemfileHealthScore.new(gemfile_path: gemfile_file.path, gemfile_lock_content: gemfile_lock_content, bundler_audit_config_path: bundler_audit_config_file.path).health_score ensure gemfile_file.unlink bundler_audit_config_file.unlink end end private attr_reader :gemfile_content attr_reader :gemfile_lock_content attr_reader :bundler_audit_config_content def gemfile_file @gemfile_file ||= begin file = Tempfile.new('Gemfile') file.write(gemfile_content.gsub("gemspec\n", '')) file.close file end end def bundler_audit_config_file @bundler_audit_config_file ||= begin file = Tempfile.new('.bundler-audit.yml') file.write(bundler_audit_config_content) file.close file end end def blank?(value) value.nil? || value == '' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
polariscope-0.1.3 | lib/polariscope/scanner/codebase_health_score.rb |
polariscope-0.1.2 | lib/polariscope/scanner/codebase_health_score.rb |