class GitPlus::Commands::Config
A Git config command wrapper.
Public Class Methods
new(environment: ENV, shell: Open3)
click to toggle source
# File lib/git_plus/commands/config.rb, line 9 def initialize environment: ENV, shell: Open3 @environment = environment @shell = shell end
Public Instance Methods
call(*arguments)
click to toggle source
# File lib/git_plus/commands/config.rb, line 14 def call(*arguments) = shell.capture3(environment, "git", "config", *arguments) def get key, value = nil, *arguments call(*arguments, "--get", key).then do |stdout, stderr, status| if status.success? stdout.chomp elsif value value else block_given? ? yield(stdout, stderr) : "" end end end def origin? = !get("remote.origin.url").empty? def set key, value, *arguments call(*arguments, "--add", key, value).then do |_stdout, stderr, status| status.success? ? value : stderr end end private attr_reader :environment, :shell end end
get(key, value = nil, *arguments) { |stdout, stderr| ... }
click to toggle source
# File lib/git_plus/commands/config.rb, line 16 def get key, value = nil, *arguments call(*arguments, "--get", key).then do |stdout, stderr, status| if status.success? stdout.chomp elsif value value else block_given? ? yield(stdout, stderr) : "" end end end
origin?(= !get("remote.origin.url").empty?)
click to toggle source
# File lib/git_plus/commands/config.rb, line 28 def origin? = !get("remote.origin.url").empty? def set key, value, *arguments call(*arguments, "--add", key, value).then do |_stdout, stderr, status| status.success? ? value : stderr end end private attr_reader :environment, :shell end
set(key, value, *arguments)
click to toggle source
# File lib/git_plus/commands/config.rb, line 30 def set key, value, *arguments call(*arguments, "--add", key, value).then do |_stdout, stderr, status| status.success? ? value : stderr end end