Class: TapConfig

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/tap.rb

Overview

Permanent configuration per Tap using git-config(1).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tap) ⇒ TapConfig

Returns a new instance of TapConfig.


707
708
709
# File 'Library/Homebrew/tap.rb', line 707

def initialize(tap)
  @tap = tap
end

Instance Attribute Details

#tapObject (readonly)

Returns the value of attribute tap


705
706
707
# File 'Library/Homebrew/tap.rb', line 705

def tap
  @tap
end

Instance Method Details

#[](key) ⇒ Object


711
712
713
714
715
716
717
718
# File 'Library/Homebrew/tap.rb', line 711

def [](key)
  return unless tap.git?
  return unless Utils::Git.available?

  tap.path.cd do
    Utils.popen_read("git", "config", "--get", "homebrew.#{key}").chomp.presence
  end
end

#[]=(key, value) ⇒ Object


720
721
722
723
724
725
726
727
# File 'Library/Homebrew/tap.rb', line 720

def []=(key, value)
  return unless tap.git?
  return unless Utils::Git.available?

  tap.path.cd do
    safe_system "git", "config", "--replace-all", "homebrew.#{key}", value.to_s
  end
end