Class: TFSGraph::Changeset

Inherits:
PersistableEntity show all
Extended by:
TFSHelpers
Defined in:
lib/tfs_graph/changeset.rb

Constant Summary collapse

SCHEMA =
{
  comment: {key: "Comment", type: String},
  committer: {key: "Committer", converter: ->(name) { base_username(name) }, type: String},
  created: {key: "CreationDate", type: Time},
  id: {key: "Id", type: Integer},
  branch_path: {type: String, default: nil},
  # tags: {type: Array, default: []},
  parent: {type: Integer, default: 0},
  merge_parent: {type: Integer, default: 0}
}

Constants inherited from PersistableEntity

PersistableEntity::NotPersisted

Instance Attribute Summary

Attributes inherited from PersistableEntity

#db_object

Instance Method Summary collapse

Methods included from TFSHelpers

base_username, branch_base, branch_path_to_name, branch_project, odata_path_to_server_path, scrub_changeset, server_path_to_odata_path

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



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

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

#add_child(changeset) ⇒ Object



53
54
55
# File 'lib/tfs_graph/changeset.rb', line 53

def add_child(changeset)
  @repo.relate(:child, self.db_object, changeset.db_object)
end

#as_json(options = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/tfs_graph/changeset.rb', line 82

def as_json(options={})
  results = super

  [:merges_ids, :merged_ids].each do |key|
    results[key] = self.send key
  end

  results
end

#base?Boolean

Returns:

  • (Boolean)


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

def base?
  @parent == 0 || @parent == @merge_parent
end

#branchObject



63
64
65
# File 'lib/tfs_graph/changeset.rb', line 63

def branch
  @repo.get_nodes(db_object, :incoming, :changesets, Branch).first
end

#createdObject



47
48
49
50
51
# File 'lib/tfs_graph/changeset.rb', line 47

def created
  return nil unless @created
  return @created unless @created.is_a? String
  @created = Time.parse @created
end

#eql?(other) ⇒ Boolean

override for the & (intersect) operator

Returns:

  • (Boolean)


27
28
29
# File 'lib/tfs_graph/changeset.rb', line 27

def eql?(other)
  other.is_a?(self.class) && other == self
end

#formatted_createdObject



67
68
69
# File 'lib/tfs_graph/changeset.rb', line 67

def formatted_created
  created.strftime("%m/%d/%Y")
end

#hashObject



31
32
33
# File 'lib/tfs_graph/changeset.rb', line 31

def hash
  @internal_id.hash
end

#idObject



35
36
37
# File 'lib/tfs_graph/changeset.rb', line 35

def id
  @id.to_i unless @id.nil?
end

#merge?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/tfs_graph/changeset.rb', line 39

def merge?
  !base? && @merge_parent != 0
end

#nextObject

Raises:

  • (StopIteration)


57
58
59
60
61
# File 'lib/tfs_graph/changeset.rb', line 57

def next
  child = @repo.get_nodes(db_object, :outgoing, :child, self.class).first
  raise StopIteration unless child
  child
end