Sha256: 5321a09e3b1f4ddc4dc60593f92b4ffb6fc04d6322be57ecc85bb2bc4b1a4c2a

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

module TeamcityRuby
  class VcsRoot
    extend TeamcityRuby::Resource

    VCS_TYPES = { :git => 'jetbrains.git' }

    DEFAULT_PROJECT = "_Root"
    DEFAULT_VCS_TYPE = :git

    attr_reader :teamcity_id, :name, :parent_id

    url_path "/vcs-roots"
    resource_name "vcs-root"

    def self.create(options = {}, &block)
      vcs_type = VCS_TYPES[options.fetch(:type) { DEFAULT_VCS_TYPE }]
      project_id = options.fetch(:project_id) { DEFAULT_PROJECT }

      attributes = {
        "name" => options[:name],
        "vcsName" => vcs_type,
        "projectLocator" => "id:#{project_id}",
      }

      builder = TeamCity::ElementBuilder.new(attributes, &block)

      response = client.post("/vcs-roots", :body => builder.to_request_body)
      VcsRoot.new(response)
    end

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

    def destroy!
      client.delete("/vcs-roots/id:#{self.teamcity_id}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teamcity_ruby-0.0.3 lib/teamcity_ruby/vcs_root.rb
teamcity_ruby-0.0.2 lib/teamcity_ruby/vcs_root.rb