module Git::Semaphore

Constants

NAME
PIM
VERSION

Public Class Methods

cache_dir() click to toggle source
# File lib/git/semaphore.rb, line 34
def self.cache_dir
  @cache_dir ||= begin
    File.join(home_dir, '.git', 'semaphore').tap do |cache_dir|
      FileUtils.mkdir_p(cache_dir)
    end
  end
end
cache_dir_for(identifier) click to toggle source
# File lib/git/semaphore.rb, line 42
def self.cache_dir_for(identifier)
  File.join(cache_dir, identifier).tap do |cache_dir|
    FileUtils.mkdir_p(cache_dir)
  end
end
empty_cache_dir() click to toggle source
# File lib/git/semaphore.rb, line 48
def self.empty_cache_dir
  FileUtils.rm_r Dir.glob(File.join(cache_dir, '*'))
end
from_json_cache(path, refresh = false) { || ... } click to toggle source
# File lib/git/semaphore.rb, line 52
def self.from_json_cache(path, refresh = false)
  if !refresh && File.exist?(path)
    JSON.parse(File.read(path))
  else
    yield.tap do |content|
      File.open(path, 'w') { |file| file.write content.to_json }
    end
  end
home_dir() click to toggle source
# File lib/git/semaphore.rb, line 28
def self.home_dir
  @home_dir ||= begin
    ENV['HOME'] || File.expand_path("~#{Etc.getlogin}")
  end
end
version() click to toggle source
# File lib/git/semaphore/version.rb, line 6
def self.version
  "#{NAME} v#{VERSION}"
end