Class: TeamcityRuby::VcsRoot

Inherits:
Object
  • Object
show all
Extended by:
Resource
Defined in:
lib/teamcity_ruby/vcs_root.rb

Constant Summary collapse

VCS_TYPES =
{ :git => 'jetbrains.git' }
DEFAULT_PROJECT =
"_Root"
DEFAULT_VCS_TYPE =
:git

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

all, client, extended, find, locator, resource_name, url_path

Constructor Details

#initialize(options = {}) ⇒ VcsRoot

Returns a new instance of VcsRoot.



31
32
33
34
# File 'lib/teamcity_ruby/vcs_root.rb', line 31

def initialize(options = {})
  @teamcity_id = options["id"]
  @name = options["name"]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/teamcity_ruby/vcs_root.rb', line 10

def name
  @name
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



10
11
12
# File 'lib/teamcity_ruby/vcs_root.rb', line 10

def parent_id
  @parent_id
end

#teamcity_idObject (readonly)

Returns the value of attribute teamcity_id.



10
11
12
# File 'lib/teamcity_ruby/vcs_root.rb', line 10

def teamcity_id
  @teamcity_id
end

Class Method Details

.create(options = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/teamcity_ruby/vcs_root.rb', line 15

def self.create(options = {}, &block)
  vcs_type = VCS_TYPES[options.fetch(:type) { DEFAULT_VCS_TYPE }]
  project_id = options.fetch(:project_id) { DEFAULT_PROJECT }

  attributes = {
    "name" => options[:name],
    "vcsName" => vcs_type,
    "projectLocator" => "id:#{project_id}",
  }

  builder = TeamCity::ElementBuilder.new(attributes, &block)

  response = client.post("/vcs-roots", :body => builder.to_request_body)
  VcsRoot.new(response)
end

Instance Method Details

#destroy!Object



36
37
38
# File 'lib/teamcity_ruby/vcs_root.rb', line 36

def destroy!
  client.delete("/vcs-roots/id:#{self.teamcity_id}")
end