class Mercurial::TagFactory

This class represents a factory for {Mercurial::Tag Tag} instances.

Attributes

repository[R]

Instance of {Mercurial::Repository Repository}.

Public Class Methods

new(repository) click to toggle source
# File lib/mercurial-ruby/factories/tag_factory.rb, line 12
def initialize(repository)
  @repository = repository
end

Public Instance Methods

all(cmd_options={}) click to toggle source

Return an array of {Mercurial::Tag Tag} instances for all tags in the repository.

Example:

repository.tags.all
# File lib/mercurial-ruby/factories/tag_factory.rb, line 21
def all(cmd_options={})
  hg_to_array("tags", {}, cmd_options) do |line|
    build(line)
  end
end
by_name(name, cmd_options={}) click to toggle source

Return a {Mercurial::Tag Tag} instance for a tag with a specified name.

Example:

repository.tags.by_name('tagname')
# File lib/mercurial-ruby/factories/tag_factory.rb, line 32
def by_name(name, cmd_options={})
  all(cmd_options).find do |b|
    b.name == name
  end
end

Private Instance Methods

build(data) click to toggle source
# File lib/mercurial-ruby/factories/tag_factory.rb, line 40
def build(data)
  name, hash_id = *data.scan(/([\w-]+)\s+\d+:(\w+)\s*/).first
  return if name == 'tip'
  Mercurial::Tag.new(repository, name, hash_id)
end