Class: Teamcity

Inherits:
Object
  • Object
show all
Defined in:
lib/teamcity-rest-client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options = {}) ⇒ Teamcity

Returns a new instance of Teamcity.



168
169
170
171
172
173
174
175
# File 'lib/teamcity-rest-client.rb', line 168

def initialize host, port, options = {}
  @host, @port = host, port
  if options[:user] && options[:password]
    @authentication = TeamcityRestClient::HttpBasicAuthentication.new(host, port, options.delete(:user), options.delete(:password), options)
  else
    @authentication = TeamcityRestClient::Open.new(host, port, options)
  end
end

Instance Attribute Details

#authenticationObject (readonly)

Returns the value of attribute authentication.



166
167
168
# File 'lib/teamcity-rest-client.rb', line 166

def authentication
  @authentication
end

#hostObject (readonly)

Returns the value of attribute host.



166
167
168
# File 'lib/teamcity-rest-client.rb', line 166

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



166
167
168
# File 'lib/teamcity-rest-client.rb', line 166

def port
  @port
end

Instance Method Details

#build_typesObject



190
191
192
193
194
# File 'lib/teamcity-rest-client.rb', line 190

def build_types
  doc(get('/app/rest/buildTypes')).elements.collect('//buildType') do |e| 
    TeamcityRestClient::BuildType.new(self, e.av("id"), e.av("name"), url(e.av("href")), e.av('projectName'), e.av('projectId'), e.av('webUrl'))
  end
end

#builds(options = {}) ⇒ Object



196
197
198
199
200
# File 'lib/teamcity-rest-client.rb', line 196

def builds options = {}
  doc(get('/app/rest/builds', options).gsub(/&buildTypeId/,'&buildTypeId')).elements.collect('//build') do |e|
    TeamcityRestClient::Build.new(self, e.av('id'), e.av('number'), e.av('status').to_sym, e.av('buildTypeId'), e.av_or('startDate', ''), url(e.av('href')), e.av('webUrl'))
  end
end

#project(spec) ⇒ Object



177
178
179
180
181
182
# File 'lib/teamcity-rest-client.rb', line 177

def project spec
  field = spec =~ /project\d+/ ? :id : :name  
  project = projects.find { |p| p.send(field) == spec }
  raise "Sorry, cannot find project with name or id '#{spec}'" unless project
  project
end

#projectsObject



184
185
186
187
188
# File 'lib/teamcity-rest-client.rb', line 184

def projects
  doc(get('/app/rest/projects')).elements.collect('//project') do |e| 
    TeamcityRestClient::Project.new(self, e.av("name"), e.av("id"), url(e.av("href")))
  end
end

#to_sObject



202
203
204
# File 'lib/teamcity-rest-client.rb', line 202

def to_s
  "Teamcity @ #{url("/")}"
end