lib/bundler/audit/database.rb in mrjoy-bundler-audit-0.3.2 vs lib/bundler/audit/database.rb in mrjoy-bundler-audit-0.3.3

- old
+ new

@@ -15,16 +15,15 @@ # # You should have received a copy of the GNU General Public License # along with mrjoy-bundler-audit. If not, see <http://www.gnu.org/licenses/>. # +require 'bundler/audit/advisory' + require 'time' require 'yaml' -require 'bundler/audit/advisory' -require 'bundler/audit/vendored_time' - module Bundler module Audit # # Represents the directory of advisories, grouped by gem name # and CVE number. @@ -35,12 +34,15 @@ URL = 'https://github.com/rubysec/ruby-advisory-db.git' # Default path to the ruby-advisory-db VENDORED_PATH = File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','data','ruby-advisory-db')) + # Timestamp for when the database was last updated + VENDORED_TIMESTAMP = Time.parse(File.read("#{VENDORED_PATH}.ts")).utc + # Path to the user's copy of the ruby-advisory-db - USER_PATH = File.join(Gem.user_home,'.local','share','ruby-advisory-db') + USER_PATH = File.expand_path(File.join(ENV['HOME'],'.local','share','ruby-advisory-db')) # The path to the advisory database attr_reader :path # @@ -67,10 +69,10 @@ # The path to the database directory. # def self.path if File.directory?(USER_PATH) t1 = Dir.chdir(USER_PATH) { Time.parse(`git log --pretty="%cd" -1`) } - t2 = VENDORED_REPO_CTIME + t2 = VENDORED_TIMESTAMP if t1 >= t2 then USER_PATH else VENDORED_PATH end else