Class: Hglib::Repo::StatusEntry
- Inherits:
-
Object
- Object
- Hglib::Repo::StatusEntry
- Extended by:
- Loggability
- Defined in:
- lib/hglib/repo/status_entry.rb
Overview
An entry in a repository’s status list.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Return the Pathname of the file the status applies to.
-
#source ⇒ Object
readonly
The Pathname of the file the status applies to was copied from (if the status is ‘A`/`added`) and the addition was via a copy/move operation.
-
#status ⇒ Object
readonly
Return the character that denotes the file’s status.
Instance Method Summary collapse
-
#added? ⇒ Boolean
Returns
true
if the status is ‘added’. -
#clean? ⇒ Boolean
Returns
true
if the status is ‘clean’. -
#ignored? ⇒ Boolean
Returns
true
if the status is ‘ignored’. -
#initialize(entryhash) ⇒ StatusEntry
constructor
Create a new log entry from the raw
entryhash
. -
#inspect ⇒ Object
Return a human-readable representation of the StatusEntry as a String.
-
#missing? ⇒ Boolean
Returns
true
if the status is ‘missing’. -
#modified? ⇒ Boolean
Returns
true
if the status is ‘modified’. -
#not_tracked? ⇒ Boolean
(also: #untracked?)
Returns
true
if the status is ‘not tracked’. -
#removed? ⇒ Boolean
Returns
true
if the status is ‘removed’. -
#status_description ⇒ Object
Return the human-readable status.
-
#tracked? ⇒ Boolean
Returns
true
if the status is anything other than ‘not tracked’.
Constructor Details
#initialize(entryhash) ⇒ StatusEntry
Create a new log entry from the raw entryhash
.
24 25 26 27 28 |
# File 'lib/hglib/repo/status_entry.rb', line 24 def initialize( entryhash ) @path = Pathname( entryhash[:path] ) @source = Pathname( entryhash[:source] ) if entryhash.key?( :source ) @status = entryhash[ :status ] end |
Instance Attribute Details
#path ⇒ Object (readonly)
Return the Pathname of the file the status applies to
37 38 39 |
# File 'lib/hglib/repo/status_entry.rb', line 37 def path @path end |
#source ⇒ Object (readonly)
The Pathname of the file the status applies to was copied from (if the status is ‘A`/`added`) and the addition was via a copy/move operation.
42 43 44 |
# File 'lib/hglib/repo/status_entry.rb', line 42 def source @source end |
#status ⇒ Object (readonly)
Return the character that denotes the file’s status
46 47 48 |
# File 'lib/hglib/repo/status_entry.rb', line 46 def status @status end |
Instance Method Details
#added? ⇒ Boolean
Returns true
if the status is ‘added’.
72 73 74 |
# File 'lib/hglib/repo/status_entry.rb', line 72 def added? return self.status == 'A' end |
#clean? ⇒ Boolean
Returns true
if the status is ‘clean’.
84 85 86 |
# File 'lib/hglib/repo/status_entry.rb', line 84 def clean? return self.status == 'C' end |
#ignored? ⇒ Boolean
Returns true
if the status is ‘ignored’.
109 110 111 |
# File 'lib/hglib/repo/status_entry.rb', line 109 def ignored? return self.status == 'I' end |
#inspect ⇒ Object
Return a human-readable representation of the StatusEntry as a String.
115 116 117 118 119 120 121 122 123 |
# File 'lib/hglib/repo/status_entry.rb', line 115 def inspect return "#<%p:#%x %s: %s%s>" % [ self.class, self.object_id * 2, self.path, self.status_description, self.source ? " via copy/move from #{self.source}" : '', ] end |
#missing? ⇒ Boolean
Returns true
if the status is ‘missing’.
90 91 92 |
# File 'lib/hglib/repo/status_entry.rb', line 90 def missing? return self.status == '!' end |
#modified? ⇒ Boolean
Returns true
if the status is ‘modified’.
66 67 68 |
# File 'lib/hglib/repo/status_entry.rb', line 66 def modified? return self.status == 'M' end |
#not_tracked? ⇒ Boolean Also known as: untracked?
Returns true
if the status is ‘not tracked’.
96 97 98 |
# File 'lib/hglib/repo/status_entry.rb', line 96 def not_tracked? return self.status == '?' end |
#removed? ⇒ Boolean
Returns true
if the status is ‘removed’.
78 79 80 |
# File 'lib/hglib/repo/status_entry.rb', line 78 def removed? return self.status == 'R' end |
#status_description ⇒ Object
Return the human-readable status.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hglib/repo/status_entry.rb', line 50 def status_description return case self.status when 'M' then 'modified' when 'A' then 'added' when 'R' then 'removed' when 'C' then 'clean' when '!' then 'missing' when '?' then 'not tracked' when 'I' then 'ignored' else raise "unknown status %p" % [ self.status ] end end |
#tracked? ⇒ Boolean
Returns true
if the status is anything other than ‘not tracked’.
103 104 105 |
# File 'lib/hglib/repo/status_entry.rb', line 103 def tracked? return !self.not_tracked? end |