gvarela-integritray 0.2.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/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ = 0.1.1
2
+ Fix build status when project is pending [Jonas Nicklas]
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,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gvarela-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", "Justin Smestad"]
12
+
13
+ gem.add_dependency 'sinatra', '>= 0.9.4'
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ if File.exist?('VERSION.yml')
46
+ config = YAML.load(File.read('VERSION.yml'))
47
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "integritray #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{integritray}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Josh French", "Justin Smestad"]
12
+ s.date = %q{2010-01-06}
13
+ s.email = %q{josh@digitalpulp.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "CHANGELOG",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "integritray.gemspec",
27
+ "lib/integrity/integritray.rb",
28
+ "test/acceptance/acceptance_helper.rb",
29
+ "test/acceptance/integritray_test.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/jfrench/integritray}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.5}
35
+ s.summary = %q{CCMenu support for Integrity}
36
+ s.test_files = [
37
+ "test/acceptance/acceptance_helper.rb",
38
+ "test/acceptance/integritray_test.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
47
+ else
48
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
52
+ end
53
+ end
54
+
@@ -0,0 +1,58 @@
1
+
2
+ module Integrity
3
+ module Integritray
4
+ module Helpers
5
+
6
+ def xml_opts_for_project(project)
7
+ opts = {}
8
+ opts['name'] = project.name
9
+ opts['category'] = project.branch
10
+ opts['activity'] = activity(project.last_build.status) if project.last_build
11
+ opts['webUrl'] = project_url(project)
12
+ if project.last_build
13
+ opts['lastBuildStatus'] = build_status(project.last_build.status)
14
+ opts['lastBuildLabel'] = project.last_build.commit.short_identifier
15
+ opts['lastBuildTime'] = project.last_build.completed_at
16
+ end
17
+ opts
18
+ end
19
+
20
+ def activity(status)
21
+ case status
22
+ when :success, :failed then 'Sleeping'
23
+ when :pending then 'Building'
24
+ else 'Sleeping'
25
+ end
26
+ end
27
+
28
+ def build_status(status)
29
+ case status
30
+ when :success, :pending then 'Success'
31
+ when :failed then 'Failure'
32
+ else 'Unknown'
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+
39
+ def self.registered(app)
40
+ app.helpers Integritray::Helpers
41
+
42
+ app.get '/projects.xml' do
43
+ login_required if params["private"]
44
+ builder do |xml|
45
+ @projects = authorized? ? Project.all : Project.all(:public => true)
46
+ response["Content-Type"] = "application/xml; charset=utf-8"
47
+ xml.Projects do
48
+ @projects.each do |project|
49
+ xml.Project xml_opts_for_project(project)
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ end # Integritray
58
+ end # Integrity
@@ -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,72 @@
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
+
59
+ scenario "projects.xml has a tag representing my unbuilt project" do
60
+ project = Project.gen(:integrity, :public => true)
61
+ commit = project.last_commit
62
+ puts commit.inspect
63
+ visit "/projects.xml"
64
+
65
+ assert_have_tag("projects")
66
+ assert_have_tag("projects/project[@name='Integrity']")
67
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
68
+ assert_have_tag("projects/project[@category='#{project.branch}']")
69
+ assert_have_no_tag("projects/project[@activity]")
70
+ assert_have_no_tag("projects/project[@lastbuildstatus]")
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gvarela-integritray
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh French
8
+ - Justin Smestad
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-01-06 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: sinatra
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.9.4
25
+ version:
26
+ description:
27
+ email: josh@digitalpulp.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - LICENSE
34
+ - README.rdoc
35
+ files:
36
+ - .document
37
+ - .gitignore
38
+ - CHANGELOG
39
+ - LICENSE
40
+ - README.rdoc
41
+ - Rakefile
42
+ - VERSION
43
+ - integritray.gemspec
44
+ - lib/integrity/integritray.rb
45
+ - test/acceptance/acceptance_helper.rb
46
+ - test/acceptance/integritray_test.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/jfrench/integritray
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.5
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: CCMenu support for Integrity
75
+ test_files:
76
+ - test/acceptance/acceptance_helper.rb
77
+ - test/acceptance/integritray_test.rb