Module: StateMate::Adapters::Git::Ignore
- Includes:
- StateMate::Adapters
- Defined in:
- lib/state_mate/adapters/git/ignore.rb
Overview
Adapter for working with .gitingore
files.
Constant Summary
Constants included from StateMate::Adapters
API_METHOD_NAMES, DEFAULT_KEY_SEP
Class Method Summary collapse
-
.read(key, options = {}) ⇒ String?
adapter API call that reads a value from the git global config.
-
.write(key, value, options = {}) ⇒ Object
adapter API call that writes a value to the git global config.
Methods included from StateMate::Adapters
Class Method Details
.read(key, options = {}) ⇒ String?
adapter API call that reads a value from the git global config.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/state_mate/adapters/git/ignore.rb', line 46 def self.read key, = {} result = Cmds "git config --global --get %{key}", key: key # if the command succeeded the result is the output # (minus trailing newline) if result.ok? result.out.chomp # if it errored with no output then the key is missing elsif result.err == '' nil # otherwise, raise an error else result.assert end end |
.write(key, value, options = {}) ⇒ Object
adapter API call that writes a value to the git global config.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/state_mate/adapters/git/ignore.rb', line 75 def self.write key, value, = {} # decide to add or replace based on if the key has a value action = read(key, ).nil? ? '--add' : '--replace' result = Cmds! "git config --global #{ action } %{key} %{value}", key: key, value: value nil end |