cruisestatus 1.2.1 → 1.3.1

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/CRUISE_URL ADDED
@@ -0,0 +1 @@
1
+ http://runcoderun.com/api/v1/json/tobytripp
data/README.rdoc CHANGED
@@ -1,9 +1,16 @@
1
1
  = Cruise Status
2
2
 
3
- CruiseStatus allows your Ruby scripts to check the status of your project's
4
- build. Use this to abort check-ins when the build has failed, for example.
3
+ CruiseStatus allows your Ruby scripts to check the status of your project's
4
+ build. Use this to abort check-ins when the build has failed, for example.
5
5
 
6
- == Example:
6
+ CruiseStatus currently supports checking builds run on
7
+ cruisecontrol.rb[http://cruisecontrolrb.thoughtworks.com/] or on
8
+ runcoderun.com[http://runcoderun.com/].
9
+
10
+ == CruiseControl.rb Example:
11
+
12
+ To check a cruise.rb build, pass the url to the project RSS feed to
13
+ +CruiseStatus+:
7
14
 
8
15
  require "cruisestatus"
9
16
 
@@ -13,6 +20,53 @@ build. Use this to abort check-ins when the build has failed, for example.
13
20
  abort "Build failed…Boo!"
14
21
  end
15
22
 
23
+ == RunCodeRun.com Example:
24
+
25
+ To check a build on http://runcoderun.com, simply pass the url for the json
26
+ API:
27
+
28
+ require "cruisestatus"
29
+
30
+ if CruiseStatus.new( 'http://runcoderun.com/api/v1/json/tobytripp' ).pass?
31
+ puts "Build passed!"
32
+ else
33
+ abort "Build failed…boo!"
34
+ end
35
+
36
+ == Command-line Usage:
37
+
38
+ The gem's binary is +cruisestatus+. Pass a URL to it and +cruisestatus+ will
39
+ check the build status at that URL and return a non-zero status if any of the
40
+ builds reported there have failed.
41
+
42
+ Pass a `-p` option to prompt the user when a build has failed. If the user
43
+ enters 'y' at the prompt, +cruisestatus+ will return a zero status regardless
44
+ of build failures.
45
+
46
+ For example:
47
+ toby@Tobys-Mac:(git)cruisestatus[master]/$ cruisestatus -p http://runcoderun.com/api/v1/json/tobytripp
48
+
49
+ Build FAILURES: cruisestatus
50
+ Are you sure you want to check in? (y/n): y
51
+
52
+ toby@Tobys-Mac:(git)cruisestatus[master]/$ echo $?
53
+ 0
54
+
55
+ toby@Tobys-Mac:(git)cruisestatus[master]/$ cruisestatus -p http://runcoderun.com/api/v1/json/tobytripp
56
+
57
+ Build FAILURES: cruisestatus
58
+ Are you sure you want to check in? (y/n): n
59
+
60
+ toby@Tobys-Mac:(git)cruisestatus[master]/$ echo $?
61
+ 1
62
+ toby@Tobys-Mac:(git)cruisestatus[master]/$
63
+
64
+ You can use this to abort check-ins onto broken builds. (See the post-commit
65
+ hook in http://github.com/tobytripp/git-pre-commit for example). As you know,
66
+ if the CI build is broken, no one should be checking in new code unless
67
+ they're fixing the build. You can use +cruisestatus+ to help keep developers
68
+ honest in that regard.
69
+
16
70
  == Note on Patches/Pull Requests
17
71
 
18
72
  * Fork the project.
@@ -31,7 +85,6 @@ http://runcoderun.com/tobytripp/cruisestatus
31
85
  == TODO
32
86
 
33
87
  * Cruise.java support?
34
- * Support for runcoderun.com
35
88
 
36
89
  == Copyright
37
90
 
data/Rakefile CHANGED
@@ -3,13 +3,16 @@ require 'rake'
3
3
 
4
4
  begin
5
5
  require 'jeweler'
6
+ require "lib/cruisestatus/version"
6
7
  Jeweler::Tasks.new do |gem|
7
- gem.name = "cruisestatus"
8
- gem.summary = %Q{Check the build status on a cruise.rb server}
8
+ gem.name = "cruisestatus"
9
+ gem.summary = %Q{Check the build status on a cruise.rb server}
9
10
  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"]
11
+ gem.email = "toby.tripp+git@gmail.com"
12
+ gem.homepage = "http://github.com/tobytripp/cruisestatus"
13
+ gem.authors = ["Toby Tripp"]
14
+ gem.version = CruiseStatus::Version::STRING
15
+ gem.add_dependency "json_pure", ">= 1.2.0"
13
16
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
18
  end
@@ -19,13 +22,9 @@ rescue LoadError
19
22
  end
20
23
 
21
24
  require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
25
+ Spec::Rake::SpecTask.new
26
26
 
27
27
  Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
28
  spec.pattern = 'spec/**/*_spec.rb'
30
29
  spec.rcov = true
31
30
  end
data/bin/cruisestatus CHANGED
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env ruby -wKU
2
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
- require "cruisestatus"
4
- require "cruisestatus/command"
2
+ begin
3
+ require "cruisestatus"
4
+ require "cruisestatus/command"
5
+ rescue LoadError
6
+ require "rubygems"
7
+ require "cruisestatus"
8
+ require "cruisestatus/command"
9
+ end
5
10
 
6
11
  exit CruiseStatus::Command.run!( ARGV )
data/cruisestatus.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cruisestatus}
8
- s.version = "1.2.1"
8
+ s.version = "1.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Toby Tripp"]
12
- s.date = %q{2010-01-28}
12
+ s.date = %q{2010-02-10}
13
13
  s.default_executable = %q{cruisestatus}
14
14
  s.description = %q{Allows scripts and applications to check the status of your project's build.}
15
15
  s.email = %q{toby.tripp+git@gmail.com}
@@ -21,15 +21,22 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  ".document",
23
23
  ".gitignore",
24
+ "CRUISE_URL",
24
25
  "LICENSE",
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
- "VERSION",
28
28
  "bin/cruisestatus",
29
29
  "cruisestatus.gemspec",
30
30
  "lib/cruisestatus.rb",
31
31
  "lib/cruisestatus/command.rb",
32
+ "lib/cruisestatus/cruise_rb_parser.rb",
33
+ "lib/cruisestatus/feed_parser.rb",
34
+ "lib/cruisestatus/run_code_run_parser.rb",
35
+ "lib/cruisestatus/version.rb",
32
36
  "spec/cruisestatus/command_spec.rb",
37
+ "spec/cruisestatus/cruise_rb_parser_spec.rb",
38
+ "spec/cruisestatus/feed_parser_spec.rb",
39
+ "spec/cruisestatus/run_code_run_parser_spec.rb",
33
40
  "spec/cruisestatus_spec.rb",
34
41
  "spec/spec.opts",
35
42
  "spec/spec_helper.rb"
@@ -41,6 +48,9 @@ Gem::Specification.new do |s|
41
48
  s.summary = %q{Check the build status on a cruise.rb server}
42
49
  s.test_files = [
43
50
  "spec/cruisestatus/command_spec.rb",
51
+ "spec/cruisestatus/cruise_rb_parser_spec.rb",
52
+ "spec/cruisestatus/feed_parser_spec.rb",
53
+ "spec/cruisestatus/run_code_run_parser_spec.rb",
44
54
  "spec/cruisestatus_spec.rb",
45
55
  "spec/spec_helper.rb"
46
56
  ]
@@ -50,11 +60,14 @@ Gem::Specification.new do |s|
50
60
  s.specification_version = 3
51
61
 
52
62
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
63
+ s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
53
64
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
54
65
  else
66
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
55
67
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
56
68
  end
57
69
  else
70
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
58
71
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
72
  end
60
73
  end
@@ -1,32 +1,50 @@
1
1
  require "readline"
2
2
  require "optparse"
3
+ require "cruisestatus/version"
3
4
 
4
5
  class CruiseStatus::Command
5
6
  DEFAULT_PROMPT = "Are you sure you want to check in? (y/n): "
6
7
 
7
8
  def self.run!( argv )
8
- @prompt = nil
9
-
9
+ @prompt = nil
10
+
10
11
  opts = OptionParser.new do |o|
12
+ o.version = CruiseStatus::Version::STRING
13
+ o.release = CruiseStatus::Version::RELEASE
11
14
  o.banner = <<-EOS
12
- Usage: #{File.basename($0)} [options] CRUISE_RB_RSS_URL
15
+ Usage: #{File.basename($0)} [options] BUILD_URL
13
16
 
14
- Reads the feed at CRUISE_RB_RSS_URL and reports if the build[s] passed.
17
+ Reads the feed at BUILD_URL and reports if the build[s] passed.
15
18
 
16
- Examples:
17
- #{File.basename($0)} http://my.cruiseserver.com
18
- #{File.basename($0)} http://my.cruiseserver.com/projects.rss
19
- #{File.basename($0)} http://my.cruiseserver.com/projects/myproject.rss
20
-
19
+ Examples:
20
+ # CruiseControl.rb:
21
+ #{File.basename($0)} http://my.cruiseserver.com
22
+ #{File.basename($0)} http://my.cruiseserver.com/projects.rss
23
+ #{File.basename($0)} http://my.cruiseserver.com/projects/myproject.rss
24
+
25
+ # RunCodeRun.com:
26
+ #{File.basename($0)} http://runcoderun.com/api/v1/json/myusername
27
+
28
+ Options:
21
29
  EOS
22
30
 
23
- o.on( "-p", "--prompt" ) { |val| @prompt = DEFAULT_PROMPT }
31
+ o.on(
32
+ "-p", "--prompt", "=[PROMPT]",
33
+ "Prompt the user if the build has failed.",
34
+ "#{File.basename($0)} will exit with a non-zero status if the user does not respond 'y' to the prompt."
35
+ ) do |val|
36
+ if val == true
37
+ @prompt = DEFAULT_PROMPT
38
+ else
39
+ @prompt = val
40
+ end
41
+ end
24
42
  end
25
43
 
26
44
  opts.parse! argv
27
45
 
28
46
  if argv.empty?
29
- abort opts.banner
47
+ abort opts.to_s
30
48
  else
31
49
  status = CruiseStatus.new argv.last
32
50
 
@@ -0,0 +1,31 @@
1
+ require 'rexml/document'
2
+ require "open-uri"
3
+
4
+ require "cruisestatus/feed_parser"
5
+
6
+ class CruiseStatus
7
+ class CruiseRbParser < FeedParser
8
+ attr_accessor :url
9
+
10
+ def check
11
+ project_feed = @feed.read
12
+ @doc = REXML::Document.new project_feed
13
+ rescue Exception => e
14
+ @failures = [e.message]
15
+ @doc = REXML::Document.new ""
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
+
26
+ def url=( feed_url )
27
+ @url = feed_url
28
+ @url += '/projects.rss' unless feed_url =~ /\.rss$/
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ class CruiseStatus
2
+ class FeedParser
3
+ def self.for( url )
4
+ case url
5
+ when /^http:\/\/runcoderun\.com/
6
+ require "cruisestatus/run_code_run_parser"
7
+ CruiseStatus::RunCodeRunParser.new url
8
+ else
9
+ require "cruisestatus/cruise_rb_parser"
10
+ CruiseStatus::CruiseRbParser.new url
11
+ end
12
+ end
13
+
14
+ def initialize( url_or_io )
15
+ case url_or_io
16
+ when String
17
+ @feed = Kernel.open( url_or_io )
18
+ when IO, StringIO
19
+ @feed = url_or_io
20
+ else
21
+ raise "Please pass either a URI or an IO object to read."
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ require "open-uri"
2
+ begin
3
+ require "json"
4
+ rescue LoadError
5
+ require "rubygems"
6
+ require "json"
7
+ end
8
+ require "cruisestatus/feed_parser"
9
+
10
+ class CruiseStatus
11
+ class RunCodeRunParser < FeedParser
12
+ attr_accessor :url
13
+
14
+ def check
15
+ response_json = @feed.read
16
+ response = JSON.parse( response_json )
17
+ @failures = response["user"]["projects"].select { |proj|
18
+ proj["status"] != "success"
19
+ }.map { |proj| proj["name"] }
20
+ rescue Exception => e
21
+ @failures = [e.message]
22
+ end
23
+
24
+ def failures
25
+ @failures
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,10 @@
1
+ class CruiseStatus
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 3
5
+ PATCH = 1
6
+
7
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
+ RELEASE = "10 Feb 2010" # date "+%d %b %Y" # ^R
9
+ end
10
+ end
data/lib/cruisestatus.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'rexml/document'
2
- require "open-uri"
1
+ require "cruisestatus/feed_parser"
3
2
 
4
3
  # Checks the status of one or more project builds on a cruisecontrol.rb
5
4
  # server.
@@ -26,7 +25,7 @@ class CruiseStatus
26
25
  end
27
26
 
28
27
  # Check the given cruise feed and return true if all builds have passed.
29
- # False otherwise.
28
+ # Returns false otherwise.
30
29
  def self.check( feed_url )
31
30
  new( feed_url ).pass?
32
31
  end
@@ -34,27 +33,19 @@ class CruiseStatus
34
33
  # Update build status
35
34
  #
36
35
  def check
37
- project_feed = Kernel.open( feed_url ).read
38
- @doc = REXML::Document.new project_feed
39
- rescue Exception => e
40
- @failures = [e.message]
41
- @doc = REXML::Document.new ""
36
+ @feed_parser.check
42
37
  end
43
38
 
44
39
  # True if all builds described by the feed are passing.
45
40
  #
46
41
  def pass?
47
- failures.empty?
42
+ @feed_parser.failures.empty?
48
43
  end
49
44
 
50
45
  # A list of failing builds. Empty if all builds passed.
51
46
  #
52
47
  def failures
53
- @failures ||= REXML::XPath.match( @doc, "//item/title" ).select { |element|
54
- element.text =~ /failed$/
55
- }.map do |element|
56
- element.text.gsub( /(.*) build (.+) failed$/, '\1' )
57
- end
48
+ @feed_parser.failures
58
49
  end
59
50
 
60
51
  def failure_message
@@ -62,7 +53,6 @@ class CruiseStatus
62
53
  end
63
54
 
64
55
  def feed_url=( url )
65
- @feed_url = url
66
- @feed_url += '/projects.rss' unless url =~ /\.rss$/
56
+ @feed_parser = FeedParser.for( url )
67
57
  end
68
58
  end
@@ -10,7 +10,7 @@ describe CruiseStatus::Command do
10
10
  end
11
11
 
12
12
  it "passes the given url to the cruise status checker" do
13
- CruiseStatus.should_receive( :new ).with "url"
13
+ CruiseStatus.should_receive( :new ).with( "url" ).and_return @status
14
14
  CruiseStatus::Command.run! ["url"]
15
15
  end
16
16
 
@@ -0,0 +1,127 @@
1
+ require "spec_helper"
2
+ require "cruisestatus/cruise_rb_parser"
3
+
4
+ describe CruiseStatus::CruiseRbParser do
5
+ describe "on failed build" do
6
+ before :each do
7
+ @parser =
8
+ CruiseStatus::CruiseRbParser.new StringIO.new( CC_FAIL_RESPONSE )
9
+ @parser.check
10
+ end
11
+
12
+ it "parses the response correctly" do
13
+ @parser.failures.should == %w[failed]
14
+ end
15
+ end
16
+
17
+ describe "on passing build" do
18
+ before :each do
19
+ @parser =
20
+ CruiseStatus::CruiseRbParser.new StringIO.new( CC_PASS_RESPONSE )
21
+ @parser.check
22
+ end
23
+
24
+ it "parses the response correctly" do
25
+ @parser.failures.should == []
26
+ end
27
+ end
28
+
29
+ describe "on failed point build" do
30
+ before :each do
31
+ @parser = CruiseStatus::CruiseRbParser.
32
+ new StringIO.new( CC_FAIL_RESPONSE_ON_POINT_REVISION )
33
+ @parser.check
34
+ end
35
+
36
+ it "parses the response correctly" do
37
+ @parser.failures.should == ["my_project"]
38
+ end
39
+ end
40
+
41
+ describe "on failed connection" do
42
+ before :each do
43
+ io = StringIO.new("")
44
+ io.stub!(:read).and_raise( Exception )
45
+
46
+ @parser = CruiseStatus.new io
47
+ @parser.check
48
+ end
49
+
50
+ it "#failures is not empty" do
51
+ @parser.failures.should_not be_empty
52
+ end
53
+ end
54
+ end
55
+
56
+
57
+ CC_FAIL_RESPONSE = <<-EOS
58
+ <rss version="2.0">
59
+ <channel>
60
+ <title>CruiseControl RSS feed</title>
61
+ <link>http://localhost:3333/</link>
62
+ <description>CruiseControl projects and their build statuses</description>
63
+ <language>en-us</language>
64
+ <ttl>10</ttl>
65
+ <item>
66
+ <title>failed build 1126 failed</title>
67
+ <description>stuff</description>
68
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
69
+ <guid>http://localhost:3333/builds/failed/1126</guid>
70
+ <link>http://localhost:3333/builds/failed/1126</link>
71
+ </item>
72
+ <item>
73
+ <title>passed build 1126 success</title>
74
+ <description>stuff</description>
75
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
76
+ <guid>http://localhost:3333/builds/passed/1126</guid>
77
+ <link>http://localhost:3333/builds/passed/1126</link>
78
+ </item>
79
+ </channel>
80
+ </rss>
81
+ EOS
82
+
83
+ CC_FAIL_RESPONSE_ON_POINT_REVISION = <<-EOS
84
+ <rss version="2.0">
85
+ <channel>
86
+ <title>CruiseControl RSS feed</title>
87
+ <link>http://localhost:3333/</link>
88
+ <description>CruiseControl projects and their build statuses</description>
89
+ <language>en-us</language>
90
+ <ttl>10</ttl>
91
+ <item>
92
+ <title>my_project build 1126.1 failed</title>
93
+ <description>stuff</description>
94
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
95
+ <guid>http://localhost:3333/builds/failed/1126</guid>
96
+ <link>http://localhost:3333/builds/failed/1126</link>
97
+ </item>
98
+ </channel>
99
+ </rss>
100
+ EOS
101
+
102
+ CC_PASS_RESPONSE = <<-EOS
103
+ <rss version="2.0">
104
+ <channel>
105
+ <title>CruiseControl RSS feed</title>
106
+ <link>http://localhost:3333/</link>
107
+ <description>CruiseControl projects and their build statuses</description>
108
+ <language>en-us</language>
109
+ <ttl>10</ttl>
110
+ <item>
111
+ <title>passed build 1127 success</title>
112
+ <description>stuff</description>
113
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
114
+ <guid>http://localhost:3333/builds/passed/1127</guid>
115
+ <link>http://localhost:3333/builds/passed/1127</link>
116
+ </item>
117
+ <item>
118
+ <title>passed build 1126 success</title>
119
+ <description>stuff</description>
120
+ <pubDate>Tue, 17 Jun 2008 22:12:46 Z</pubDate>
121
+ <guid>http://localhost:3333/builds/passed/1126</guid>
122
+ <link>http://localhost:3333/builds/passed/1126</link>
123
+ </item>
124
+ </channel>
125
+ </rss>
126
+ EOS
127
+
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ describe CruiseStatus::FeedParser do
4
+ it "returns an instance of CruiseRbParser" do
5
+ CruiseStatus::CruiseRbParser.should_receive( :new )
6
+ CruiseStatus::FeedParser.for "foo"
7
+ end
8
+
9
+ it "returns an instance of RunCodeRunParser for runcoderun.com domain" do
10
+ CruiseStatus::RunCodeRunParser.should_receive( :new )
11
+ CruiseStatus::FeedParser.for "http://runcoderun.com/api/v1/json/tobytripp"
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+ require "cruisestatus/run_code_run_parser"
3
+
4
+ describe CruiseStatus::RunCodeRunParser do
5
+ describe "on passing builds" do
6
+ before :each do
7
+ @parser =
8
+ CruiseStatus::RunCodeRunParser.new StringIO.new( RCR_PASS_RESPONSE )
9
+ @parser.check
10
+ end
11
+
12
+ it "returns an empty failures list" do
13
+ @parser.failures.should == []
14
+ end
15
+ end
16
+
17
+ describe "on failing builds" do
18
+ before :each do
19
+ @parser =
20
+ CruiseStatus::RunCodeRunParser.new StringIO.new( RCR_FAIL_RESPONSE )
21
+ @parser.check
22
+ end
23
+
24
+ it "reports failing builds in the response" do
25
+ @parser.failures.should == ["cruisestatus"]
26
+ end
27
+ end
28
+ end
29
+
30
+ RCR_PASS_RESPONSE = <<-EOS
31
+ {"user":{"email":"toby.tripp+runcoderun.com@testmail.com","username":"tobytripp","projects":[{"ended_at":"2010-01-28T12:33:16-06:00","git_url":"http:\/\/github.com\/tobytripp\/cruisestatus","author_name":"Toby","url":"http:\/\/runcoderun.com\/tobytripp\/cruisestatus","branch":"refs\/heads\/master","commit":"7ced1af9afecbb6396b78f86341b4121f026248c","name":"cruisestatus","status":"success","description":"Check the status of your cruise.rb build from your Ruby scripts.","build_url":"http:\/\/runcoderun.com\/tobytripp\/cruisestatus\/builds\/7ced1af9afecbb6396b78f86341b4121f026248c","commit_message":"Regenerated gemspec for version 1.2.1"}]}}
32
+ EOS
33
+
34
+ RCR_FAIL_RESPONSE = <<-EOS
35
+ {"user":{"email":"toby.tripp+runcoderun.com@testmail.com","username":"tobytripp","projects":[{"ended_at":"2010-02-10T11:13:16-06:00","git_url":"http:\/\/github.com\/tobytripp\/cruisestatus","author_name":"Toby","url":"http:\/\/runcoderun.com\/tobytripp\/cruisestatus","branch":"refs\/heads\/master","commit":"9a951f0fdbefcd9a019f799049ce4658e6e3686f","name":"cruisestatus","status":"failure","description":"Check the status of your cruise.rb build from your Ruby scripts.","build_url":"http:\/\/runcoderun.com\/tobytripp\/cruisestatus\/builds\/9a951f0fdbefcd9a019f799049ce4658e6e3686f","commit_message":"Fix constant-collision"}]}}
36
+ EOS
@@ -1,17 +1,20 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe CruiseStatus do
4
-
5
4
  describe "on failed build" do
6
5
  before :each do
7
- io = mock( Object.new, :read => FAIL_RESPONSE )
8
- Kernel.stub!(:open).with( 'ccrb.rss' ).and_return io
6
+ @parser = mock( "failing feed parser",
7
+ :failures => ["failed build"],
8
+ :check => nil
9
+ )
10
+ CruiseStatus::FeedParser.stub!( :for ).and_return @parser
9
11
 
10
12
  @status = CruiseStatus.new 'ccrb.rss'
11
13
  end
12
14
 
13
- it "parses the response correctly" do
14
- @status.failures.should == %w[failed]
15
+ it "delegates #failures to the feed parser" do
16
+ @parser.should_receive( :failures ).and_return :failures
17
+ @status.failures.should == :failures
15
18
  end
16
19
 
17
20
  it "#pass? is false" do
@@ -21,103 +24,22 @@ describe CruiseStatus do
21
24
 
22
25
  describe "on passing build" do
23
26
  before :each do
24
- io = mock( Object.new, :read => PASS_RESPONSE )
25
- Kernel.stub!(:open).with( 'ccrb.rss' ).and_return io
27
+ @parser = mock( "passing feed parser",
28
+ :failures => [],
29
+ :check => nil
30
+ )
31
+ CruiseStatus::FeedParser.stub!( :for ).and_return @parser
26
32
 
27
33
  @status = CruiseStatus.new 'ccrb.rss'
28
34
  end
29
35
 
30
- it "parses the response correctly" do
31
- @status.failures.should == []
36
+ it "delegates #failures to the feed parser" do
37
+ @parser.should_receive( :failures ).and_return :failures
38
+ @status.failures.should == :failures
32
39
  end
33
40
 
34
41
  it "#pass? is true" do
35
42
  @status.should be_pass
36
43
  end
37
44
  end
38
-
39
- describe "on failed connection to cruise" do
40
- before :each do
41
- io = mock( Object.new ).stub!(:read).and_raise( Exception )
42
- Kernel.stub!(:open).with( 'ccrb.rss' ).and_return 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
45
  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_helper.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'cruisestatus'
4
- require 'cruisestatus/command'
5
3
 
6
4
  require "rubygems"
7
5
  require 'spec'
8
6
  require 'spec/autorun'
9
7
 
8
+ require 'cruisestatus'
9
+ require 'cruisestatus/command'
10
+
11
+
10
12
  Spec::Runner.configure do |config|
11
13
  def capture_stdout(&block)
12
14
  old_stdout, $stdout = $stdout, StringIO.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cruisestatus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Tripp
@@ -9,9 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-28 00:00:00 -06:00
12
+ date: 2010-02-10 00:00:00 -06:00
13
13
  default_executable: cruisestatus
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json_pure
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.0
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: rspec
17
27
  type: :development
@@ -34,15 +44,22 @@ extra_rdoc_files:
34
44
  files:
35
45
  - .document
36
46
  - .gitignore
47
+ - CRUISE_URL
37
48
  - LICENSE
38
49
  - README.rdoc
39
50
  - Rakefile
40
- - VERSION
41
51
  - bin/cruisestatus
42
52
  - cruisestatus.gemspec
43
53
  - lib/cruisestatus.rb
44
54
  - lib/cruisestatus/command.rb
55
+ - lib/cruisestatus/cruise_rb_parser.rb
56
+ - lib/cruisestatus/feed_parser.rb
57
+ - lib/cruisestatus/run_code_run_parser.rb
58
+ - lib/cruisestatus/version.rb
45
59
  - spec/cruisestatus/command_spec.rb
60
+ - spec/cruisestatus/cruise_rb_parser_spec.rb
61
+ - spec/cruisestatus/feed_parser_spec.rb
62
+ - spec/cruisestatus/run_code_run_parser_spec.rb
46
63
  - spec/cruisestatus_spec.rb
47
64
  - spec/spec.opts
48
65
  - spec/spec_helper.rb
@@ -76,5 +93,8 @@ specification_version: 3
76
93
  summary: Check the build status on a cruise.rb server
77
94
  test_files:
78
95
  - spec/cruisestatus/command_spec.rb
96
+ - spec/cruisestatus/cruise_rb_parser_spec.rb
97
+ - spec/cruisestatus/feed_parser_spec.rb
98
+ - spec/cruisestatus/run_code_run_parser_spec.rb
79
99
  - spec/cruisestatus_spec.rb
80
100
  - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.2.1