teamcity-client 0.0.1
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.
- data/LICENSE +20 -0
- data/README.rdoc +12 -0
- data/Rakefile +50 -0
- data/TODO +4 -0
- data/lib/teamcity-client.rb +41 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/teamcity-client_spec.rb +7 -0
- metadata +102 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Stephen McDonald
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
== teamcity-client
|
2
|
+
|
3
|
+
Team City Ghetto HTTP client.
|
4
|
+
|
5
|
+
Authentication is not yet supported and therefore guest access is
|
6
|
+
required.
|
7
|
+
|
8
|
+
Currently supports retrieving the number of new build errors for
|
9
|
+
a given build.
|
10
|
+
|
11
|
+
Initialize with a host:port string for grabbing and parsing pages
|
12
|
+
in the Team City interface.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
spec = Gem::Specification.new do |s|
|
8
|
+
s.name = "teamcity-client"
|
9
|
+
s.version = "0.0.1"
|
10
|
+
s.author = "Stephen McDonald"
|
11
|
+
s.email = "steve@jupo.org"
|
12
|
+
s.homepage = "http://jupo.org"
|
13
|
+
s.description = s.summary = "Team City Ghetto HTTP client."
|
14
|
+
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE", 'TODO']
|
18
|
+
|
19
|
+
# Uncomment this to add a dependency
|
20
|
+
s.add_dependency "nokogiri"
|
21
|
+
s.add_dependency "rest-client"
|
22
|
+
|
23
|
+
s.require_path = 'lib'
|
24
|
+
s.files = %w(LICENSE README.rdoc Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
25
|
+
end
|
26
|
+
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
desc "Run specs"
|
30
|
+
Spec::Rake::SpecTask.new do |t|
|
31
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
32
|
+
t.spec_opts = %w(-fs --color)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
37
|
+
pkg.gem_spec = spec
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "install the gem locally"
|
41
|
+
task :install => [:package] do
|
42
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "create a gemspec file"
|
46
|
+
task :make_spec do
|
47
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
48
|
+
file.puts spec.to_ruby
|
49
|
+
end
|
50
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rest-client"
|
3
|
+
require "nokogiri"
|
4
|
+
|
5
|
+
# Team City Ghetto HTTP client.
|
6
|
+
#
|
7
|
+
# Authentication is not yet supported and therefore guest access is
|
8
|
+
# required.
|
9
|
+
#
|
10
|
+
# Currently supports retrieving the number of new build errors for
|
11
|
+
# a given build.
|
12
|
+
#
|
13
|
+
# Initialize with a host:port string for grabbing and parsing pages
|
14
|
+
# in the Team City interface.
|
15
|
+
class TeamCityClient
|
16
|
+
|
17
|
+
def initialize(host)
|
18
|
+
@host = host
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_errors(build_id, show_progress=true)
|
22
|
+
# Grab the build page for the given build ID and parse the page
|
23
|
+
# for amount of time left for the build to complete. Keep hitting
|
24
|
+
# the page until the build is complete and output the amout of time
|
25
|
+
# remaining. Once the build is complete, parse the page for any
|
26
|
+
# new errors and return the number.
|
27
|
+
begin
|
28
|
+
html = RestClient.get("http://#{@host}/viewLog.html?buildId=#{build_id}&guest=1")
|
29
|
+
doc = Nokogiri::HTML(html)
|
30
|
+
parts = doc.css(".statusTable").text.split("Time left:")
|
31
|
+
time_left = parts.length > 1 ? parts[1].split("(")[0].gsub(/\s+/, "") : ""
|
32
|
+
if show_progress && !time_left.empty?
|
33
|
+
STDOUT.write "\rTime left: #{time_left} (CTRL-C to abort)"
|
34
|
+
STDOUT.flush
|
35
|
+
end
|
36
|
+
sleep 1
|
37
|
+
end until time_left.empty?
|
38
|
+
doc.css(".failCount strong").text.to_i
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamcity-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Stephen McDonald
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-30 00:00:00 +10:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: nokogiri
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rest-client
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Team City Ghetto HTTP client.
|
50
|
+
email: steve@jupo.org
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- README.rdoc
|
57
|
+
- LICENSE
|
58
|
+
- TODO
|
59
|
+
files:
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- TODO
|
64
|
+
- lib/teamcity-client.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- spec/teamcity-client_spec.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://jupo.org
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.6.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Team City Ghetto HTTP client.
|
101
|
+
test_files: []
|
102
|
+
|