teamcity-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,25 +3,23 @@ require 'rake/gempackagetask'
3
3
  require 'rubygems/specification'
4
4
  require 'date'
5
5
  require 'spec/rake/spectask'
6
+ require 'lib/teamcity-client'
6
7
 
7
8
  spec = Gem::Specification.new do |s|
8
9
  s.name = "teamcity-client"
9
- s.version = "0.0.1"
10
+ s.version = TeamCityClient::VERSION
10
11
  s.author = "Stephen McDonald"
11
12
  s.email = "steve@jupo.org"
12
13
  s.homepage = "http://jupo.org"
13
- s.description = s.summary = "Team City Ghetto HTTP client."
14
-
14
+ s.description = s.summary = "Team City HTTP client."
15
15
  s.platform = Gem::Platform::RUBY
16
16
  s.has_rdoc = true
17
- s.extra_rdoc_files = ["README.rdoc", "LICENSE", 'TODO']
18
-
19
- # Uncomment this to add a dependency
17
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
20
18
  s.add_dependency "nokogiri"
21
19
  s.add_dependency "rest-client"
22
-
20
+ s.executables = [s.name]
23
21
  s.require_path = 'lib'
24
- s.files = %w(LICENSE README.rdoc Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
22
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec,bin}/**/*")
25
23
  end
26
24
 
27
25
  task :default => :spec
@@ -32,7 +30,6 @@ Spec::Rake::SpecTask.new do |t|
32
30
  t.spec_opts = %w(-fs --color)
33
31
  end
34
32
 
35
-
36
33
  Rake::GemPackageTask.new(spec) do |pkg|
37
34
  pkg.gem_spec = spec
38
35
  end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "optparse"
5
+ require "teamcity-client"
6
+
7
+ options = {:address => "teamcity:8111"}
8
+
9
+ option_parser = OptionParser.new do |opts|
10
+ opts.banner = "\nUsage: teamcity-client [options]\n\n"
11
+
12
+ opts.on("-b", "--build ID", Integer, "Check status and new errors for the given build ID (required)") do |v|
13
+ options[:build] = v
14
+ end
15
+
16
+ opts.on("-a", "--address HOST:PORT", String, "Host and port of the TeamCity server (default: #{options[:address]})") do |v|
17
+ options[:address] = v
18
+ end
19
+
20
+ opts.on("-h", "--help", "Show this message") do
21
+ puts opts
22
+ exit
23
+ end
24
+
25
+ opts.on("-v", "--version", "Show version") do
26
+ puts TeamCityClient::VERSION
27
+ exit
28
+ end
29
+ end
30
+
31
+ begin
32
+ option_parser.parse!
33
+ # Raise a parse error if the build arg isn't given, since it's required.
34
+ raise OptionParser::ParseError if options[:build].nil?
35
+ rescue OptionParser::ParseError
36
+ # Display all options if anything goes wrong.
37
+ puts option_parser
38
+ exit
39
+ end
40
+
41
+ # Connect to the Team City server and display the number of new errors
42
+ # for the given build.
43
+ teamcity_client = TeamCityClient.new options[:address]
44
+ errors = teamcity_client.build_errors(options[:build])
45
+ s = errors == 1 ? "" : "s"
46
+ puts "#{errors} error#{s} found for build #{options[:build]}"
@@ -14,6 +14,8 @@ require "nokogiri"
14
14
  # in the Team City interface.
15
15
  class TeamCityClient
16
16
 
17
+ VERSION = "0.0.2"
18
+
17
19
  def initialize(host)
18
20
  @host = host
19
21
  end
@@ -25,15 +27,15 @@ class TeamCityClient
25
27
  # remaining. Once the build is complete, parse the page for any
26
28
  # new errors and return the number.
27
29
  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
30
+ html = RestClient.get("http://#{@host}/viewLog.html?buildId=#{build_id}&guest=1")
31
+ doc = Nokogiri::HTML(html)
32
+ parts = doc.css(".statusTable").text.split("Time left:")
33
+ time_left = parts.length > 1 ? parts[1].split("(")[0].gsub(/\s+/, "") : ""
34
+ if show_progress && !time_left.empty?
35
+ STDOUT.write "\rTime left: #{time_left} (CTRL-C to abort)"
36
+ STDOUT.flush
37
+ end
38
+ sleep 1
37
39
  end until time_left.empty?
38
40
  doc.css(".failCount strong").text.to_i
39
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamcity-client
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
  - Stephen McDonald
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-30 00:00:00 +10:00
18
+ date: 2011-09-06 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,24 +46,23 @@ dependencies:
46
46
  version: "0"
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
- description: Team City Ghetto HTTP client.
49
+ description: Team City HTTP client.
50
50
  email: steve@jupo.org
51
- executables: []
52
-
51
+ executables:
52
+ - teamcity-client
53
53
  extensions: []
54
54
 
55
55
  extra_rdoc_files:
56
56
  - README.rdoc
57
57
  - LICENSE
58
- - TODO
59
58
  files:
60
59
  - LICENSE
61
60
  - README.rdoc
62
61
  - Rakefile
63
- - TODO
64
62
  - lib/teamcity-client.rb
65
63
  - spec/spec_helper.rb
66
64
  - spec/teamcity-client_spec.rb
65
+ - bin/teamcity-client
67
66
  has_rdoc: true
68
67
  homepage: http://jupo.org
69
68
  licenses: []
@@ -97,6 +96,6 @@ rubyforge_project:
97
96
  rubygems_version: 1.6.2
98
97
  signing_key:
99
98
  specification_version: 3
100
- summary: Team City Ghetto HTTP client.
99
+ summary: Team City HTTP client.
101
100
  test_files: []
102
101
 
data/TODO DELETED
@@ -1,4 +0,0 @@
1
- TODO:
2
- Fix LICENSE with your name
3
- Fix Rakefile with your name and contact info
4
- Add your code to lib/<%= name %>.rb