go_api_client 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +40 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/README.textile +36 -0
- data/Rakefile +13 -0
- data/bin/go_api_client +3 -0
- data/go_api_client.gemspec +24 -0
- data/lib/go_api_client/atom/author.rb +18 -0
- data/lib/go_api_client/atom/entry.rb +28 -0
- data/lib/go_api_client/atom/feed.rb +85 -0
- data/lib/go_api_client/atom.rb +4 -0
- data/lib/go_api_client/test/stub_http_fetcher.rb +91 -0
- data/lib/go_api_client/test.rb +1 -0
- data/lib/go_api_client/version.rb +3 -0
- data/lib/go_api_client.rb +16 -0
- data/test/fixtures/pipelines_1.xml +25 -0
- data/test/fixtures/stages.xml +63 -0
- data/test/fixtures/stages_1.xml +14 -0
- data/test/fixtures/stages_2.xml +14 -0
- data/test/go_api_client/integration_test.rb +25 -0
- data/test/test_helper.rb +7 -0
- metadata +85 -0
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Compiled source #
|
2
|
+
###################
|
3
|
+
*.com
|
4
|
+
*.class
|
5
|
+
*.dll
|
6
|
+
*.exe
|
7
|
+
*.o
|
8
|
+
*.so
|
9
|
+
|
10
|
+
# Packages #
|
11
|
+
############
|
12
|
+
# it's better to unpack these files and commit the raw source
|
13
|
+
# git has its own built in compression methods
|
14
|
+
*.7z
|
15
|
+
*.dmg
|
16
|
+
*.gz
|
17
|
+
*.iso
|
18
|
+
*.jar
|
19
|
+
*.rar
|
20
|
+
*.tar
|
21
|
+
*.zip
|
22
|
+
|
23
|
+
# Logs and databases #
|
24
|
+
######################
|
25
|
+
*.log
|
26
|
+
*.sql
|
27
|
+
*.sqlite
|
28
|
+
|
29
|
+
# OS generated files #
|
30
|
+
######################
|
31
|
+
.DS_Store*
|
32
|
+
ehthumbs.db
|
33
|
+
Icon?
|
34
|
+
Thumbs.db
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
\#*\#
|
39
|
+
.\#*
|
40
|
+
TAGS
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
go_api_client (0.0.1)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.2.7)
|
11
|
+
crack (0.3.1)
|
12
|
+
nokogiri (1.5.0)
|
13
|
+
webmock (1.8.0)
|
14
|
+
addressable (>= 2.2.7)
|
15
|
+
crack (>= 0.1.7)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
go_api_client!
|
22
|
+
webmock
|
data/README.textile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
h2. Go API Client Gem
|
2
|
+
|
3
|
+
This gem provides API access to the go api.
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
<pre>$ [sudo] gem install go_api_client</pre>
|
8
|
+
|
9
|
+
h2. Usage
|
10
|
+
|
11
|
+
h2. License
|
12
|
+
|
13
|
+
Go API Client Gem is MIT Licensed
|
14
|
+
|
15
|
+
The MIT License
|
16
|
+
|
17
|
+
Copyright (c) 2012 ThoughtWorks, Inc. (http://thoughtworks.com)
|
18
|
+
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
20
|
+
of this software and associated documentation files (the "Software"), to deal
|
21
|
+
in the Software without restriction, including without limitation the rights
|
22
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
23
|
+
copies of the Software, and to permit persons to whom the Software is
|
24
|
+
furnished to do so, subject to the following conditions:
|
25
|
+
|
26
|
+
The above copyright notice and this permission notice shall be included in
|
27
|
+
all copies or substantial portions of the Software.
|
28
|
+
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
32
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
33
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
34
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
35
|
+
THE SOFTWARE.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/go_api_client
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "go_api_client/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "go_api_client"
|
7
|
+
s.version = GoApiClient::VERSION
|
8
|
+
s.authors = ["Nikhil Mungel"]
|
9
|
+
s.email = ["hyfather@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Client to parse Go CI atom feed}
|
12
|
+
s.description = %q{This gem parses atom feed generated by the Go Continuous Integration server and provides an OO representation of the pipelines and stages.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "go_api_client"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "nokogiri"
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module GoApiClient
|
2
|
+
module Atom
|
3
|
+
class Author
|
4
|
+
attr_accessor :name, :email, :uri
|
5
|
+
def initialize(root)
|
6
|
+
@root = root
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse!
|
10
|
+
self.name = @root.xpath('xmlns:name').first.content
|
11
|
+
self.email = @root.xpath('xmlns:email').first.content rescue nil
|
12
|
+
self.uri = @root.xpath('xmlns:uri').first.content rescue nil
|
13
|
+
@root = nil
|
14
|
+
self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GoApiClient
|
2
|
+
module Atom
|
3
|
+
class Entry
|
4
|
+
attr_accessor :authors, :id, :updated_at, :title, :stage_href, :pipelines
|
5
|
+
|
6
|
+
def initialize(root)
|
7
|
+
@root = root
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse!
|
11
|
+
self.updated_at = @root.xpath('xmlns:updated').first.content
|
12
|
+
self.id = @root.xpath('xmlns:id').first.content
|
13
|
+
self.title = @root.xpath('xmlns:title').first.content
|
14
|
+
self.stage_href = @root.
|
15
|
+
xpath("xmlns:link[@type='application/vnd.go+xml' and @rel='alternate']").
|
16
|
+
first.
|
17
|
+
attributes["href"]
|
18
|
+
|
19
|
+
self.authors = @root.xpath('xmlns:author').collect do |author|
|
20
|
+
Author.new(author).parse!
|
21
|
+
end
|
22
|
+
@root = nil
|
23
|
+
self
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module GoApiClient
|
2
|
+
module Atom
|
3
|
+
class Feed
|
4
|
+
attr_accessor :updated_at
|
5
|
+
attr_accessor :next_page
|
6
|
+
attr_accessor :url
|
7
|
+
attr_accessor :entries
|
8
|
+
|
9
|
+
def initialize(root)
|
10
|
+
@root = root
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse!
|
14
|
+
self.updated_at = @root.xpath('xmlns:updated').first.content
|
15
|
+
self.next_page = @root.xpath("xmlns:link[@rel='next']").first.attribute('href').value
|
16
|
+
self.url = @root.xpath("xmlns:link[@rel='self']").first.attribute('href').value
|
17
|
+
|
18
|
+
self.entries = @root.xpath("xmlns:entry").collect do |entry|
|
19
|
+
Entry.new(entry).parse!
|
20
|
+
end
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.construct
|
25
|
+
doc = Nokogiri::XML(open("http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml"))
|
26
|
+
feed = GoApiClient::Atom::Feed.new(doc.root).parse!
|
27
|
+
pipelines = []
|
28
|
+
feed.entries.collect do |entry|
|
29
|
+
pipelines = Stage.new(entry, pipelines).fetch
|
30
|
+
end
|
31
|
+
pipelines
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
class Stage
|
38
|
+
attr_reader :authors, :details_link, :name, :result
|
39
|
+
|
40
|
+
def initialize(entry, pipelines)
|
41
|
+
@authors = entry.authors
|
42
|
+
@details_link = entry.stage_href
|
43
|
+
@pipelines = pipelines
|
44
|
+
end
|
45
|
+
|
46
|
+
def fetch
|
47
|
+
doc = Nokogiri::XML(open(self.details_link))
|
48
|
+
@name = doc.root.xpath("@name").first.value
|
49
|
+
@result = doc.root.xpath("//result").first.content
|
50
|
+
|
51
|
+
pipeline_link = doc.root.xpath("//pipeline").first.attributes["href"].value
|
52
|
+
existing_pipeline = @pipelines.find {|p| p.same?(pipeline_link)}
|
53
|
+
|
54
|
+
if existing_pipeline
|
55
|
+
existing_pipeline.stages << self
|
56
|
+
else
|
57
|
+
new_pipeline = Pipeline.new(pipeline_link).fetch
|
58
|
+
new_pipeline.stages << self
|
59
|
+
@pipelines << new_pipeline
|
60
|
+
end
|
61
|
+
@pipelines
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Pipeline
|
66
|
+
attr_reader :details_link, :id
|
67
|
+
attr_accessor :stages
|
68
|
+
|
69
|
+
def initialize(details_link)
|
70
|
+
@details_link = details_link
|
71
|
+
@stages = []
|
72
|
+
end
|
73
|
+
|
74
|
+
def fetch
|
75
|
+
doc = Nokogiri::XML(open(self.details_link))
|
76
|
+
@label = doc.root.attributes["label"].value
|
77
|
+
@id = doc.root.xpath("//id").first.content
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
def same?(link)
|
82
|
+
@details_link == link
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module GoApiClient
|
3
|
+
class StubHttpFetcher
|
4
|
+
# Careful : this will respond to any call with nil
|
5
|
+
class HashStruct < OpenStruct
|
6
|
+
def [](key)
|
7
|
+
self.headers[key]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Response
|
12
|
+
def invoked!
|
13
|
+
@invoked = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def invoked?
|
17
|
+
!!@invoked
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class StringResponse
|
22
|
+
include Response
|
23
|
+
def initialize(content, code = 200, headers = {})
|
24
|
+
@content = content
|
25
|
+
@code = code.to_s
|
26
|
+
@headers = headers
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute
|
30
|
+
HashStruct.new(:body => @content, :code => @code, :headers => @headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class ErrorResponse
|
36
|
+
include Response
|
37
|
+
def initialize(error)
|
38
|
+
@error = error
|
39
|
+
end
|
40
|
+
|
41
|
+
def execute
|
42
|
+
raise @error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def get(url)
|
47
|
+
if body = interweb[:get][url]
|
48
|
+
body.invoked!
|
49
|
+
return body.execute
|
50
|
+
else
|
51
|
+
raise "404 - Could not find #{url}. Available URLs are #{@interweb[:get].keys.inspect}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def post(url, params = {})
|
56
|
+
if body = interweb[:post][url]
|
57
|
+
response = body.execute
|
58
|
+
if response.headers == params
|
59
|
+
body.invoked!
|
60
|
+
return response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
raise "404 - Could not find a url listening to #{url.inspect} that responds to post params #{params.inspect}. Available URLs are #{@interweb[:post].keys.inspect}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def invoked?(url, type = :get, params = {})
|
68
|
+
if body = interweb[type][url]
|
69
|
+
response = body.execute
|
70
|
+
if response.headers == params
|
71
|
+
|
72
|
+
body.invoked?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def register_content(content, url, type = :get, headers = {})
|
78
|
+
interweb[type][url] = StringResponse.new(content, 200, headers)
|
79
|
+
end
|
80
|
+
|
81
|
+
def register_error(url, type = :get, error)
|
82
|
+
interweb[type][url] = ErrorResponse.new(error)
|
83
|
+
end
|
84
|
+
|
85
|
+
def interweb
|
86
|
+
@interweb ||= {:get => {}, :post => {}}
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'go_api_client/test/stub_http_fetcher.rb'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require "go_api_client/version"
|
3
|
+
require "go_api_client/atom"
|
4
|
+
require "open-uri"
|
5
|
+
module GoApiClient
|
6
|
+
def self.runs(host)
|
7
|
+
doc = Nokogiri::XML(open("http://#{host}/go/api/pipelines/defaultPipeline/stages.xml"))
|
8
|
+
feed = GoApiClient::Atom::Feed.new(doc.root).parse!
|
9
|
+
pipelines = []
|
10
|
+
feed.entries.collect do |entry|
|
11
|
+
pipelines = Stage.new(entry, pipelines).fetch
|
12
|
+
end
|
13
|
+
pipelines
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<pipeline name="defaultPipeline" counter="1" label="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:job-id:defaultPipeline:1]]></id>
|
6
|
+
<scheduleTime>2012-02-23T17:16:15+05:30</scheduleTime>
|
7
|
+
<materials>
|
8
|
+
<material materialUri="http://localhost:8153/go/api/materials/1.xml" type="GitMaterial" url="git@github.com:oogabooga/zinger.git" branch="master">
|
9
|
+
<modifications>
|
10
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/9f77888d7a594699894a17f4d61fc9dfac3cfb74.xml">
|
11
|
+
<user><![CDATA[oogabooga <twgosaas@gmail.com>]]></user>
|
12
|
+
<checkinTime>2012-02-21T15:41:30+05:30</checkinTime>
|
13
|
+
<revision><![CDATA[9f77888d7a594699894a17f4d61fc9dfac3cfb74]]></revision>
|
14
|
+
<message><![CDATA[Update README]]></message>
|
15
|
+
<file name="README" action="modified"/>
|
16
|
+
</changeset>
|
17
|
+
</modifications>
|
18
|
+
</material>
|
19
|
+
</materials>
|
20
|
+
<stages>
|
21
|
+
<stage href="http://localhost:8153/go/api/stages/1.xml"/>
|
22
|
+
<stage href="http://localhost:8153/go/api/stages/2.xml"/>
|
23
|
+
</stages>
|
24
|
+
<approvedBy><![CDATA[changes]]></approvedBy>
|
25
|
+
</pipeline>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:go="http://www.thoughtworks-studios.com/ns/go">
|
2
|
+
<title><![CDATA[defaultPipeline]]></title>
|
3
|
+
<id>http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml</id>
|
4
|
+
<author>
|
5
|
+
<name>Go</name>
|
6
|
+
</author>
|
7
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
8
|
+
<link rel="self" href="http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml"/>
|
9
|
+
|
10
|
+
|
11
|
+
<link rel="next" href="http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml?before=6"/>
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<entry>
|
16
|
+
<title><![CDATA[defaultPipeline(1) stage Acceptance(1) Failed]]></title>
|
17
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
18
|
+
<id>http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1</id>
|
19
|
+
|
20
|
+
|
21
|
+
<author>
|
22
|
+
<name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name>
|
23
|
+
</author>
|
24
|
+
|
25
|
+
|
26
|
+
<link title="Acceptance Stage Detail" href="http://localhost:8153/go/api/stages/2.xml" rel="alternate" type="application/vnd.go+xml"/>
|
27
|
+
<link title="Acceptance Stage Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1" rel="alternate" type="text/html"/>
|
28
|
+
|
29
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="application/vnd.go+xml"/>
|
30
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1/pipeline" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="text/html"/>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="stage" label="Stage" />
|
35
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="completed" label="Completed" />
|
36
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="failed" label="Failed" />
|
37
|
+
</entry>
|
38
|
+
|
39
|
+
<entry>
|
40
|
+
<title><![CDATA[defaultPipeline(1) stage Units(1) Failed]]></title>
|
41
|
+
<updated>2012-02-23T17:16:41+05:30</updated>
|
42
|
+
<id>http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1</id>
|
43
|
+
|
44
|
+
|
45
|
+
<author>
|
46
|
+
<name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name>
|
47
|
+
</author>
|
48
|
+
|
49
|
+
|
50
|
+
<link title="Units Stage Detail" href="http://localhost:8153/go/api/stages/1.xml" rel="alternate" type="application/vnd.go+xml"/>
|
51
|
+
<link title="Units Stage Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1" rel="alternate" type="text/html"/>
|
52
|
+
|
53
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="application/vnd.go+xml"/>
|
54
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1/pipeline" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="text/html"/>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="stage" label="Stage" />
|
59
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="completed" label="Completed" />
|
60
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="failed" label="Failed" />
|
61
|
+
</entry>
|
62
|
+
|
63
|
+
</feed>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<stage name="Units" counter="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/stages/1.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Units:1]]></id>
|
6
|
+
<pipeline name="defaultPipeline" counter="1" label="1" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
7
|
+
<updated>2012-02-23T17:16:41+05:30</updated>
|
8
|
+
<result>Failed</result>
|
9
|
+
<state>Completed</state>
|
10
|
+
<approvedBy><![CDATA[changes]]></approvedBy>
|
11
|
+
<jobs>
|
12
|
+
<job href="http://localhost:8153/go/api/jobs/1.xml"/>
|
13
|
+
</jobs>
|
14
|
+
</stage>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<stage name="Acceptance" counter="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/stages/2.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Acceptance:1]]></id>
|
6
|
+
<pipeline name="defaultPipeline" counter="1" label="1" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
7
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
8
|
+
<result>Failed</result>
|
9
|
+
<state>Completed</state>
|
10
|
+
<approvedBy><![CDATA[anonymous]]></approvedBy>
|
11
|
+
<jobs>
|
12
|
+
<job href="http://localhost:8153/go/api/jobs/2.xml"/>
|
13
|
+
</jobs>
|
14
|
+
</stage>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class IntegrationTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_end_to_end
|
6
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml").to_return(:body => file_contents("stages.xml"))
|
7
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml").to_return(:body => file_contents("pipelines_1.xml"))
|
8
|
+
stub_request(:get, "http://localhost:8153/go/api/stages/1.xml").to_return(:body => file_contents("stages_1.xml"))
|
9
|
+
stub_request(:get, "http://localhost:8153/go/api/stages/2.xml").to_return(:body => file_contents("stages_2.xml"))
|
10
|
+
pipelines = GoApiClient.runs("localhost:8153")
|
11
|
+
assert_equal 1, pipelines.count
|
12
|
+
stages = pipelines.first.stages
|
13
|
+
assert_equal 2, stages.count
|
14
|
+
stages.each do |stage|
|
15
|
+
assert_equal "oogabooga <twgosaas@gmail.com>", stage.authors.first.name
|
16
|
+
assert_equal "Failed", stage.result
|
17
|
+
end
|
18
|
+
assert_equal "Acceptance", stages.first.name
|
19
|
+
assert_equal "Units", stages.last.name
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_contents(file_name)
|
23
|
+
File.read(File.expand_path("../../fixtures/#{file_name}", __FILE__))
|
24
|
+
end
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: go_api_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nikhil Mungel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70232878359900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70232878359900
|
25
|
+
description: This gem parses atom feed generated by the Go Continuous Integration
|
26
|
+
server and provides an OO representation of the pipelines and stages.
|
27
|
+
email:
|
28
|
+
- hyfather@gmail.com
|
29
|
+
executables:
|
30
|
+
- go_api_client
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- README.textile
|
38
|
+
- Rakefile
|
39
|
+
- bin/go_api_client
|
40
|
+
- go_api_client.gemspec
|
41
|
+
- lib/go_api_client.rb
|
42
|
+
- lib/go_api_client/atom.rb
|
43
|
+
- lib/go_api_client/atom/author.rb
|
44
|
+
- lib/go_api_client/atom/entry.rb
|
45
|
+
- lib/go_api_client/atom/feed.rb
|
46
|
+
- lib/go_api_client/test.rb
|
47
|
+
- lib/go_api_client/test/stub_http_fetcher.rb
|
48
|
+
- lib/go_api_client/version.rb
|
49
|
+
- test/fixtures/pipelines_1.xml
|
50
|
+
- test/fixtures/stages.xml
|
51
|
+
- test/fixtures/stages_1.xml
|
52
|
+
- test/fixtures/stages_2.xml
|
53
|
+
- test/go_api_client/integration_test.rb
|
54
|
+
- test/test_helper.rb
|
55
|
+
homepage: ''
|
56
|
+
licenses: []
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project: go_api_client
|
75
|
+
rubygems_version: 1.8.15
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Client to parse Go CI atom feed
|
79
|
+
test_files:
|
80
|
+
- test/fixtures/pipelines_1.xml
|
81
|
+
- test/fixtures/stages.xml
|
82
|
+
- test/fixtures/stages_1.xml
|
83
|
+
- test/fixtures/stages_2.xml
|
84
|
+
- test/go_api_client/integration_test.rb
|
85
|
+
- test/test_helper.rb
|