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.


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

def initialize(tap)
  @tap = tap
end

Instance Attribute Details

#tapObject (readonly)

Returns the value of attribute tap


702
703
704
# File 'Library/Homebrew/tap.rb', line 702

def tap
  @tap
end

Instance Method Details

#[](key) ⇒ Object


708
709
710
711
712
713
714
715
# File 'Library/Homebrew/tap.rb', line 708

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


717
718
719
720
721
722
723
724
# File 'Library/Homebrew/tap.rb', line 717

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