teamcity_ruby 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,17 +4,8 @@ module TeamcityRuby
4
4
 
5
5
  attr_accessor :teamcity_id, :name, :project_id
6
6
 
7
- def self.all
8
- client.get("/buildTypes")["buildType"].map do |b|
9
- new(b)
10
- end
11
- end
12
-
13
- def self.find(options = {})
14
- response = client.get("/buildTypes/#{locator(options)}")
15
- return nil if ( response.body =~ /No buildType found/ )
16
- new(response)
17
- end
7
+ url_path '/buildTypes'
8
+ resource_name 'buildType'
18
9
 
19
10
  def self.create(name, options = {})
20
11
  payload = { "name" => name }.to_json
@@ -4,17 +4,8 @@ module TeamcityRuby
4
4
 
5
5
  attr_reader :teamcity_id, :name, :parent_id
6
6
 
7
- def self.all
8
- client.get("/projects")["project"].map do |p|
9
- new(p)
10
- end
11
- end
12
-
13
- def self.find(options = {})
14
- response = client.get("/projects/#{locator(options)}")
15
- return nil if ( response.body =~ /No project found/ )
16
- new(response)
17
- end
7
+ url_path '/projects'
8
+ resource_name 'project'
18
9
 
19
10
  def self.create(name, options = {})
20
11
  payload = { "name" => name }
@@ -9,6 +9,26 @@ module TeamcityRuby
9
9
  options.map { |key, value| "#{key}:#{URI.escape(value)}" }.join
10
10
  end
11
11
 
12
+ def url_path(url_path)
13
+ @url_path = url_path
14
+ end
15
+
16
+ def resource_name(resource_name)
17
+ @resource_name = resource_name
18
+ end
19
+
20
+ def all
21
+ client.get(@url_path)[@resource_name].map do |b|
22
+ new(b)
23
+ end
24
+ end
25
+
26
+ def find(options = {})
27
+ response = client.get("#{@url_path}/#{locator(options)}")
28
+ return nil if ( response.body =~ /NotFoundException/ )
29
+ new(response)
30
+ end
31
+
12
32
  module InstanceMethods
13
33
  def client
14
34
  self.class.client
@@ -9,17 +9,8 @@ module TeamcityRuby
9
9
 
10
10
  attr_reader :teamcity_id, :name, :parent_id
11
11
 
12
- def self.all
13
- client.get("/vcs-roots")["vcs-root"].map do |p|
14
- VcsRoot.new(p)
15
- end
16
- end
17
-
18
- def self.find(options = {})
19
- response = client.get("/vcs-roots/#{locator(options)}")
20
- return nil if ( response.body =~ /No vcsRoot found/ )
21
- VcsRoot.new(response)
22
- end
12
+ url_path "/vcs-roots"
13
+ resource_name "vcs-root"
23
14
 
24
15
  def self.create(options = {}, &block)
25
16
  vcs_type = VCS_TYPES[options.fetch(:type) { DEFAULT_VCS_TYPE }]
@@ -1,3 +1,3 @@
1
1
  module TeamcityRuby
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamcity_ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jefferson Girao
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-05-09 00:00:00 -04:00
18
+ date: 2014-05-22 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency