Class: TFSGraph::Changeset

Inherits:
Entity
  • Object
show all
Extended by:
Comparable, 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: DateTime},
  id: {key: "Id", type: Integer},
  branch_path: {type: String, default: nil},
  tags: {type: Array, default: []},
  parent: {type: Integer, default: nil},
  merge_parent: {type: Integer, default: nil}
}

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 Entity

inherited

Instance Method Details

#<=>(other) ⇒ Object



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

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

#as_json(options = {}) ⇒ Object



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

def as_json(options={})
  options.merge! methods: [:merges_ids, :merged_ids]
  super
end

#branchObject



33
34
35
# File 'lib/tfs_graph/changeset.rb', line 33

def branch
  incoming(:changesets).options(model: Branch).nodes.to_a.first
end

#formatted_createdObject



37
38
39
# File 'lib/tfs_graph/changeset.rb', line 37

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

#nextObject

Raises:

  • (StopIteration)


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

def next
  child = outgoing(:child).options(model: self.class).nodes.to_a.first
  raise StopIteration unless child
  child
end

#set_merging_fromObject



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

def set_merging_from
  from = merges.max
  self.merge_parent = from.id if from
end

#set_merging_toObject



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

def set_merging_to
  into = merged.max
  self.merge_parent = into.id if into
end