Class: Grit::Tag
Overview
Head
Instance Attribute Summary collapse
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.find_all(repo, options = {}) ⇒ Object
Find all Tags
repo
is the Repooptions
is a Hash of options. -
.from_string(repo, line) ⇒ Object
Create a new Tag instance from the given string.
-
.list_from_string(repo, text) ⇒ Object
Parse out tag information into an array of baked Tag objects
repo
is the Repotext
is the text output from the git command.
Instance Method Summary collapse
-
#initialize(name, commit) ⇒ Tag
constructor
Instantiate a new Tag
name
is the name of the headcommit
is the Commit that the head points to. -
#inspect ⇒ Object
Pretty object inspection.
Constructor Details
#initialize(name, commit) ⇒ Tag
Instantiate a new Tag
+name+ is the name of the head
+commit+ is the Commit that the head points to
Returns Grit::Tag (baked)
12 13 14 15 |
# File 'lib/grit/tag.rb', line 12 def initialize(name, commit) @name = name @commit = commit end |
Instance Attribute Details
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
5 6 7 |
# File 'lib/grit/tag.rb', line 5 def commit @commit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/grit/tag.rb', line 4 def name @name end |
Class Method Details
.find_all(repo, options = {}) ⇒ Object
Find all Tags
+repo+ is the Repo
+options+ is a Hash of options
Returns Grit::Tag[] (baked)
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/grit/tag.rb', line 22 def self.find_all(repo, = {}) = {:sort => "committerdate", :format => "%(refname)%00%(objectname)"} = .merge() output = repo.git.for_each_ref(, "refs/tags") self.list_from_string(repo, output) end |
.from_string(repo, line) ⇒ Object
Create a new Tag instance from the given string.
+repo+ is the Repo
+line+ is the formatted tag information
Format
name: [a-zA-Z_/]+
<null byte>
id: [0-9A-Fa-f]{40}
Returns Grit::Tag (baked)
58 59 60 61 62 63 |
# File 'lib/grit/tag.rb', line 58 def self.from_string(repo, line) full_name, id = line.split("\0") name = full_name.split("/").last commit = Commit.create(repo, :id => id) self.new(name, commit) end |
.list_from_string(repo, text) ⇒ Object
Parse out tag information into an array of baked Tag objects
+repo+ is the Repo
+text+ is the text output from the git command
Returns Grit::Tag[] (baked)
38 39 40 41 42 43 44 45 46 |
# File 'lib/grit/tag.rb', line 38 def self.list_from_string(repo, text) = [] text.split("\n").each do |line| << self.from_string(repo, line) end end |
Instance Method Details
#inspect ⇒ Object
Pretty object inspection
66 67 68 |
# File 'lib/grit/tag.rb', line 66 def inspect %Q{#<Grit::Tag "#{@name}">} end |