Class: Git::ConfigEntryInfo
- Inherits:
-
Data
- Object
- Data
- Git::ConfigEntryInfo
- Defined in:
- lib/git/config_entry_info.rb
Overview
Represents a single Git configuration entry
Returned by Configuring read operations such as Git::Configuring#config_get, Git::Configuring#config_get_all, Git::Configuring#config_list, and their related methods.
Instance Attribute Summary collapse
-
#key ⇒ String
readonly
The full dotted key name of the configuration entry (e.g.,
remote.origin.url). -
#origin ⇒ String?
readonly
Where the configuration entry originates.
-
#scope ⇒ String
readonly
The scope of the configuration entry.
-
#value ⇒ String
readonly
The value of the configuration entry.
Instance Method Summary collapse
-
#section ⇒ String
Returns the section component of the key (everything before the first dot).
-
#subsection ⇒ String
Returns the subsection component of the key (everything between the first and last dot).
-
#variable ⇒ String
Returns the variable component of the key (everything after the last dot).
Instance Attribute Details
#key ⇒ String (readonly)
The full dotted key name of the configuration entry (e.g., remote.origin.url)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#origin ⇒ String? (readonly)
Where the configuration entry originates
The origin is in the format <origin-type>:<actual-origin> and is never
blank. The origin type prefix is one of file:, blob:, command line:,
or standard input:.
nil when the git command used to retrieve this entry does not support
--show-origin (currently only --get-urlmatch).
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#scope ⇒ String (readonly)
The scope of the configuration entry
May be one of "system", "global", "local", "worktree", "command",
"file", or "blob". The "command" scope is used for values supplied
via the command line (including default values from --default).
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#value ⇒ String (readonly)
The value of the configuration entry
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
Instance Method Details
#section ⇒ String
Returns the section component of the key (everything before the first dot)
Returns an empty string when the key contains no dot.
68 |
# File 'lib/git/config_entry_info.rb', line 68 def section = first_dot ? key[0...first_dot] : '' |
#subsection ⇒ String
Returns the subsection component of the key (everything between the first and last dot)
Returns an empty string when the key has zero or one dot (no subsection).
79 |
# File 'lib/git/config_entry_info.rb', line 79 def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' |
#variable ⇒ String
Returns the variable component of the key (everything after the last dot)
Returns the full key when the key contains no dot.
90 |
# File 'lib/git/config_entry_info.rb', line 90 def variable = last_dot ? key[(last_dot + 1)..] : key |