Sha256: 8cfc4cf3178f8419691145601823e6d9db34611053274b9a6c6c243fddec85fb

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tcity-0.0.1a lib/tcity/team_city_api.rb