Module: Git::Semaphore
- Defined in:
- lib/git/semaphore.rb,
lib/git/semaphore/api.rb,
lib/git/semaphore/gemspec.rb,
lib/git/semaphore/project.rb,
lib/git/semaphore/version.rb,
lib/git/semaphore/api_cache.rb,
lib/git/semaphore/api_enrich.rb
Defined Under Namespace
Classes: API, Error, Project
Constant Summary
collapse
- PIM =
<<~"PIM".freeze
The only required setting for \033[1mgit semaphore\33[0m is:
\tgit config --global --add \033[1msemaphore.authtoken\033[0m <your_semaphore_auth_token>
Thanks for using \033[1mgit semaphore\033[0m ... the ultimate Semaphore utility for git!
PIM
- NAME =
'git-semaphore'.freeze
- VERSION =
'2.8.0'.freeze
Class Method Summary
collapse
Class Method Details
.auth_token ⇒ Object
75
76
77
|
# File 'lib/git/semaphore.rb', line 75
def self.auth_token
git_auth_token || global_auth_token || env_auth_token
end
|
.cache_dir ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/git/semaphore.rb', line 29
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) ⇒ Object
37
38
39
40
41
|
# File 'lib/git/semaphore.rb', line 37
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 ⇒ Object
43
44
45
|
# File 'lib/git/semaphore.rb', line 43
def self.empty_cache_dir
FileUtils.rm_r Dir.glob(File.join(cache_dir, '*'))
end
|
.env_auth_token ⇒ Object
63
64
65
|
# File 'lib/git/semaphore.rb', line 63
def self.env_auth_token
@env_auth_token ||= ENV['SEMAPHORE_AUTH_TOKEN']
end
|
.from_json_cache(path, refresh = false) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/git/semaphore.rb', line 47
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
end
|
.git_auth_token ⇒ Object
71
72
73
|
# File 'lib/git/semaphore.rb', line 71
def self.git_auth_token
git_repo&.config&.get('semaphore.authtoken')
end
|
.git_repo ⇒ Object
57
58
59
60
61
|
# File 'lib/git/semaphore.rb', line 57
def self.git_repo
Rugged::Repository.new(Dir.pwd)
rescue Rugged::RepositoryError
nil
end
|
.global_auth_token ⇒ Object
67
68
69
|
# File 'lib/git/semaphore.rb', line 67
def self.global_auth_token
Rugged::Config.global['semaphore.authtoken']
end
|
.home_dir ⇒ Object
23
24
25
26
27
|
# File 'lib/git/semaphore.rb', line 23
def self.home_dir
@home_dir ||= begin
ENV['HOME'] || File.expand_path("~#{Etc.getlogin}")
end
end
|
.version ⇒ Object
6
7
8
|
# File 'lib/git/semaphore/version.rb', line 6
def self.version
"#{NAME} v#{VERSION}"
end
|