Class: TFSGraph::Project

Inherits:
PersistableEntity show all
Defined in:
lib/tfs_graph/project.rb

Constant Summary collapse

SCHEMA =
{
  name: {key: "Name"},
  last_updated: {type: Time, default: Time.at(0).utc},
  hidden: {default: false, type: String}
}

Constants inherited from PersistableEntity

TFSGraph::PersistableEntity::NotPersisted

Instance Attribute Summary

Attributes inherited from PersistableEntity

#db_object, #id

Instance Method Summary collapse

Methods inherited from PersistableEntity

#delete!, #initialize, #persist, #persisted?, repository, #save!, #to_hash

Methods included from Extensions

#base_class_name

Methods inherited from Entity

inherited, #initialize, #schema, #to_hash

Constructor Details

This class inherits a constructor from TFSGraph::PersistableEntity

Instance Method Details

#<=>(other) ⇒ Object



13
14
15
# File 'lib/tfs_graph/project.rb', line 13

def <=>(other)
  id <=> other.id
end

#active_branchesObject



57
58
59
# File 'lib/tfs_graph/project.rb', line 57

def active_branches
  branches.reject(&:archived?)
end

#add_branch(branch) ⇒ Object



36
37
38
39
40
41
# File 'lib/tfs_graph/project.rb', line 36

def add_branch(branch)
  branch.project = self.name
  branch.save!

  @repo.relate(:branches, db_object, branch.db_object)
end

#all_activityObject



47
48
49
# File 'lib/tfs_graph/project.rb', line 47

def all_activity
  @repo.activity(self)
end

#all_activity_by_date(limiter = nil) ⇒ Object



51
52
53
54
55
# File 'lib/tfs_graph/project.rb', line 51

def all_activity_by_date(limiter=nil)
  raise InvalidArgument("parameter must be a Date") unless limiter.nil? || limiter.is_a?(Time)

  @repo.activity_by_date(self, limiter).group_by(&:formatted_created)
end

#branchesObject



61
62
63
# File 'lib/tfs_graph/project.rb', line 61

def branches
  branches_with_hidden.reject(&:hidden?)
end

#branches_for_root(root) ⇒ Object



65
66
67
# File 'lib/tfs_graph/project.rb', line 65

def branches_for_root(root)
  @repo.branches_for_root(self, root)
end

#branches_with_hiddenObject



73
74
75
# File 'lib/tfs_graph/project.rb', line 73

def branches_with_hidden
  @repo.get_nodes(db_object, :outgoing, :branches, Branch)
end

#changesets_for_root(root) ⇒ Object



69
70
71
# File 'lib/tfs_graph/project.rb', line 69

def changesets_for_root(root)
  @repo.changesets_for_root(self, root)
end

#hiddenObject

force string



28
29
30
# File 'lib/tfs_graph/project.rb', line 28

def hidden
  @hidden.to_s
end

#hidden?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tfs_graph/project.rb', line 32

def hidden?
  @hidden.to_s == "true"
end

#hide!Object



22
23
24
25
# File 'lib/tfs_graph/project.rb', line 22

def hide!
  self.hidden = true
  save!
end

#root_branchesObject



43
44
45
# File 'lib/tfs_graph/project.rb', line 43

def root_branches
  @repo.root_branches(self)
end

#updated!Object



17
18
19
20
# File 'lib/tfs_graph/project.rb', line 17

def updated!
  @last_updated = Time.now.utc
  save!
end