Top Level Namespace
Defined Under Namespace
Modules: Git, Sawyer
Classes: Dir, Numeric, String
Instance Method Summary
collapse
Instance Method Details
#abbreviate(directory, root_dir = nil) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/ext/utils.rb', line 25
def abbreviate directory, root_dir = nil
case root_dir
when :home then directory.gsub(Git::Multi::HOME, '${HOME}')
when :workarea then directory.gsub(Git::Multi::WORKAREA, '${WORKAREA}')
else abbreviate(abbreviate(directory, :workarea), :home)
end
end
|
#describe(token) ⇒ Object
13
14
15
|
# File 'lib/ext/utils.rb', line 13
def describe token
token.nil? ? '(nil)' : token.empty? ? '(empty)' : "#{'*'*36}#{token[36..-1]}"
end
|
#env_var(name, default = nil) ⇒ Object
8
9
10
11
|
# File 'lib/ext/utils.rb', line 8
def env_var name, default = nil
value = ENV[name].freeze
(value.nil? || value.empty?) && default ? default : value
end
|
#git_option(name, default = nil) ⇒ Object
3
4
5
6
|
# File 'lib/ext/utils.rb', line 3
def git_option name, default = nil
value = `git config #{name}`.chomp.freeze
value.empty? && default ? default : value
end
|
#notify(message, options = {}, verbose = false) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ext/notify.rb', line 8
def notify(message, options = {}, verbose = false)
subtitle = options[:subtitle]
warn(subtitle ? "#{subtitle}: #{message}" : message) if $VERBOSE
if $INTERACTIVE && defined?(TerminalNotifier)
options[:title] ||= 'git-multi'
TerminalNotifier.notify(message, options, verbose)
end
end
|
#symbolize(token) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/ext/utils.rb', line 17
def symbolize token
case token
when env_var('OCTOKIT_ACCESS_TOKEN') then '${OCTOKIT_ACCESS_TOKEN}'
when git_option('github.token') then 'github.token'
else '(unset)'
end
end
|