go_cd_feed 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  coverage
2
3
  .bundle
3
4
  bundle/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p484
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- go_api_client (0.2.0)
4
+ go_cd_feed (1.0.0)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -9,8 +9,10 @@ GEM
9
9
  specs:
10
10
  addressable (2.2.7)
11
11
  crack (0.3.1)
12
+ mini_portile (0.6.0)
12
13
  multi_json (1.2.0)
13
- nokogiri (1.5.2)
14
+ nokogiri (1.6.2.1)
15
+ mini_portile (= 0.6.0)
14
16
  rake (0.9.2.2)
15
17
  simplecov (0.6.1)
16
18
  multi_json (~> 1.0)
@@ -25,7 +27,7 @@ PLATFORMS
25
27
  ruby
26
28
 
27
29
  DEPENDENCIES
28
- go_api_client!
30
+ go_cd_feed!
29
31
  rake
30
32
  simplecov
31
33
  test-unit
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ Go.CD Feed Gem
2
+ ==============
3
+
4
+ This gem provides an object-oriented model around the event feed for [Go.CD](http://go.cd)
5
+
6
+ It is a fork of the original gem, [go_api_client](https://github.com/ThoughtWorksInc/go-api-client)
data/Rakefile CHANGED
@@ -1,12 +1,18 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rake/testtask'
3
3
 
4
+ task :quiet do
5
+ ENV['QUIET'] = 'true'
6
+ end
7
+
4
8
  desc "Run all tests"
5
9
  Rake::TestTask.new do |t|
6
10
  t.libs << "test"
7
11
  t.test_files = FileList['test/**/*test.rb']
8
12
  t.verbose = true
9
- end
13
+ end
14
+
15
+ task :test => :quiet
10
16
 
11
17
  desc "upload the gem to artifact repository"
12
18
  task :upload do
@@ -36,4 +42,4 @@ task :upload do
36
42
  end
37
43
 
38
44
  desc "the default task"
39
- task :default => :test
45
+ task :default => :test
@@ -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.0.0'
6
+ s.version = '1.1.0'
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"
@@ -3,11 +3,10 @@ module GoApiClient
3
3
  class Feed
4
4
  attr_accessor :feed_pages, :entries
5
5
 
6
- PAGE_FETCH_LIMIT = 2
7
-
8
- def initialize(atom_feed_url, last_entry_id=nil)
6
+ def initialize(atom_feed_url, last_entry_id=nil, page_fetch_limit=nil)
9
7
  @atom_feed_url = atom_feed_url
10
8
  @last_entry_id = last_entry_id
9
+ @page_fetch_limit = page_fetch_limit
11
10
  end
12
11
 
13
12
  def fetch!(http_fetcher = HttpFetcher.new)
@@ -18,11 +17,11 @@ module GoApiClient
18
17
  begin
19
18
  doc = Nokogiri::XML(http_fetcher.get_response_body(feed_url))
20
19
  pages_fetched += 1
21
- if pages_fetched > PAGE_FETCH_LIMIT
20
+ if @page_fetch_limit && pages_fetched > @page_fetch_limit
22
21
  puts "=" * 100
23
22
  puts ""
24
- puts "[GO WATCHDOG] not fetching past #{PAGE_FETCH_LIMIT} pages of the Go event feed."
25
- puts "If there is no green build in those pages, Go Watchdog may not work properly."
23
+ puts "[GoApiClient] not fetching past #{page_fetch_limit} pages of the Go.CD event feed."
24
+ puts "If there is no green build in those pages, your app may not work properly."
26
25
  puts "Get your build green first!"
27
26
  puts ""
28
27
  puts "=" * 100
@@ -0,0 +1,21 @@
1
+ module GoApiClient
2
+
3
+ class DependencyMaterial
4
+
5
+ attr_reader :pipeline_name, :stage_name, :identifier
6
+
7
+ def initialize(root)
8
+ @root = root
9
+ end
10
+
11
+ def parse!
12
+ @pipeline_name = @root['pipelineName']
13
+ @stage_name = @root['stageName']
14
+ @identifier = @root.xpath('./modifications/changeset/revision').first.content
15
+ @root = nil
16
+ self
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -12,7 +12,7 @@ module GoApiClient
12
12
  def get(url, options={})
13
13
  uri = URI.parse(url)
14
14
 
15
- puts "[DEBUG] fetching #{url}"
15
+ puts "[DEBUG] fetching #{url}" unless ENV['QUIET']
16
16
 
17
17
  password = options[:password] || uri.password || @password
18
18
  username = options[:username] || uri.user || @username
@@ -1,6 +1,6 @@
1
1
  module GoApiClient
2
2
  class Pipeline
3
- attr_accessor :url, :commits, :label, :counter, :authors, :stages, :name, :http_fetcher, :identifier, :schedule_time
3
+ attr_accessor :url, :commits, :label, :counter, :authors, :stages, :name, :http_fetcher, :identifier, :schedule_time, :dependencies
4
4
 
5
5
  include GoApiClient::Helpers::SimpleAttributesSupport
6
6
 
@@ -31,6 +31,9 @@ module GoApiClient
31
31
  self.commits = @root.xpath('./materials/material[@type != "DependencyMaterial"]/modifications/changeset').collect do |changeset|
32
32
  Commit.new(changeset).parse!
33
33
  end
34
+ self.dependencies = @root.xpath('./materials/material[@type="DependencyMaterial"]').collect do |dependency|
35
+ DependencyMaterial.new(dependency).parse!
36
+ end
34
37
 
35
38
  @root = nil
36
39
  self
data/lib/go_api_client.rb CHANGED
@@ -11,10 +11,12 @@ require 'go_api_client/pipeline'
11
11
  require 'go_api_client/stage'
12
12
  require 'go_api_client/job'
13
13
  require 'go_api_client/commit'
14
+ require 'go_api_client/dependency_material'
14
15
  require 'go_api_client/user'
15
16
 
16
17
 
17
18
  module GoApiClient
19
+
18
20
  def self.runs(options)
19
21
  options = ({:protocol => 'http', :port => 8153, :username => nil, :password => nil, :latest_atom_entry_id => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
20
22
 
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <pipeline name="deploy-pasty" counter="1022" label="1022">
4
+ <link rel="self" href="https://go.thoughtworks.com/go/api/pipelines/deploy-pasty/173834.xml"/>
5
+ <id><![CDATA[urn:x-go.studios.thoughtworks.com:job-id:deploy-pasty:1022]]></id>
6
+ <link rel="insertedAfter" href="https://go.thoughtworks.com/go/api/pipelines/deploy-pasty/173823.xml"/>
7
+ <scheduleTime>2014-07-07T10:44:32-07:00</scheduleTime>
8
+ <materials>
9
+ <material materialUri="https://go.thoughtworks.com/go/api/materials/108307.xml" type="DependencyMaterial" pipelineName="acceptance-cupcake" stageName="acceptance">
10
+ <modifications>
11
+ <changeset changesetUri="https://go.thoughtworks.com/go/api/stages/353017.xml">
12
+ <checkinTime>2014-07-07T10:43:05-07:00</checkinTime>
13
+ <revision>acceptance-cupcake/931/acceptance/1</revision>
14
+ </changeset>
15
+ </modifications>
16
+ </material>
17
+ <material materialUri="https://go.thoughtworks.com/go/api/materials/18170.xml" type="GitMaterial" url="https://studios-scm.thoughtworks.com/saas" branch="master">
18
+ <modifications>
19
+ <changeset changesetUri="https://go.thoughtworks.com/go/api/materials/18170/changeset/ec4365b7377988cddde6575364f0d2a9d2d8b37a.xml">
20
+ <user><![CDATA[smarker <bill.dephillips@gmail.com>]]></user>
21
+ <checkinTime>2014-07-03T14:08:55-07:00</checkinTime>
22
+ <revision><![CDATA[ec4365b7377988cddde6575364f0d2a9d2d8b37a]]></revision>
23
+ <message><![CDATA[upgrade eb_deployer to solve
24
+ AWS::ElasticBeanstalk::Errors::OperationInProgressFailure error when
25
+ concurrently deleting elasticbeanstalk versions]]></message>
26
+ <file name="Gemfile" action="modified"/>
27
+ <file name="Gemfile.lock" action="modified"/>
28
+ </changeset>
29
+ </modifications>
30
+ </material>
31
+ </materials>
32
+ <stages>
33
+ <stage href="https://go.thoughtworks.com/go/api/stages/353019.xml"/>
34
+ <stage href="https://go.thoughtworks.com/go/api/stages/353025.xml"/>
35
+ <stage href="https://go.thoughtworks.com/go/api/stages/353026.xml"/>
36
+ </stages>
37
+ <approvedBy><![CDATA[changes]]></approvedBy>
38
+ </pipeline>
@@ -0,0 +1,27 @@
1
+ require "test_helper"
2
+
3
+ module GoApiClient
4
+ class DependencyMaterialTest < Test::Unit::TestCase
5
+
6
+ test "should parse properly" do
7
+
8
+ doc = Nokogiri::XML.parse <<-XML
9
+ <material materialUri="https://go.thoughtworks.com/go/api/materials/108307.xml" type="DependencyMaterial" pipelineName="acceptance-cupcake" stageName="acceptance">
10
+ <modifications>
11
+ <changeset changesetUri="https://go.thoughtworks.com/go/api/stages/353017.xml">
12
+ <checkinTime>2014-07-07T10:43:05-07:00</checkinTime>
13
+ <revision>acceptance-cupcake/931/acceptance/1</revision>
14
+ </changeset>
15
+ </modifications>
16
+ </material>
17
+ XML
18
+
19
+ dependency = DependencyMaterial.new(doc.root).parse!
20
+ assert_equal 'acceptance-cupcake', dependency.pipeline_name
21
+ assert_equal 'acceptance', dependency.stage_name
22
+ assert_equal 'acceptance-cupcake/931/acceptance/1', dependency.identifier
23
+
24
+ end
25
+
26
+ end
27
+ end
@@ -5,6 +5,7 @@ module GoApiClient
5
5
 
6
6
  def setup
7
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/pipelines/defaultPipeline/2.xml").to_return(:body => file_contents("pipelines_with_pipeline_materials.xml"))
8
9
  end
9
10
 
10
11
  test "should fetch the pipeline xml and populate itself" do
@@ -30,5 +31,14 @@ module GoApiClient
30
31
  assert_equal [author_foo, author_bar], pipeline.authors
31
32
  end
32
33
 
34
+ test "should parse pipeline materias" do
35
+ link = 'http://localhost:8153/go/api/pipelines/defaultPipeline/2.xml'
36
+ pipeline = GoApiClient::Pipeline.from(link)
37
+
38
+ assert_equal 1, pipeline.commits.size
39
+ assert_equal 1, pipeline.dependencies.size
40
+
41
+ end
42
+
33
43
  end
34
44
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_cd_feed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Nikhil Mungel
@@ -11,76 +12,86 @@ authors:
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-07-11 00:00:00.000000000 Z
15
+ date: 2014-07-12 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: webmock
18
19
  requirement: !ruby/object:Gem::Requirement
20
+ none: false
19
21
  requirements:
20
- - - '>='
22
+ - - ! '>='
21
23
  - !ruby/object:Gem::Version
22
24
  version: '0'
23
25
  type: :development
24
26
  prerelease: false
25
27
  version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
26
29
  requirements:
27
- - - '>='
30
+ - - ! '>='
28
31
  - !ruby/object:Gem::Version
29
32
  version: '0'
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: simplecov
32
35
  requirement: !ruby/object:Gem::Requirement
36
+ none: false
33
37
  requirements:
34
- - - '>='
38
+ - - ! '>='
35
39
  - !ruby/object:Gem::Version
36
40
  version: '0'
37
41
  type: :development
38
42
  prerelease: false
39
43
  version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
40
45
  requirements:
41
- - - '>='
46
+ - - ! '>='
42
47
  - !ruby/object:Gem::Version
43
48
  version: '0'
44
49
  - !ruby/object:Gem::Dependency
45
50
  name: rake
46
51
  requirement: !ruby/object:Gem::Requirement
52
+ none: false
47
53
  requirements:
48
- - - '>='
54
+ - - ! '>='
49
55
  - !ruby/object:Gem::Version
50
56
  version: '0'
51
57
  type: :development
52
58
  prerelease: false
53
59
  version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
54
61
  requirements:
55
- - - '>='
62
+ - - ! '>='
56
63
  - !ruby/object:Gem::Version
57
64
  version: '0'
58
65
  - !ruby/object:Gem::Dependency
59
66
  name: test-unit
60
67
  requirement: !ruby/object:Gem::Requirement
68
+ none: false
61
69
  requirements:
62
- - - '>='
70
+ - - ! '>='
63
71
  - !ruby/object:Gem::Version
64
72
  version: '0'
65
73
  type: :development
66
74
  prerelease: false
67
75
  version_requirements: !ruby/object:Gem::Requirement
76
+ none: false
68
77
  requirements:
69
- - - '>='
78
+ - - ! '>='
70
79
  - !ruby/object:Gem::Version
71
80
  version: '0'
72
81
  - !ruby/object:Gem::Dependency
73
82
  name: nokogiri
74
83
  requirement: !ruby/object:Gem::Requirement
84
+ none: false
75
85
  requirements:
76
- - - '>='
86
+ - - ! '>='
77
87
  - !ruby/object:Gem::Version
78
88
  version: '0'
79
89
  type: :runtime
80
90
  prerelease: false
81
91
  version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
82
93
  requirements:
83
- - - '>='
94
+ - - ! '>='
84
95
  - !ruby/object:Gem::Version
85
96
  version: '0'
86
97
  description: (Fork of go_api_client) This gem parses atom feed generated by the Go.CD
@@ -96,14 +107,15 @@ extensions: []
96
107
  extra_rdoc_files: []
97
108
  files:
98
109
  - .gitignore
110
+ - .ruby-version
99
111
  - .rvmrc
100
112
  - .zeroci.yml
101
113
  - Gemfile
102
114
  - Gemfile.lock
103
- - README.textile
115
+ - README.md
104
116
  - Rakefile
105
117
  - bin/go_api_client
106
- - go_api_client.gemspec
118
+ - go_cd_feed.gemspec
107
119
  - lib/go_api_client.rb
108
120
  - lib/go_api_client/atom.rb
109
121
  - lib/go_api_client/atom/author.rb
@@ -111,6 +123,7 @@ files:
111
123
  - lib/go_api_client/atom/feed.rb
112
124
  - lib/go_api_client/atom/feed_page.rb
113
125
  - lib/go_api_client/commit.rb
126
+ - lib/go_api_client/dependency_material.rb
114
127
  - lib/go_api_client/helpers.rb
115
128
  - lib/go_api_client/helpers/simple_attribute_support.rb
116
129
  - lib/go_api_client/http_fetcher.rb
@@ -169,6 +182,7 @@ files:
169
182
  - test/fixtures/pagination/stages_before_7916973.xml
170
183
  - test/fixtures/pagination/stages_before_7959831.xml
171
184
  - test/fixtures/pipelines_1.xml
185
+ - test/fixtures/pipelines_with_pipeline_materials.xml
172
186
  - test/fixtures/stages.xml
173
187
  - test/fixtures/stages_1.xml
174
188
  - test/fixtures/stages_2.xml
@@ -179,6 +193,7 @@ files:
179
193
  - test/go_api_client/atom/feed_test.rb
180
194
  - test/go_api_client/building_test.rb
181
195
  - test/go_api_client/commit_test.rb
196
+ - test/go_api_client/dependency_material_test.rb
182
197
  - test/go_api_client/job_test.rb
183
198
  - test/go_api_client/pipeline_test.rb
184
199
  - test/go_api_client/stage_test.rb
@@ -186,26 +201,27 @@ files:
186
201
  - test/test_helper.rb
187
202
  homepage: http://github.com/rearadmiral/go-api-client.git
188
203
  licenses: []
189
- metadata: {}
190
204
  post_install_message:
191
205
  rdoc_options: []
192
206
  require_paths:
193
207
  - lib
194
208
  required_ruby_version: !ruby/object:Gem::Requirement
209
+ none: false
195
210
  requirements:
196
- - - '>='
211
+ - - ! '>='
197
212
  - !ruby/object:Gem::Version
198
213
  version: '0'
199
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
+ none: false
200
216
  requirements:
201
- - - '>='
217
+ - - ! '>='
202
218
  - !ruby/object:Gem::Version
203
219
  version: '0'
204
220
  requirements: []
205
221
  rubyforge_project: go_cd_feed
206
- rubygems_version: 2.0.14
222
+ rubygems_version: 1.8.21
207
223
  signing_key:
208
- specification_version: 4
224
+ specification_version: 3
209
225
  summary: Client to parse Go CI atom feed
210
226
  test_files:
211
227
  - test/fixtures/building/job_1.xml
@@ -255,6 +271,7 @@ test_files:
255
271
  - test/fixtures/pagination/stages_before_7916973.xml
256
272
  - test/fixtures/pagination/stages_before_7959831.xml
257
273
  - test/fixtures/pipelines_1.xml
274
+ - test/fixtures/pipelines_with_pipeline_materials.xml
258
275
  - test/fixtures/stages.xml
259
276
  - test/fixtures/stages_1.xml
260
277
  - test/fixtures/stages_2.xml
@@ -265,6 +282,7 @@ test_files:
265
282
  - test/go_api_client/atom/feed_test.rb
266
283
  - test/go_api_client/building_test.rb
267
284
  - test/go_api_client/commit_test.rb
285
+ - test/go_api_client/dependency_material_test.rb
268
286
  - test/go_api_client/job_test.rb
269
287
  - test/go_api_client/pipeline_test.rb
270
288
  - test/go_api_client/stage_test.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 086892ef807a155548eb78d3d29957a83a0dcaad
4
- data.tar.gz: ad11e247b17715789ca4c6d2c89b70e2620a7bb4
5
- SHA512:
6
- metadata.gz: 7a1d5677978816d8ce71f4175facb10b6e5f4bc52ce3484031e0bd241829882e44117f15b4fc7b95bf62ecc82844bf09df0ef7c78ec5b8beda9b3c8819220725
7
- data.tar.gz: 06fe1c81e5193525e59e3b677021a31ab1636ac4dcc51efcfadddd48d2e2035892db950f8f3be534748e9c4e5611c1c5f14046d4aaf5aaa3e918f82a9fa9010c
data/README.textile DELETED
@@ -1,36 +0,0 @@
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
-