tc-client 0.0.2 → 0.0.3
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/bin/tc-client +30 -5
- data/lib/tc-client.rb +9 -6
- data/lib/version.rb +1 -1
- data/tc-client.gemspec +1 -1
- metadata +4 -4
data/bin/tc-client
CHANGED
@@ -2,16 +2,41 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
4
|
require 'tc-client'
|
5
|
+
require 'optparse'
|
5
6
|
|
6
|
-
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: tc-client <project name> <build name> [options]"
|
10
|
+
|
11
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
12
|
+
options[:verbose] = v
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.separator ""
|
16
|
+
opts.separator "Common tasks"
|
17
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
18
|
+
puts opts
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on_tail("--version", "Show version") do
|
23
|
+
require 'version'
|
24
|
+
puts "TCClient v#{TCClient::Version}"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end.parse!
|
28
|
+
|
29
|
+
client = TCClient.new(options[:verbose])
|
7
30
|
|
8
31
|
case ARGV.length
|
9
32
|
when 1 then
|
10
|
-
|
11
|
-
puts
|
33
|
+
builds = client.builds(ARGV[0])
|
34
|
+
puts "Available builds on #{builds[:project_name]}: "
|
35
|
+
puts builds[:builds].map { |x| x[:name] }
|
12
36
|
when 2
|
13
|
-
|
14
|
-
|
37
|
+
statuses = client.statuses(ARGV[0], ARGV[1])
|
38
|
+
puts "Last 10 builds on #{statuses[:project_name]} '#{statuses[:build_name]}': "
|
39
|
+
statuses[:statuses].each do |x|
|
15
40
|
puts "#{x[:build]} (#{x[:status]})"
|
16
41
|
end
|
17
42
|
else
|
data/lib/tc-client.rb
CHANGED
@@ -23,17 +23,20 @@ class TCClient
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def builds(project)
|
26
|
-
p = projects.select{|x| x[:name]
|
27
|
-
|
26
|
+
p = projects.select{|x| x[:name].match /#{project}/i }
|
27
|
+
return [{:name => "Can't find a project matching '#{project}'"}] if p.empty?
|
28
|
+
xml = get(p.first[:href])
|
28
29
|
doc = REXML::Document.new xml
|
29
|
-
doc.elements.collect("project/buildTypes/buildType") { |b| { :name => b.attributes["name"], :href => b.attributes["href"] } }
|
30
|
+
{ :project_name => p.first[:name], :builds => doc.elements.collect("project/buildTypes/buildType") { |b| { :name => b.attributes["name"], :href => b.attributes["href"] } } }
|
30
31
|
end
|
31
32
|
|
32
33
|
def statuses(project, build)
|
33
|
-
|
34
|
-
|
34
|
+
all = builds(project)
|
35
|
+
b = all[:builds].select{|x| x[:name].match /#{build}/i}
|
36
|
+
return [{:build => "Can't find a build matching: '#{build}'", :status => "FATAL"}] if b.empty?
|
37
|
+
xml = get("#{b.first[:href]}/builds?count=10")
|
35
38
|
doc = REXML::Document.new xml
|
36
|
-
doc.elements.collect("builds/build") {|x| { :build => x.attributes["number"], :status => x.attributes["status"] } }
|
39
|
+
{ :project_name => all[:project_name], :build_name => b.first[:name], :statuses => doc.elements.collect("builds/build") {|x| { :build => x.attributes["number"], :status => x.attributes["status"] } } }
|
37
40
|
end
|
38
41
|
|
39
42
|
def get(what)
|
data/lib/version.rb
CHANGED
data/tc-client.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tc-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristoffer Roupe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-04-04 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|