cruisestatus 1.0.0

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Toby
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = cruisestatus
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Toby. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "cruisestatus"
8
+ gem.summary = %Q{Check the build status on a cruise.rb server}
9
+ gem.description = %Q{Allows scripts and applications to check the status of your project's build.}
10
+ gem.email = "toby.tripp+git@gmail.com"
11
+ gem.homepage = "http://github.com/tobytripp/cruisestatus"
12
+ gem.authors = ["Toby Tripp"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "rr", ">= 0.10.5"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "CruiseStatus #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/cruisestatus ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby -wKU
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require "cruise_status"
4
+
5
+ unless ARGV.size == 1
6
+ $stderr.puts <<-EOS
7
+ cruisestatus: RSS feed url required.
8
+ Usage: cruisestatus CRUISE_RB_RSS_URL
9
+
10
+ Reads the feed at CRUISE_RB_RSS_URL and reports if the build[s] passed.
11
+
12
+ Example: cruisestatus http://my.cruiseserver.com/projects.rss
13
+
14
+ EOS
15
+ exit 1
16
+ end
17
+
18
+ status = CruiseStatus.new ARGV.first
19
+
20
+ unless status.pass?
21
+ puts "FAIL: #{status.failures.join( ', ' )}"
22
+ exit 1
23
+ else
24
+ puts "OK"
25
+ exit 0
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'rexml/document'
2
+ require "open-uri"
3
+
4
+ class CruiseStatus
5
+
6
+ def initialize( feed_url )
7
+ project_feed = Kernel.open( feed_url ).read
8
+ @doc = REXML::Document.new project_feed
9
+ rescue Exception => e
10
+ @failures = [e.message]
11
+ @doc = REXML::Document.new ""
12
+ end
13
+
14
+ def pass?
15
+ failures.empty?
16
+ end
17
+
18
+ def failures
19
+ @failures ||= REXML::XPath.match( @doc, "//item/title" ).select { |element|
20
+ element.text =~ /failed$/
21
+ }.map do |element|
22
+ element.text.gsub( /(.*) build (.+) failed$/, '\1' )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,123 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe CruiseStatus do
4
+
5
+ describe "on failed build" do
6
+ before :each do
7
+ stub( io = Object.new ).read { FAIL_RESPONSE }
8
+ stub( Kernel ).open( 'ccrb.rss' ) { io }
9
+
10
+ @status = CruiseStatus.new 'ccrb.rss'
11
+ end
12
+
13
+ it "parses the response correctly" do
14
+ @status.failures.should == %w[failed]
15
+ end
16
+
17
+ it "#pass? is false" do
18
+ @status.should_not be_pass
19
+ end
20
+ end
21
+
22
+ describe "on passing build" do
23
+ before :each do
24
+ stub( io = Object.new ).read { PASS_RESPONSE }
25
+ stub( Kernel ).open( 'ccrb.rss' ) { io }
26
+
27
+ @status = CruiseStatus.new 'ccrb.rss'
28
+ end
29
+
30
+ it "parses the response correctly" do
31
+ @status.failures.should == []
32
+ end
33
+
34
+ it "#pass? is true" do
35
+ @status.should be_pass
36
+ end
37
+ end
38
+
39
+ describe "on failed connection to cruise" do
40
+ before :each do
41
+ stub( io = Object.new ).read { raise Exception, 'Cannot connect' }
42
+ stub( Kernel ).open( 'ccrb.rss' ) { io }
43
+
44
+ @status = CruiseStatus.new 'ccrb.rss'
45
+ end
46
+
47
+ it "#pass? is false" do
48
+ @status.should_not be_pass
49
+ end
50
+ end
51
+ end
52
+
53
+ FAIL_RESPONSE = <<-EOS
54
+ <rss version="2.0">
55
+ <channel>
56
+ <title>CruiseControl RSS feed</title>
57
+ <link>http://localhost:3333/</link>
58
+ <description>CruiseControl projects and their build statuses</description>
59
+ <language>en-us</language>
60
+ <ttl>10</ttl>
61
+ <item>
62
+ <title>failed build 1126 failed</title>
63
+ <description>stuff</description>
64
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
65
+ <guid>http://localhost:3333/builds/failed/1126</guid>
66
+ <link>http://localhost:3333/builds/failed/1126</link>
67
+ </item>
68
+ <item>
69
+ <title>passed build 1126 success</title>
70
+ <description>stuff</description>
71
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
72
+ <guid>http://localhost:3333/builds/passed/1126</guid>
73
+ <link>http://localhost:3333/builds/passed/1126</link>
74
+ </item>
75
+ </channel>
76
+ </rss>
77
+ EOS
78
+
79
+ FAIL_RESPONSE_ON_POINT_REVISION = <<-EOS
80
+ <rss version="2.0">
81
+ <channel>
82
+ <title>CruiseControl RSS feed</title>
83
+ <link>http://localhost:3333/</link>
84
+ <description>CruiseControl projects and their build statuses</description>
85
+ <language>en-us</language>
86
+ <ttl>10</ttl>
87
+ <item>
88
+ <title>my_project build 1126.1 failed</title>
89
+ <description>stuff</description>
90
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
91
+ <guid>http://localhost:3333/builds/failed/1126</guid>
92
+ <link>http://localhost:3333/builds/failed/1126</link>
93
+ </item>
94
+ </channel>
95
+ </rss>
96
+ EOS
97
+
98
+ PASS_RESPONSE = <<-EOS
99
+ <rss version="2.0">
100
+ <channel>
101
+ <title>CruiseControl RSS feed</title>
102
+ <link>http://localhost:3333/</link>
103
+ <description>CruiseControl projects and their build statuses</description>
104
+ <language>en-us</language>
105
+ <ttl>10</ttl>
106
+ <item>
107
+ <title>passed build 1127 success</title>
108
+ <description>stuff</description>
109
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
110
+ <guid>http://localhost:3333/builds/passed/1127</guid>
111
+ <link>http://localhost:3333/builds/passed/1127</link>
112
+ </item>
113
+ <item>
114
+ <title>passed build 1126 success</title>
115
+ <description>stuff</description>
116
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
117
+ <guid>http://localhost:3333/builds/passed/1126</guid>
118
+ <link>http://localhost:3333/builds/passed/1126</link>
119
+ </item>
120
+ </channel>
121
+ </rss>
122
+ EOS
123
+
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'cruise_status'
4
+
5
+ require "rubygems"
6
+ require 'spec'
7
+ require 'spec/autorun'
8
+
9
+ require "rr"
10
+
11
+ Spec::Runner.configure do |config|
12
+ config.mock_with :rr
13
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cruisestatus
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Toby Tripp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-23 00:00:00 -06:00
13
+ default_executable: cruisestatus
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rr
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.5
34
+ version:
35
+ description: Allows scripts and applications to check the status of your project's build.
36
+ email: toby.tripp+git@gmail.com
37
+ executables:
38
+ - cruisestatus
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - bin/cruisestatus
52
+ - lib/cruise_status.rb
53
+ - spec/cruise_status_spec.rb
54
+ - spec/spec.opts
55
+ - spec/spec_helper.rb
56
+ has_rdoc: true
57
+ homepage: http://github.com/tobytripp/cruisestatus
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options:
62
+ - --charset=UTF-8
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.5
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Check the build status on a cruise.rb server
84
+ test_files:
85
+ - spec/cruise_status_spec.rb
86
+ - spec/spec_helper.rb