Class: VSTS::Shelveset

Inherits:
BaseModel show all
Defined in:
lib/vsts/shelveset.rb

Overview

Shelveset model

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#underscore

Constructor Details

#initialize(h = {}) ⇒ Shelveset

Create new shelveset instance from a hash

Parameters:

  • h (Hash) (defaults to: {})

    shelveset data as returned by the VSTS API



10
11
12
13
14
15
16
17
18
# File 'lib/vsts/shelveset.rb', line 10

def initialize(h = {})
  @id = h["id"]
  @name = h["name"]
  @url = h["url"]
  @owner = Identity.new(h["owner"])
  @created_date = DateTime.rfc3339(h["createdDate"])
  @comment = h["comment"]
  @_changes = nil
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def comment
  @comment
end

#created_dateObject

Returns the value of attribute created_date.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def created_date
  @created_date
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def owner
  @owner
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/vsts/shelveset.rb', line 5

def url
  @url
end

Class Method Details

.find(id, opts = {}) ⇒ Shelveset?

Parameters:

  • name (String)

    shelveset id

  • opts (Hash) (defaults to: {})

    options

Options Hash (opts):

  • :maxCommentLength (int)
  • :maxChangeCount (int)
  • :includeDetails (boolean)
  • :includeWorkItems (boolean)

Returns:

  • (Shelveset, nil)

    the shelveset found or nil



78
79
80
81
82
# File 'lib/vsts/shelveset.rb', line 78

def self.find(id, opts = {})
  urlparams = APIClient.build_params(opts, [:includeDetails, :includeWorkItems, :maxCommentLength, :maxChangeCount])
  resp = APIClient.get("/shelvesets/#{id}", area: "tfvc", urlparams: urlparams)
  Shelveset.new(resp.parsed)
end

.find_all(params = {}) ⇒ array of Shelveset

Parameters:

  • params (Hash) (defaults to: {})

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vsts/shelveset.rb', line 37

def self.find_all(params = {})
  urlparams = APIClient.build_params(
    params,
    [
      :owner,
      :maxCommentLength,
      ["$", :top],
      ["$", :skip]
    ]
  )
  resp = APIClient.get("/shelvesets", area: "tfvc", urlparams: urlparams)
  resp.parsed["value"].map { |o| Shelveset.new(o) }
end

.find_by_name(name, owner, opts = {}) ⇒ Shelveset?

Parameters:

  • name (String)

    shelveset name

  • owner (String)

    shelveset owner (unique guid, display name or email)

  • opts (Hash) (defaults to: {})

    options

Options Hash (opts):

  • :maxCommentLength (int)
  • :maxChangeCount (int)
  • :includeDetails (boolean)
  • :includeWorkItems (boolean)

Returns:

  • (Shelveset, nil)

    the shelveset found or nil



62
63
64
65
66
# File 'lib/vsts/shelveset.rb', line 62

def self.find_by_name(name, owner, opts = {})
  urlparams = APIClient.build_params(opts, [:includeDetails, :includeWorkItems, :maxCommentLength, :maxChangeCount])
  resp = APIClient.get("/shelvesets/#{name};#{owner}", area: "tfvc", urlparams: urlparams)
  Shelveset.new(resp.parsed)
end

Instance Method Details

#changes(opts = {}) ⇒ array of Change

Parameters:

  • opts (Hash) (defaults to: {})

Returns:

  • (array of Change)

    list of changes in the shelveset



25
26
27
28
29
30
# File 'lib/vsts/shelveset.rb', line 25

def changes(opts = {})
  return @_changes if @_changes.instance_of?(Array)
  urlparams = APIClient.build_params(opts, [["$", :top], ["$", :skip]])
  resp = APIClient.get("/shelvesets/#{id}/changes", area: "tfvc", urlparams: urlparams)
  @_changes = resp.parsed["changes"].map { |o| Change.new(o) }
end