Module: TeamcityRuby::Resource

Included in:
BuildConfiguration, Project, VcsRoot
Defined in:
lib/teamcity_ruby/resource.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



42
43
44
# File 'lib/teamcity_ruby/resource.rb', line 42

def self.extended(base)
  base.send(:include, InstanceMethods)
end

Instance Method Details

#allObject



20
21
22
23
24
# File 'lib/teamcity_ruby/resource.rb', line 20

def all
  client.get(@url_path)[@resource_name].map do |b|
    new(b)
  end
end

#clientObject



3
4
5
# File 'lib/teamcity_ruby/resource.rb', line 3

def client
  TeamcityRuby
end

#find(options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/teamcity_ruby/resource.rb', line 26

def find(options = {})
  response = client.get("#{@url_path}/#{locator(options)}")
  return nil if ( response.body =~ /NotFoundException/  )
  new(response)
end

#locator(options) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/teamcity_ruby/resource.rb', line 7

def locator(options)
  raise(ArgumentError, "the Locator must be a Hash") unless options.is_a? Hash
  options.map { |key, value| "#{key}:#{URI.escape(value)}" }.join
end

#resource_name(resource_name) ⇒ Object



16
17
18
# File 'lib/teamcity_ruby/resource.rb', line 16

def resource_name(resource_name)
  @resource_name = resource_name
end

#url_path(url_path) ⇒ Object



12
13
14
# File 'lib/teamcity_ruby/resource.rb', line 12

def url_path(url_path)
  @url_path = url_path
end