Sha256: 8e2402eb26c290d76a67cd126d88595a12fe45a868163dbc409682148b0a5c26
Contents?: true
Size: 1000 Bytes
Versions: 5
Compression:
Stored size: 1000 Bytes
Contents
require 'git' module Bundler::Advise class Advisories attr_reader :dir, :repo def initialize(dir: File.expand_path('~/.ruby-advisory-db'), repo: 'git@github.com:rubysec/ruby-advisory-db.git') @dir = dir @repo = repo end def update File.exist?(@dir) ? pull : clone rescue ArgumentError => e # git gem is dorky in this case, putting the path into the backtrace. msg = "Unexpected problem with working dir for advisories: #{e.message} #{e.backtrace}.\n" + "Call clean_update! to remove #{@dir} and re-clone it." raise RuntimeError, msg end def clean_update! FileUtils.rmtree @dir update end def gem_advisories_for(gem_name) Dir[File.join(@dir, 'gems', gem_name, '*.yml')].map do |ad_yml| Advisory.from_yml(ad_yml) end end private def clone Git.clone(@repo, @dir) end def pull git = Git.open(@dir) git.pull end end end
Version data entries
5 entries across 5 versions & 1 rubygems