Sha256: bcaeca325fe461a4f68d1e7b9dae92e2239674d903e2603e338e0186d27b8e3f

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

require 'nrser'
require 'nrser/exec'

using NRSER

module StateMate; end
module StateMate::Adapters; end

module StateMate::Adapters::GitConfig
  def self.read key, options = {}
    result = NRSER::Exec.result "git config --global --get %{key}", key: key

    if result.success?
      result.output.chomp
    elsif result.output == ''
      nil
    else
      result.raise_error
    end
  end

  def self.write key, value, options = {}
    action = if read(key, options).nil?
      '--add'
    else
      '--replace'
    end

    result = NRSER::Exec.result(
      "git config --global #{ action } %{key} %{value}",
      key: key,
      value: value
    )
  end
end # GitConfig

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
state_mate-0.0.1 lib/state_mate/adapters/git_config.rb