integritray 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.log
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Josh French
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,21 @@
1
+ = integritray
2
+
3
+ Adds a CruiseControl.rb-style XML feed to Integrity (http://integrityapp.com)
4
+ for use with CCMenu and other tray items.
5
+
6
+ == Usage
7
+ Install the integritray gem:
8
+ gem install jfrench-integritray
9
+
10
+ Require in your Integrity application's config.ru:
11
+ require 'integrity/integritray'
12
+
13
+ Point CCMenu or your tray item of choice to the feed URL:
14
+ http://my.integration.server/projects.xml
15
+
16
+ You may have to manually specify that this is a CruiseControl.rb-type server;
17
+ CCMenu has trouble determining which type of server to treat this as.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2009 Josh French. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "integritray"
8
+ gem.summary = %Q{CCMenu support for Integrity}
9
+ gem.email = "josh@digitalpulp.com"
10
+ gem.homepage = "http://github.com/jfrench/integritray"
11
+ gem.authors = ["Josh French"]
12
+ end
13
+
14
+ rescue LoadError
15
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
+ end
17
+
18
+ require 'rake/testtask'
19
+ Rake::TestTask.new(:test) do |test|
20
+ test.libs << 'lib' << 'test'
21
+ test.pattern = 'test/**/*_test.rb'
22
+ test.verbose = true
23
+ end
24
+
25
+ begin
26
+ require 'rcov/rcovtask'
27
+ Rcov::RcovTask.new do |test|
28
+ test.libs << 'test'
29
+ test.pattern = 'test/**/*_test.rb'
30
+ test.verbose = true
31
+ end
32
+ rescue LoadError
33
+ task :rcov do
34
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
35
+ end
36
+ end
37
+
38
+
39
+ task :default => :test
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ if File.exist?('VERSION.yml')
44
+ config = YAML.load(File.read('VERSION.yml'))
45
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
46
+ else
47
+ version = ""
48
+ end
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "integritray #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
55
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,46 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{integritray}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Josh French"]
9
+ s.date = %q{2009-07-08}
10
+ s.email = %q{josh@digitalpulp.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "integritray.gemspec",
23
+ "lib/integrity/integritray.rb",
24
+ "test/acceptance/acceptance_helper.rb",
25
+ "test/acceptance/integritray_test.rb"
26
+ ]
27
+ s.homepage = %q{http://github.com/jfrench/integritray}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.4}
31
+ s.summary = %q{CCMenu support for Integrity}
32
+ s.test_files = [
33
+ "test/acceptance/acceptance_helper.rb",
34
+ "test/acceptance/integritray_test.rb"
35
+ ]
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ else
43
+ end
44
+ else
45
+ end
46
+ end
@@ -0,0 +1,49 @@
1
+ class Integrity::App < Sinatra::Default
2
+ get '/projects.xml' do
3
+ builder do |xml|
4
+ @projects = authorized? ? Project.all : Project.all(:public => true)
5
+ response["Content-Type"] = "application/xml; charset=utf-8"
6
+ xml.Projects do
7
+ @projects.each do |project|
8
+ xml.Project xml_opts_for_project(project)
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ # Move route definition with the literal routes where it won't be hidden behind any general matchers
15
+ xml_route = routes['GET'].pop
16
+ first_literal_route = routes['GET'].find { |route| route.first.inspect.include? 'integrity' }
17
+ routes['GET'].insert(routes['GET'].index(first_literal_route), xml_route)
18
+
19
+ private
20
+ def xml_opts_for_project(project)
21
+ opts = {}
22
+ opts['name'] = project.name
23
+ opts['category'] = project.branch
24
+ opts['activity'] = activity(project.last_commit.status)
25
+ opts['webUrl'] = project_url(project)
26
+ if project.last_commit
27
+ opts['lastBuildStatus'] = build_status(project.last_commit.status)
28
+ opts['lastBuildLabel'] = project.last_commit.short_identifier
29
+ opts['lastBuildTime'] = project.last_commit.build.completed_at if project.last_commit.build
30
+ end
31
+ opts
32
+ end
33
+
34
+ def activity(status)
35
+ case status
36
+ when :success, :failed then 'Sleeping'
37
+ when :pending then 'Building'
38
+ else 'Sleeping'
39
+ end
40
+ end
41
+
42
+ def build_status(status)
43
+ case status
44
+ when :success, :pending then 'Success'
45
+ when :failed then 'Failure'
46
+ else 'Unknown'
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,150 @@
1
+ $:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__)
2
+
3
+ require "rubygems"
4
+
5
+ require "test/unit"
6
+ require "rr"
7
+ require "mocha"
8
+ require "dm-sweatshop"
9
+ require "webrat/sinatra"
10
+
11
+ gem "jeremymcanally-context"
12
+ gem "jeremymcanally-matchy"
13
+ gem "jeremymcanally-pending"
14
+ require "context"
15
+ require "matchy"
16
+ require "pending"
17
+
18
+ require "integrity"
19
+ require "integrity/notifier/test/fixtures"
20
+
21
+ begin
22
+ require "ruby-debug"
23
+ require "redgreen"
24
+ rescue LoadError
25
+ end
26
+
27
+ module TestHelper
28
+ def ignore_logs!
29
+ Integrity.config[:log] = "/tmp/integrity.test.log"
30
+ end
31
+
32
+ def capture_stdout
33
+ output = StringIO.new
34
+ $stdout = output
35
+ yield
36
+ $stdout = STDOUT
37
+ output
38
+ end
39
+
40
+ def silence_warnings
41
+ $VERBOSE, v = nil, $VERBOSE
42
+ yield
43
+ ensure
44
+ $VERBOSE = v
45
+ end
46
+ end
47
+
48
+ class Test::Unit::TestCase
49
+ class << self
50
+ alias_method :specify, :test
51
+ end
52
+
53
+ include RR::Adapters::TestUnit
54
+ include Integrity
55
+ include TestHelper
56
+
57
+ before(:all) do
58
+ DataMapper.setup(:default, "sqlite3::memory:")
59
+
60
+ require "integrity/migrations"
61
+ end
62
+
63
+ before(:each) do
64
+ [Project, Build, Commit, Notifier].each{ |i| i.auto_migrate_down! }
65
+ capture_stdout { Integrity.migrate_db }
66
+ Notifier.available.clear
67
+ Integrity.instance_variable_set(:@config, nil)
68
+ end
69
+
70
+ after(:each) do
71
+ capture_stdout { Integrity::Migrations.migrate_down! }
72
+ end
73
+ end
74
+
75
+ gem "foca-storyteller"
76
+ require "storyteller"
77
+
78
+ module AcceptanceHelper
79
+ include FileUtils
80
+
81
+ def export_directory
82
+ File.dirname(__FILE__) + "/../../exports"
83
+ end
84
+
85
+ def enable_auth!
86
+ Integrity.config[:use_basic_auth] = true
87
+ Integrity.config[:admin_username] = "admin"
88
+ Integrity.config[:admin_password] = "test"
89
+ Integrity.config[:hash_admin_password] = false
90
+ end
91
+
92
+ def login_as(user, password)
93
+ def AcceptanceHelper.logged_in; true; end
94
+ basic_auth user, password
95
+ visit "/login"
96
+ Integrity::App.before { login_required if AcceptanceHelper.logged_in }
97
+ end
98
+
99
+ def log_out
100
+ def AcceptanceHelper.logged_in; false; end
101
+ @_webrat_session = Webrat::SinatraSession.new(self)
102
+ end
103
+
104
+ def disable_auth!
105
+ Integrity.config[:use_basic_auth] = false
106
+ end
107
+
108
+ def set_and_create_export_directory!
109
+ FileUtils.rm_r(export_directory) if File.directory?(export_directory)
110
+ FileUtils.mkdir(export_directory)
111
+ Integrity.config[:export_directory] = export_directory
112
+ end
113
+
114
+ def setup_log!
115
+ log_file = Pathname(File.dirname(__FILE__) + "/../../integrity.log")
116
+ log_file.delete if log_file.exist?
117
+ Integrity.config[:log] = log_file
118
+ end
119
+ end
120
+
121
+ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase
122
+ include AcceptanceHelper
123
+ include Test::Storyteller
124
+ include Webrat::Methods
125
+ include Webrat::Matchers
126
+ include Webrat::HaveTagMatcher
127
+
128
+ Webrat::Methods.delegate_to_session :response_code
129
+
130
+ def app
131
+ Integrity::App
132
+ end
133
+
134
+ before(:all) do
135
+ app.set(:environment, :test)
136
+ end
137
+
138
+ before(:each) do
139
+ # ensure each scenario is run in a clean sandbox
140
+ Integrity.config[:base_uri] = "http://www.example.com"
141
+ enable_auth!
142
+ setup_log!
143
+ set_and_create_export_directory!
144
+ log_out
145
+ end
146
+
147
+ after(:each) do
148
+ rm_r export_directory if File.directory?(export_directory)
149
+ end
150
+ end
@@ -0,0 +1,58 @@
1
+ # Unclear how to get ahold of Integrity's test helpers externally. For now,
2
+ # I've been copying this into an unpacked version of Integrity and running it
3
+ # there.
4
+
5
+ require File.dirname(__FILE__) + "/acceptance_helper"
6
+ require 'integrity/integritray'
7
+
8
+ class IntegritrayTest < Test::Unit::AcceptanceTestCase
9
+ include Integrity::Helpers::Urls
10
+
11
+ story <<-EOS
12
+ As a user,
13
+ I want an XML representation of my projects
14
+ So I can use CCMenu with Integrity
15
+ EOS
16
+
17
+ scenario "projects.xml has a tag representing my project" do
18
+ project = Project.gen(:integrity, :public => true, :commits => 2.of { Commit.gen(:successful)})
19
+ commit = project.last_commit
20
+ visit "/projects.xml"
21
+
22
+ assert_have_tag("projects")
23
+ assert_have_tag("projects/project[@name='Integrity']")
24
+ assert_have_tag("projects/project[@lastbuildlabel='#{commit.short_identifier}']")
25
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
26
+ assert_have_tag("projects/project[@category='#{project.branch}']")
27
+ assert_have_tag("projects/project[@activity='Sleeping']")
28
+ assert_have_tag("projects/project[@lastbuildstatus='Success']")
29
+ end
30
+
31
+ scenario "projects.xml has a tag representing my pending project" do
32
+ project = Project.gen(:integrity, :public => true, :commits => 2.of { Commit.gen(:pending)})
33
+ commit = project.last_commit
34
+ visit "/projects.xml"
35
+
36
+ assert_have_tag("projects")
37
+ assert_have_tag("projects/project[@name='Integrity']")
38
+ assert_have_tag("projects/project[@lastbuildlabel='#{commit.short_identifier}']")
39
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
40
+ assert_have_tag("projects/project[@category='#{project.branch}']")
41
+ assert_have_tag("projects/project[@activity='Building']")
42
+ assert_have_tag("projects/project[@lastbuildstatus='Success']")
43
+ end
44
+
45
+ scenario "projects.xml has a tag representing my failed project" do
46
+ project = Project.gen(:integrity, :public => true, :commits => 2.of { Commit.gen(:failed)})
47
+ commit = project.last_commit
48
+ visit "/projects.xml"
49
+
50
+ assert_have_tag("projects")
51
+ assert_have_tag("projects/project[@name='Integrity']")
52
+ assert_have_tag("projects/project[@lastbuildlabel='#{commit.short_identifier}']")
53
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
54
+ assert_have_tag("projects/project[@category='#{project.branch}']")
55
+ assert_have_tag("projects/project[@activity='Sleeping']")
56
+ assert_have_tag("projects/project[@lastbuildstatus='Failure']")
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: integritray
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh French
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-08 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: josh@digitalpulp.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - integritray.gemspec
33
+ - lib/integrity/integritray.rb
34
+ - test/acceptance/acceptance_helper.rb
35
+ - test/acceptance/integritray_test.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/jfrench/integritray
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.4
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: CCMenu support for Integrity
64
+ test_files:
65
+ - test/acceptance/acceptance_helper.rb
66
+ - test/acceptance/integritray_test.rb