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
- #all ⇒ Object
- #client ⇒ Object
- #find(options = {}) ⇒ Object
- #locator(options) ⇒ Object
- #resource_name(resource_name) ⇒ Object
- #url_path(url_path) ⇒ Object
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
#all ⇒ Object
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 |
#client ⇒ Object
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( = {}) response = client.get("#{@url_path}/#{locator()}") return nil if ( response.body =~ /NotFoundException/ ) new(response) end |
#locator(options) ⇒ Object
7 8 9 10 |
# File 'lib/teamcity_ruby/resource.rb', line 7 def locator() raise(ArgumentError, "the Locator must be a Hash") unless .is_a? Hash .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 |