Class: TeamcityRuby::Project

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

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 = {}) ⇒ Project

Returns a new instance of Project.



23
24
25
26
27
# File 'lib/teamcity_ruby/project.rb', line 23

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/teamcity_ruby/project.rb', line 5

def name
  @name
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



5
6
7
# File 'lib/teamcity_ruby/project.rb', line 5

def parent_id
  @parent_id
end

#teamcity_idObject (readonly)

Returns the value of attribute teamcity_id.



5
6
7
# File 'lib/teamcity_ruby/project.rb', line 5

def teamcity_id
  @teamcity_id
end

Class Method Details

.create(name, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/teamcity_ruby/project.rb', line 10

def self.create(name, options = {})
  payload = { "name" => name }
  payload["parentProject"] = { "id" => options[:parent_id] } if options[:parent_id]

  if options[:source_id]
    payload["sourceProject"] = { "id" => options[:source_id] }
    payload["copyAllAssociatedSettings"] = 'true'
  end

  response = client.post("/projects", :body => payload.to_json)
  new(response)
end

Instance Method Details

#descriptionObject



38
39
40
41
# File 'lib/teamcity_ruby/project.rb', line 38

def description
  headers = { "Accept" => "text/plain", "Content-Type" => "text/plain" }
  client.get("/projects/id:#{teamcity_id}/description", :headers => headers, :format => :text).parsed_response
end

#description=(value) ⇒ Object



33
34
35
36
# File 'lib/teamcity_ruby/project.rb', line 33

def description=(value)
  headers = { "Accept" => "text/plain", "Content-Type" => "text/plain" }
  client.put("/projects/id:#{teamcity_id}/description", :body => value, :headers => headers)
end

#destroy!Object



29
30
31
# File 'lib/teamcity_ruby/project.rb', line 29

def destroy!
  client.delete("/projects/id:#{teamcity_id}")
end