Class: Grit::Ref

Inherits:
Object
  • Object
show all
Defined in:
lib/grit/ref.rb

Direct Known Subclasses

Head, Note, Remote, Tag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, repo, commit_id) ⇒ Ref

Instantiate a new Head

+name+ is the name of the head
+commit+ is the Commit that the head points to

Returns Grit::Head (baked)



45
46
47
48
49
50
# File 'lib/grit/ref.rb', line 45

def initialize(name, repo, commit_id)
  @name = name
  @commit_id = commit_id
  @repo_ref = repo
  @commit = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/grit/ref.rb', line 38

def name
  @name
end

Class Method Details

.count_all(repo, options = {}) ⇒ Object

Count all Refs

+repo+ is the Repo
+options+ is a Hash of options

Returns int



12
13
14
15
# File 'lib/grit/ref.rb', line 12

def count_all(repo, options = {})
  refs = repo.git.refs(options, prefix)
  refs.split("\n").size
end

.find_all(repo, options = {}) ⇒ Object

Find all Refs

+repo+ is the Repo
+options+ is a Hash of options

Returns Grit::Ref[] (baked)



22
23
24
25
26
27
28
# File 'lib/grit/ref.rb', line 22

def find_all(repo, options = {})
  refs = repo.git.refs(options, prefix)
  refs.split("\n").map do |ref|
    name, id = *ref.split(' ')
    self.new(name, repo, id)
  end
end

Instance Method Details

#commitObject



52
53
54
# File 'lib/grit/ref.rb', line 52

def commit
  @commit ||= get_commit
end

#inspectObject

Pretty object inspection



57
58
59
# File 'lib/grit/ref.rb', line 57

def inspect
  %Q{#<#{self.class.name} "#{@name}">}
end