require 'nokogiri' require 'open-uri' require 'singleton' require 'tcity/build_type' require 'tcity/configuration' module TCity class TeamCityAPI include Singleton BASE_URL = "#{Configuration.host}/httpAuth/app/rest" BUILD_TYPES_URL = "#{BASE_URL}/buildTypes" def self.build_types Nokogiri::XML(read_from_ci BUILD_TYPES_URL) .search('buildType') .map { |node| node.attr 'name' } .map { |name| BuildType.new(name) } end private def self.read_from_ci(url) open( url, http_basic_authentication: [ Configuration.username, Configuration.password, ] ).read end end end