class GitObjectBrowser::Models::Ref

Public Class Methods

new(input) click to toggle source
# File lib/git-object-browser/models/ref.rb, line 7
def initialize(input)
  @content = input.read(nil)

  if @content =~ %r{\Aref:\s*(.+)}
    @ref = $1
  elsif @content =~ %r{\A([0-9a-f]{40})}
    @sha1 = $1
  end
end
path?(relpath) click to toggle source
# File lib/git-object-browser/models/ref.rb, line 25
def self.path?(relpath)
  ref_names = %w{HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD CHERRY_PICK_HEAD}
  return (ref_names.include?(relpath) || relpath =~ %r{\Arefs/})
end

Public Instance Methods

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