Sha256: d80fbfdff05d4fdbb22d1d5642863d50f31d74af4c55cbff84e9ca5722020a09
Contents?: true
Size: 968 Bytes
Versions: 2
Compression:
Stored size: 968 Bytes
Contents
# frozen_string_literal: true module Spandx module Core class Git attr_reader :root, :url def initialize(url:) @url = url @root = path_for(url) end def read(path) full_path = File.join(root, path) IO.read(full_path) if File.exist?(full_path) end def update! dotgit? ? pull! : clone! end private def path_for(url) uri = URI.parse(url) name = uri.path.gsub(/\.git$/, '') File.expand_path(File.join(Dir.home, '.local', 'share', name)) end def dotgit? File.directory?(File.join(root, '.git')) end def clone! system('git', 'clone', '--quiet', '--depth=1', '--single-branch', '--branch', 'master', url, root) end def pull! Dir.chdir(root) do system('git', 'pull', '--no-rebase', '--quiet', 'origin', 'master') end end end Database = Git end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.13.1 | lib/spandx/core/git.rb |
spandx-0.13.0 | lib/spandx/core/git.rb |