Class: VSTS::Item

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

Overview

Item model

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#underscore

Constructor Details

#initialize(h = {}) ⇒ Item

Parameters:

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

    item data as returned by the VSTS API



11
12
13
14
15
# File 'lib/vsts/item.rb', line 11

def initialize(h = {})
  @version = h["version"]
  @path = h["path"]
  @url = h["url"]
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#get(opts = {}) ⇒ String

Parameters:

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

    options

Options Hash (opts):

  • :versionType (Symbol)

    requested version type (the version parameter is the version of this); can be :branch, :changeset, :shelveset, :change, :date, :mergeSource, :latest

  • :version (int)

    the requested version number

  • :versionOptions (Symbol, nil)

    can be specified as :previous to get the previous version to the one specified

Returns:

  • (String)

    the downloaded file contents



27
28
29
30
31
32
# File 'lib/vsts/item.rb', line 27

def get(opts = {})
  urlparams = APIClient.build_params(opts, [:versionType, :version, :versionOptions])
  urlparams[:path] = @path
  resp = APIClient.get("/items", area: "tfvc", urlparams: urlparams, accept: "application/binary")
  resp.body
end