Class: Teamcity
- Inherits:
-
Object
- Object
- Teamcity
- Defined in:
- lib/teamcity-rest-client.rb
Instance Attribute Summary collapse
-
#authentication ⇒ Object
readonly
Returns the value of attribute authentication.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #build_types ⇒ Object
- #builds(options = {}) ⇒ Object
-
#initialize(host, port, options = {}) ⇒ Teamcity
constructor
A new instance of Teamcity.
- #project(spec) ⇒ Object
- #projects ⇒ Object
- #to_s ⇒ Object
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, = {} @host, @port = host, port if [:user] && [:password] @authentication = TeamcityRestClient::HttpBasicAuthentication.new(host, port, .delete(:user), .delete(:password), ) else @authentication = TeamcityRestClient::Open.new(host, port, ) end end |
Instance Attribute Details
#authentication ⇒ Object (readonly)
Returns the value of attribute authentication.
166 167 168 |
# File 'lib/teamcity-rest-client.rb', line 166 def authentication @authentication end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
166 167 168 |
# File 'lib/teamcity-rest-client.rb', line 166 def host @host end |
#port ⇒ Object (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_types ⇒ Object
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 = {} doc(get('/app/rest/builds', ).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 |
#projects ⇒ Object
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_s ⇒ Object
202 203 204 |
# File 'lib/teamcity-rest-client.rb', line 202 def to_s "Teamcity @ #{url("/")}" end |