Class: Gitt::Commands::Config
- Inherits:
-
Object
- Object
- Gitt::Commands::Config
- Defined in:
- lib/gitt/commands/config.rb
Overview
A Git config command wrapper.
Instance Method Summary collapse
- #call ⇒ Object
- #get(key, fallback = Core::EMPTY_STRING) ⇒ Object
-
#initialize(shell: SHELL) ⇒ Config
constructor
A new instance of Config.
- #origin? ⇒ Boolean
- #set(key, value) ⇒ Object
Constructor Details
Instance Method Details
#call ⇒ Object
16 |
# File 'lib/gitt/commands/config.rb', line 16 def call(*, **) = shell.call("config", *, **) |
#get(key, fallback = Core::EMPTY_STRING) ⇒ Object
18 19 20 21 22 |
# File 'lib/gitt/commands/config.rb', line 18 def get(key, fallback = Core::EMPTY_STRING, *, **) shell.call("config", "--get", key, *, **) .fmap(&:chomp) .or { |error| block_given? ? yield(error) : Success(fallback) } end |
#origin? ⇒ Boolean
24 |
# File 'lib/gitt/commands/config.rb', line 24 def origin? = !get("remote.origin.url").value_or(Core::EMPTY_STRING).empty? |
#set(key, value) ⇒ Object
26 |
# File 'lib/gitt/commands/config.rb', line 26 def set(key, value, *, **) = shell.call("config", "--add", key, value, *, **).fmap { value } |