Class: Jets::Git::User

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
GitCli
Defined in:
lib/jets/git/user.rb

Instance Method Summary collapse

Methods included from GitCli

#git, #git?, #git_folder?, #git_installed?

Instance Method Details

#emailObject



14
15
16
# File 'lib/jets/git/user.rb', line 14

def email
  git_config["user.email"]
end

#first_nameObject



6
7
8
# File 'lib/jets/git/user.rb', line 6

def first_name
  name.split(" ").first if name # name can be nil
end

#git_configObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/jets/git/user.rb', line 18

def git_config
  return {} if ENV['JETS_GIT_DISABLED']
  return {} unless git?
  list = git("config --list")
  lines = list.split("\n")
  # Other values in the git config are not needed.
  # And can cause .to_h to bomb and throw an error.
  lines.select! { |l| l =~ /^user\./ }
  lines.map { |l| l.split("=") }.to_h
end

#nameObject



10
11
12
# File 'lib/jets/git/user.rb', line 10

def name
  git_config["user.name"]
end