class GitObjectBrowser::Models::PackedRefs

Public Class Methods

new(input) click to toggle source
# 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
path?(relpath) click to toggle source
# File lib/git-object-browser/models/packed_refs.rb, line 35
def self.path?(relpath)
  return relpath == "packed-refs"
end

Public Instance Methods

to_hash() click to toggle source
# File lib/git-object-browser/models/packed_refs.rb, line 28
def to_hash
  return {
    :entries => @entries,
    :content => @content
  }
end