Class: Gitw::Git::RemoteRef
- Inherits:
-
Object
- Object
- Gitw::Git::RemoteRef
- Defined in:
- lib/gitw/git/remote_ref.rb
Overview
encapsulate git remote reference entry
Constant Summary collapse
- REMOTE_LINE_RE =
/^(?<name>\w+) \s+ (?<url>[^\s]+) \s+ \((?<mode>fetch|push)\)$/x.freeze
Instance Attribute Summary collapse
-
#fetch ⇒ Object
readonly
Returns the value of attribute fetch.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#push ⇒ Object
readonly
Returns the value of attribute push.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, fetch: nil, push: nil) ⇒ RemoteRef
constructor
A new instance of RemoteRef.
- #update(other_ref) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(name, fetch: nil, push: nil) ⇒ RemoteRef
Returns a new instance of RemoteRef.
52 53 54 55 56 |
# File 'lib/gitw/git/remote_ref.rb', line 52 def initialize(name, fetch: nil, push: nil) @name = name @fetch = fetch @push = push end |
Instance Attribute Details
#fetch ⇒ Object (readonly)
Returns the value of attribute fetch.
50 51 52 |
# File 'lib/gitw/git/remote_ref.rb', line 50 def fetch @fetch end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
50 51 52 |
# File 'lib/gitw/git/remote_ref.rb', line 50 def name @name end |
#push ⇒ Object (readonly)
Returns the value of attribute push.
50 51 52 |
# File 'lib/gitw/git/remote_ref.rb', line 50 def push @push end |
Class Method Details
.parse(ref_line) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/gitw/git/remote_ref.rb', line 71 def self.parse(ref_line) return unless (match = REMOTE_LINE_RE.match(ref_line.strip)) new(match[:name], match[:mode].to_sym => match[:url]) end |
Instance Method Details
#update(other_ref) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/gitw/git/remote_ref.rb', line 62 def update(other_ref) return self if self == other_ref return self if name != other_ref.name @fetch = other_ref.fetch || @fetch @push = other_ref.push || @push self end |
#url ⇒ Object
58 59 60 |
# File 'lib/gitw/git/remote_ref.rb', line 58 def url fetch || push end |