Class: Gitw::Git::RemoteRefs
- Inherits:
-
Object
- Object
- Gitw::Git::RemoteRefs
- Defined in:
- lib/gitw/git/remote_ref.rb
Overview
encapsulate git remote references
Class Method Summary collapse
Instance Method Summary collapse
- #by_name(name) ⇒ Object
- #by_url(url) ⇒ Object
-
#initialize(refs) ⇒ RemoteRefs
constructor
A new instance of RemoteRefs.
Constructor Details
#initialize(refs) ⇒ RemoteRefs
Returns a new instance of RemoteRefs.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gitw/git/remote_ref.rb', line 7 def initialize(refs) @refs = refs.compact @index_name = {} @index_url = {} @refs.each do |ref| @index_name[ref.name] = ref @index_url[ref.url] ||= [] @index_url[ref.url] << ref end end |
Class Method Details
.parse(output) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitw/git/remote_ref.rb', line 28 def self.parse(output) return new unless output refs = output.each_line.with_object({}) do |entry, refs_store| remote = RemoteRef.parse(entry) next unless remote refs_store[remote.name] ||= remote refs_store[remote.name].update(remote) end new(refs.values) end |
Instance Method Details
#by_name(name) ⇒ Object
20 21 22 |
# File 'lib/gitw/git/remote_ref.rb', line 20 def by_name(name) @index_name[name] end |
#by_url(url) ⇒ Object
24 25 26 |
# File 'lib/gitw/git/remote_ref.rb', line 24 def by_url(url) @index_url[url] end |