Class: Hglib::Extension::Topic::Entry

Inherits:
Object
  • Object
show all
Extended by:
MethodUtilities
Includes:
Inspection
Defined in:
lib/hglib/extension/topic.rb

Overview

A topic in an Hglib::Repo.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MethodUtilities

attr_predicate, attr_predicate_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias

Methods included from Inspection

#inspect

Constructor Details

#initialize(repo, entryhash) ⇒ Entry

Create a new Entry for the specified repo given an entryhash like that returned by the JSON template for the ‘topics` command.



20
21
22
23
24
25
26
27
28
29
# File 'lib/hglib/extension/topic.rb', line 20

def initialize( repo, entryhash )
	@repo = repo

	@name            = entryhash[:topic]
	@active          = entryhash[:active]
	@changeset_count = entryhash[:changesetcount]
	@branch          = entryhash[:"branches+"]
	@last_touched    = entryhash[:lasttouched]
	@user_touched    = entryhash[:usertouched]
end

Instance Attribute Details

#branchObject (readonly)

The name of the branch the topic is on



46
47
48
# File 'lib/hglib/extension/topic.rb', line 46

def branch
  @branch
end

#changeset_countObject (readonly) Also known as: changesetcount

The number of changesets belonging to the topic



54
55
56
# File 'lib/hglib/extension/topic.rb', line 54

def changeset_count
  @changeset_count
end

#last_touchedObject (readonly) Also known as: lasttouched

The human description of when the topic last had changesets added to it (if it was fetched)



60
61
62
# File 'lib/hglib/extension/topic.rb', line 60

def last_touched
  @last_touched
end

#nameObject (readonly)

The name of the topic



42
43
44
# File 'lib/hglib/extension/topic.rb', line 42

def name
  @name
end

#repoObject (readonly)

The Hglib::Repo of the repository the topic belongs to



38
39
40
# File 'lib/hglib/extension/topic.rb', line 38

def repo
  @repo
end

#user_touchedObject (readonly) Also known as: usertouched, touched_by

The name of the last user to add changesets to the topic (if it was fetched)



65
66
67
# File 'lib/hglib/extension/topic.rb', line 65

def user_touched
  @user_touched
end

Instance Method Details

#activeObject

Whether or not the entry is current active



50
# File 'lib/hglib/extension/topic.rb', line 50

attr_predicate :active

#stackObject

Return the changesets that belong to this topic as Hglib::Extension::Topic::StackEntry objects.



88
89
90
# File 'lib/hglib/extension/topic.rb', line 88

def stack
	return self.repo.stack( self.name )
end

#to_sObject Also known as: inspect_details

Return the entry as a String (in a similar form to the regular ‘hg topics` output)



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/hglib/extension/topic.rb', line 71

def to_s
	rval = String.new( encoding: 'utf-8' )
	rval << "%s (" % [ self.name ]
	rval << "%s" % [ self.last_touched ] if self.last_touched
	rval << " by %s" % [ self.user_touched ] if self.user_touched
	rval << ', ' if self.last_touched || self.user_touched
	rval << "%d changesets)" % [ self.changeset_count ]
	rval << " [active]" if self.active?
	rval.freeze

	return rval
end