Class: GitObjectBrowser::Models::PackedRefs
- Inherits:
-
Object
- Object
- GitObjectBrowser::Models::PackedRefs
- Defined in:
- lib/git-object-browser/models/packed_refs.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input) ⇒ PackedRefs
constructor
A new instance of PackedRefs.
- #to_hash ⇒ Object
Constructor Details
#initialize(input) ⇒ PackedRefs
Returns a new instance of PackedRefs.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/git-object-browser/models/packed_refs.rb', line 7 def initialize(input) @content = input.read(nil) input.seek(0) @entries = [] while (line = input.gets) do next if line =~ /\A\s*#/ next unless line =~ /(\^)?([0-9a-f]{40})\s*(.*)/ sha1 = $2 ref = $3 if $1 entry = @entries.last entry[:tag_sha1] = sha1 if entry else entry = {} entry[:sha1] = sha1 entry[:ref] = ref @entries << entry end end end |
Class Method Details
.path?(relpath) ⇒ Boolean
35 36 37 |
# File 'lib/git-object-browser/models/packed_refs.rb', line 35 def self.path?(relpath) return relpath == "packed-refs" end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 31 32 33 |
# File 'lib/git-object-browser/models/packed_refs.rb', line 28 def to_hash return { :entries => @entries, :content => @content } end |