go_cd_feed 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/go_cd_feed.gemspec +1 -1
- data/lib/go_api_client.rb +2 -1
- data/lib/go_api_client/atom/feed.rb +3 -3
- data/lib/go_api_client/git_material.rb +25 -0
- data/lib/go_api_client/pipeline.rb +3 -3
- data/test/go_api_client/commit_test.rb +3 -2
- data/test/go_api_client/git_material_test.rb +36 -0
- data/test/go_api_client/pipeline_test.rb +2 -2
- data/test/go_api_client/stage_test.rb +2 -2
- metadata +5 -2
data/Gemfile.lock
CHANGED
data/go_cd_feed.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "go_cd_feed"
|
6
|
-
s.version = '1.1.
|
6
|
+
s.version = '1.1.1'
|
7
7
|
s.authors = ["Nikhil Mungel", "Ketan Padegaonkar", "Shishir Das", "Bill DePhillips"]
|
8
8
|
s.email = ["hyfather@gmail.com", "KetanPadegaonkar@gmail.com", "shishir.das@gmail.com", "bill.dephillips@gmail.com"]
|
9
9
|
s.homepage = "http://github.com/rearadmiral/go-api-client.git"
|
data/lib/go_api_client.rb
CHANGED
@@ -10,6 +10,7 @@ require 'go_api_client/atom'
|
|
10
10
|
require 'go_api_client/pipeline'
|
11
11
|
require 'go_api_client/stage'
|
12
12
|
require 'go_api_client/job'
|
13
|
+
require 'go_api_client/git_material'
|
13
14
|
require 'go_api_client/commit'
|
14
15
|
require 'go_api_client/dependency_material'
|
15
16
|
require 'go_api_client/user'
|
@@ -24,7 +25,7 @@ module GoApiClient
|
|
24
25
|
|
25
26
|
feed_url = "#{options[:protocol]}://#{options[:host]}:#{options[:port]}/go/api/pipelines/#{options[:pipeline_name]}/stages.xml"
|
26
27
|
|
27
|
-
feed = GoApiClient::Atom::Feed.new(feed_url, options[:latest_atom_entry_id])
|
28
|
+
feed = GoApiClient::Atom::Feed.new(feed_url, options[:latest_atom_entry_id], options[:page_fetch_limit])
|
28
29
|
feed.fetch!(http_fetcher)
|
29
30
|
|
30
31
|
pipelines = {}
|
@@ -6,7 +6,7 @@ module GoApiClient
|
|
6
6
|
def initialize(atom_feed_url, last_entry_id=nil, page_fetch_limit=nil)
|
7
7
|
@atom_feed_url = atom_feed_url
|
8
8
|
@last_entry_id = last_entry_id
|
9
|
-
@page_fetch_limit = page_fetch_limit
|
9
|
+
@page_fetch_limit = page_fetch_limit.to_i
|
10
10
|
end
|
11
11
|
|
12
12
|
def fetch!(http_fetcher = HttpFetcher.new)
|
@@ -17,10 +17,10 @@ module GoApiClient
|
|
17
17
|
begin
|
18
18
|
doc = Nokogiri::XML(http_fetcher.get_response_body(feed_url))
|
19
19
|
pages_fetched += 1
|
20
|
-
if @page_fetch_limit && pages_fetched > @page_fetch_limit
|
20
|
+
if @page_fetch_limit > 0 && pages_fetched > @page_fetch_limit
|
21
21
|
puts "=" * 100
|
22
22
|
puts ""
|
23
|
-
puts "[GoApiClient] not fetching past #{page_fetch_limit} pages of the Go.CD event feed."
|
23
|
+
puts "[GoApiClient] not fetching past #{@page_fetch_limit} pages of the Go.CD event feed."
|
24
24
|
puts "If there is no green build in those pages, your app may not work properly."
|
25
25
|
puts "Get your build green first!"
|
26
26
|
puts ""
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'commit'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
|
5
|
+
class GitMaterial
|
6
|
+
|
7
|
+
attr_reader :commits, :repository_url
|
8
|
+
|
9
|
+
def initialize(root)
|
10
|
+
@root = root
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse!
|
14
|
+
@repository_url = @root['url']
|
15
|
+
@commits = @root.xpath('./modifications/changeset').collect do |changeset|
|
16
|
+
Commit.new(changeset).parse!
|
17
|
+
end
|
18
|
+
@root = nil
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module GoApiClient
|
2
2
|
class Pipeline
|
3
|
-
attr_accessor :url, :
|
3
|
+
attr_accessor :url, :label, :counter, :authors, :stages, :name, :http_fetcher, :identifier, :schedule_time, :dependencies, :materials
|
4
4
|
|
5
5
|
include GoApiClient::Helpers::SimpleAttributesSupport
|
6
6
|
|
@@ -28,8 +28,8 @@ module GoApiClient
|
|
28
28
|
self.url = href_from(@root.xpath("./link[@rel='self']"))
|
29
29
|
self.identifier = @root.xpath("./id").first.content
|
30
30
|
self.schedule_time = Time.parse(@root.xpath('./scheduleTime').first.content).utc
|
31
|
-
self.
|
32
|
-
|
31
|
+
self.materials = @root.xpath('./materials/material[@type="GitMaterial"]').collect do |git_material|
|
32
|
+
GitMaterial.new(git_material).parse!
|
33
33
|
end
|
34
34
|
self.dependencies = @root.xpath('./materials/material[@type="DependencyMaterial"]').collect do |dependency|
|
35
35
|
DependencyMaterial.new(dependency).parse!
|
@@ -3,8 +3,9 @@ require "test_helper"
|
|
3
3
|
module GoApiClient
|
4
4
|
class CommitTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
test "should parse a changeset xml node" do
|
7
|
-
doc = Nokogiri::XML.parse %q{
|
6
|
+
test "should parse a material with changeset xml node" do
|
7
|
+
doc = Nokogiri::XML.parse %q{
|
8
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/9f77888d7a594699894a17f4d61fc9dfac3cfb74.xml">
|
8
9
|
<bar>
|
9
10
|
<revision>jhgasdfjkhgads</revision>
|
10
11
|
<message>some message</message>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class GitMaterialTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
test "should parse a material xml with 2 changesets" do
|
7
|
+
doc = Nokogiri::XML.parse %q{
|
8
|
+
<material materialUri="https://go.thoughtworks.com/go/api/materials/18170.xml" type="GitMaterial" url="https://studios-scm.thoughtworks.com/saas" branch="master">
|
9
|
+
<modifications>
|
10
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/9f77888d7a594699894a17f4d61fc9dfac3cfb74.xml">
|
11
|
+
<user><![CDATA[osito <osito@bonito.com>]]></user>
|
12
|
+
<checkinTime>2012-02-21T15:42:30+05:30</checkinTime>
|
13
|
+
<revision><![CDATA[9f77888d7a594699894a17f4d61fc9dfac3cfb74]]></revision>
|
14
|
+
<message><![CDATA[Update README]]></message>
|
15
|
+
<file name="README" action="modified"/>
|
16
|
+
</changeset>
|
17
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/abcd123.xml">
|
18
|
+
<user><![CDATA[zorro <zorro@poms.net>]]></user>
|
19
|
+
<checkinTime>2012-02-20T15:41:30+05:30</checkinTime>
|
20
|
+
<revision><![CDATA[abcd123]]></revision>
|
21
|
+
<message><![CDATA[fixin' the bugs]]></message>
|
22
|
+
<file name="buggy_code.rb" action="modified"/>
|
23
|
+
</changeset>
|
24
|
+
</modifications>
|
25
|
+
</material>
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
material = GitMaterial.new(doc.root).parse!
|
30
|
+
|
31
|
+
assert_equal "https://studios-scm.thoughtworks.com/saas", material.repository_url
|
32
|
+
assert_equal 2, material.commits.size
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -16,7 +16,7 @@ module GoApiClient
|
|
16
16
|
assert_equal 99, pipeline.counter
|
17
17
|
assert_equal "defaultPipeline", pipeline.name
|
18
18
|
assert_equal "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml", pipeline.url
|
19
|
-
assert_equal ["Update README", "Fixed build"], pipeline.commits.collect(&:message)
|
19
|
+
assert_equal ["Update README", "Fixed build"], pipeline.materials.map { |material| material.commits.collect(&:message) }.flatten
|
20
20
|
assert_equal "urn:x-go.studios.thoughtworks.com:job-id:defaultPipeline:1", pipeline.identifier
|
21
21
|
assert_equal Time.parse('2012-02-23 11:46:15 UTC'), pipeline.schedule_time
|
22
22
|
end
|
@@ -35,7 +35,7 @@ module GoApiClient
|
|
35
35
|
link = 'http://localhost:8153/go/api/pipelines/defaultPipeline/2.xml'
|
36
36
|
pipeline = GoApiClient::Pipeline.from(link)
|
37
37
|
|
38
|
-
assert_equal 1, pipeline.
|
38
|
+
assert_equal 1, pipeline.materials.size
|
39
39
|
assert_equal 1, pipeline.dependencies.size
|
40
40
|
|
41
41
|
end
|
@@ -38,7 +38,7 @@ module GoApiClient
|
|
38
38
|
|
39
39
|
assert_equal "http://localhost:8153/go/api/stages/1.xml", stages.first.url
|
40
40
|
assert_equal "http://localhost:8153/go/api/stages/2.xml", stages.last.url
|
41
|
-
|
41
|
+
|
42
42
|
assert_equal 1, stages.first.counter
|
43
43
|
assert_equal 1, stages.last.counter
|
44
44
|
|
@@ -56,7 +56,7 @@ module GoApiClient
|
|
56
56
|
assert_equal "Units", stages.first.name
|
57
57
|
assert_equal "Acceptance", stages.last.name
|
58
58
|
|
59
|
-
assert_equal ["Update README", "Fixed build"], pipelines.first.commits.collect(&:message)
|
59
|
+
assert_equal ["Update README", "Fixed build"], pipelines.first.materials.map { |material| material.commits.collect(&:message) }.flatten
|
60
60
|
|
61
61
|
assert_equal "http://localhost:8153/go/files/defaultPipeline/1/Units/1/Test/cruise-output/console.log", stages.first.jobs.first.console_log_url
|
62
62
|
assert_equal "http://localhost:8153/go/files/defaultPipeline/1/Acceptance/1/Test/cruise-output/console.log", stages.last.jobs.first.console_log_url
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_cd_feed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-07-
|
15
|
+
date: 2014-07-13 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: webmock
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/go_api_client/atom/feed_page.rb
|
125
125
|
- lib/go_api_client/commit.rb
|
126
126
|
- lib/go_api_client/dependency_material.rb
|
127
|
+
- lib/go_api_client/git_material.rb
|
127
128
|
- lib/go_api_client/helpers.rb
|
128
129
|
- lib/go_api_client/helpers/simple_attribute_support.rb
|
129
130
|
- lib/go_api_client/http_fetcher.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- test/go_api_client/building_test.rb
|
195
196
|
- test/go_api_client/commit_test.rb
|
196
197
|
- test/go_api_client/dependency_material_test.rb
|
198
|
+
- test/go_api_client/git_material_test.rb
|
197
199
|
- test/go_api_client/job_test.rb
|
198
200
|
- test/go_api_client/pipeline_test.rb
|
199
201
|
- test/go_api_client/stage_test.rb
|
@@ -283,6 +285,7 @@ test_files:
|
|
283
285
|
- test/go_api_client/building_test.rb
|
284
286
|
- test/go_api_client/commit_test.rb
|
285
287
|
- test/go_api_client/dependency_material_test.rb
|
288
|
+
- test/go_api_client/git_material_test.rb
|
286
289
|
- test/go_api_client/job_test.rb
|
287
290
|
- test/go_api_client/pipeline_test.rb
|
288
291
|
- test/go_api_client/stage_test.rb
|