imbriaco-integrity 0.1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGES +36 -0
  3. data/README.markdown +79 -0
  4. data/Rakefile +79 -0
  5. data/bin/integrity +4 -0
  6. data/config/config.sample.ru +21 -0
  7. data/config/config.sample.yml +41 -0
  8. data/config/heroku/.gems +1 -0
  9. data/config/heroku/Rakefile +6 -0
  10. data/config/heroku/config.ru +7 -0
  11. data/config/heroku/integrity-config.rb +14 -0
  12. data/config/thin.sample.yml +13 -0
  13. data/integrity.gemspec +140 -0
  14. data/lib/integrity/app.rb +138 -0
  15. data/lib/integrity/author.rb +39 -0
  16. data/lib/integrity/build.rb +91 -0
  17. data/lib/integrity/commit.rb +63 -0
  18. data/lib/integrity/core_ext/object.rb +6 -0
  19. data/lib/integrity/helpers/authorization.rb +33 -0
  20. data/lib/integrity/helpers/breadcrumbs.rb +20 -0
  21. data/lib/integrity/helpers/forms.rb +29 -0
  22. data/lib/integrity/helpers/pretty_output.rb +45 -0
  23. data/lib/integrity/helpers/rendering.rb +25 -0
  24. data/lib/integrity/helpers/resources.rb +19 -0
  25. data/lib/integrity/helpers/urls.rb +59 -0
  26. data/lib/integrity/helpers.rb +16 -0
  27. data/lib/integrity/installer.rb +136 -0
  28. data/lib/integrity/migrations.rb +151 -0
  29. data/lib/integrity/notifier/base.rb +74 -0
  30. data/lib/integrity/notifier/test/fixtures.rb +108 -0
  31. data/lib/integrity/notifier/test/hpricot_matcher.rb +38 -0
  32. data/lib/integrity/notifier/test.rb +59 -0
  33. data/lib/integrity/notifier.rb +34 -0
  34. data/lib/integrity/project/deprecated.rb +17 -0
  35. data/lib/integrity/project/notifiers.rb +33 -0
  36. data/lib/integrity/project/push.rb +44 -0
  37. data/lib/integrity/project.rb +102 -0
  38. data/lib/integrity/project_builder.rb +56 -0
  39. data/lib/integrity/scm/git/uri.rb +57 -0
  40. data/lib/integrity/scm/git.rb +84 -0
  41. data/lib/integrity/scm.rb +19 -0
  42. data/lib/integrity.rb +101 -0
  43. data/public/buttons.css +82 -0
  44. data/public/reset.css +7 -0
  45. data/public/spinner.gif +0 -0
  46. data/test/acceptance/api_test.rb +97 -0
  47. data/test/acceptance/browse_project_builds_test.rb +65 -0
  48. data/test/acceptance/browse_project_test.rb +99 -0
  49. data/test/acceptance/build_notifications_test.rb +95 -0
  50. data/test/acceptance/create_project_test.rb +97 -0
  51. data/test/acceptance/delete_project_test.rb +53 -0
  52. data/test/acceptance/edit_project_test.rb +117 -0
  53. data/test/acceptance/error_page_test.rb +18 -0
  54. data/test/acceptance/installer_test.rb +79 -0
  55. data/test/acceptance/manual_build_project_test.rb +82 -0
  56. data/test/acceptance/not_found_page_test.rb +29 -0
  57. data/test/acceptance/project_syndication_test.rb +30 -0
  58. data/test/acceptance/stylesheet_test.rb +26 -0
  59. data/test/acceptance/unauthorized_page_test.rb +20 -0
  60. data/test/helpers/acceptance/email_notifier.rb +55 -0
  61. data/test/helpers/acceptance/git_helper.rb +99 -0
  62. data/test/helpers/acceptance/notifier_helper.rb +47 -0
  63. data/test/helpers/acceptance/textfile_notifier.rb +26 -0
  64. data/test/helpers/acceptance.rb +79 -0
  65. data/test/helpers/expectations/be_a.rb +23 -0
  66. data/test/helpers/expectations/change.rb +90 -0
  67. data/test/helpers/expectations/have.rb +105 -0
  68. data/test/helpers/expectations/predicates.rb +37 -0
  69. data/test/helpers/expectations.rb +4 -0
  70. data/test/helpers/fixtures.rb +87 -0
  71. data/test/helpers/initial_migration_fixture.sql +44 -0
  72. data/test/helpers.rb +87 -0
  73. data/test/unit/build_test.rb +86 -0
  74. data/test/unit/commit_test.rb +62 -0
  75. data/test/unit/helpers_test.rb +103 -0
  76. data/test/unit/integrity_test.rb +52 -0
  77. data/test/unit/migrations_test.rb +57 -0
  78. data/test/unit/notifier/base_test.rb +43 -0
  79. data/test/unit/notifier/test_test.rb +29 -0
  80. data/test/unit/notifier_test.rb +85 -0
  81. data/test/unit/project_builder_test.rb +118 -0
  82. data/test/unit/project_test.rb +371 -0
  83. data/test/unit/scm_test.rb +54 -0
  84. data/views/_commit_info.haml +24 -0
  85. data/views/build.haml +2 -0
  86. data/views/error.haml +37 -0
  87. data/views/home.haml +21 -0
  88. data/views/integrity.sass +400 -0
  89. data/views/layout.haml +29 -0
  90. data/views/new.haml +50 -0
  91. data/views/not_found.haml +31 -0
  92. data/views/notifier.haml +7 -0
  93. data/views/project.builder +21 -0
  94. data/views/project.haml +30 -0
  95. data/views/unauthorized.haml +38 -0
  96. metadata +327 -0
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ log/*.log
2
+ config/thin.yml
3
+ config/deploy.rb
4
+ config/config.yml
5
+ dist
6
+ coverage
7
+ integrity.db
8
+ exports
9
+ *.gem
10
+ *.swp
11
+ .aggregated_coverage_report
12
+ tmp/
data/CHANGES ADDED
@@ -0,0 +1,36 @@
1
+ 0.1.9.3 / unreleased
2
+ ====================
3
+
4
+ * Fix for when the commit identifier can't be retrieved
5
+ <http://integrity.lighthouseapp.com/projects/14308/tickets/116>
6
+ * Fix two issues with MySQL
7
+ * Fix one more URL issue
8
+
9
+ 0.1.9.2 / 2009-03-28
10
+ ====================
11
+
12
+ * Add development dependencies to gemspec
13
+ * Fix and improve deprecation (Josh Nichols)
14
+ * Fix a typo in post install message (Josh Nichols)
15
+ * Fix URLs issues (hopefully)
16
+ * Calculate URLs using base_uri option instead of the request.url
17
+ * Fix and use the URLs generation helpers in views. (Will Leinweber)
18
+ * Depend on sinatra-authorization (which has no dependency) instead
19
+ of sinatra-ditties.
20
+ * Use [mg](http://github.com/sr/mg) to manage release
21
+ * Various tweaks to the bootstraping Rake tasks. I am not happy
22
+ with them, though.
23
+ <http://integrity.lighthouseapp.com/projects/14308/tickets/126>
24
+
25
+ 0.1.9.1 / 2009-03-16
26
+ ====================
27
+
28
+ * Add the Integrity::Notifier::Test mixin, aimed at helping
29
+ writing test for notifiers.
30
+ NOTE: The API is not fixed yet. See the following ticket
31
+ <http://integrity.lighthouseapp.com/projects/14308-integrity/tickets/130>
32
+ * Add support for Heroku as a deployment option
33
+ * Fix the installer to work with the current Thor gem
34
+
35
+
36
+ **There is no changelog for previous release :-)**
data/README.markdown ADDED
@@ -0,0 +1,79 @@
1
+ Integrity
2
+ =========
3
+
4
+ [Integrity][website] is your friendly automated Continuous Integration server.
5
+
6
+ * See our [website][] for documentation and a [live demo][demo]
7
+ * Report bugs and submit features request on our [Lighthouse account][lighthouse]
8
+ * Join us on [#integrity][irc-channel] for ideas, help, patches or something
9
+ * Get the code on [GitHub][repo]
10
+
11
+ Try it!
12
+ -------
13
+
14
+ $ git clone git://github.com/foca/integrity.git
15
+ $ rake launch
16
+ # Navigate to <http://0.0.0.0:4567>
17
+
18
+ Run the test suite
19
+ ------------------
20
+
21
+ Install the test dependencies with `rake test:setup` and
22
+ run the test suite with `rake test`.
23
+
24
+ Thanks
25
+ ------
26
+
27
+ Thanks to the fellowing people for their feedbacks, ideas and patches :
28
+
29
+ * [James Adam][james]
30
+ * [Elliott Cable][ec]
31
+ * [Corey Donohoe][atmos]
32
+ * [Kyle Hargraves][kyle]
33
+ * [Pier-Hugues Pellerin][ph]
34
+ * [Simon Rozet][sr]
35
+ * [Scott Taylor][scott]
36
+
37
+ License
38
+ -------
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2008 [Nicolás Sanguinetti][foca], [entp][]
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62
+
63
+ [website]: http://integrityapp.com
64
+ [demo]: http://builder.integrityapp.com
65
+ [repo]: http://github.com/foca/integrity
66
+ [lighthouse]: http://integrity.lighthouseapp.com/projects/14308-integrity
67
+ [irc-channel]: irc://irc.freenode.net/integrity
68
+
69
+ [foca]: http://nicolassanguinetti.info/
70
+ [entp]: http://entp.com
71
+
72
+ [james]: http://github.com/lazyatom
73
+ [ec]: http://github.com/elliotcabble
74
+ [atmos]: http://github.com/atmos
75
+ [kyle]: http://github.com/pd
76
+ [ph]: http://github.com/ph
77
+ [sr]: http://purl.org/net/sr/
78
+ [scott]: http://github.com/smtlaissezfaire
79
+
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ require "rake/testtask"
2
+ require "rake/clean"
3
+
4
+ def spec
5
+ @spec ||= begin
6
+ require "rubygems/specification"
7
+ eval(File.read("integrity.gemspec"))
8
+ end
9
+ end
10
+
11
+ desc "Default: run all tests"
12
+ task :default => :test
13
+
14
+ desc "Install Integrity dependencies"
15
+ task :setup do
16
+ puts "NOTE: assuming you have gems.github.com in your gem sources"
17
+
18
+ system "gem install " +
19
+ spec.dependencies.select { |dep| dep.type == :runtime }.
20
+ collect(&:name).join(" ")
21
+ end
22
+
23
+ desc "Launch Integrity real quick"
24
+ task :launch do
25
+ ruby "bin/integrity launch"
26
+ end
27
+
28
+ desc "Run tests"
29
+ task :test => %w(test:units test:acceptance)
30
+ namespace :test do
31
+ Rake::TestTask.new(:units) do |t|
32
+ t.test_files = FileList["test/unit/*_test.rb"]
33
+ end
34
+
35
+ Rake::TestTask.new(:acceptance) do |t|
36
+ t.test_files = FileList["test/acceptance/*_test.rb"]
37
+ end
38
+
39
+ desc "Install tests dependencies"
40
+ task :setup do
41
+ puts "NOTE: assuming you have gems.github.com in your gem sources"
42
+
43
+ system "gem install " +
44
+ spec.dependencies.select { |dep| dep.type == :development }.
45
+ collect(&:name).join(" ")
46
+ end
47
+ end
48
+
49
+ begin
50
+ require "mg"
51
+ MG.new("integrity.gemspec")
52
+ rescue LoadError
53
+ end
54
+
55
+ begin
56
+ require "metric_fu"
57
+ rescue LoadError
58
+ end
59
+
60
+ desc "Special task for running tests on <http://builder.integrityapp.com>"
61
+ task :ci do
62
+ sh "git submodule update --init"
63
+
64
+ Rake::Task["test"].invoke
65
+
66
+ metrics = %w(flay flog:all reek roodi saikuro)
67
+ metrics.each { |m| Rake::Task["metrics:#{m}"].invoke }
68
+
69
+ rm_rf "/var/www/integrity-metrics"
70
+ mv "tmp/metric_fu", "/var/www/integrity-metrics"
71
+
72
+ File.open("/var/www/integrity-metrics/index.html", "w") { |f|
73
+ f << "<ul>"
74
+ metrics.map { |m| m.split(":").first }.each { |m|
75
+ f << %Q(<li><a href="/#{m}">#{m}</a></li>)
76
+ }
77
+ f << "</ul>"
78
+ }
79
+ end
data/bin/integrity ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + "/../lib/integrity/installer"
3
+
4
+ Integrity::Installer.start
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "integrity"
4
+
5
+ # If you want to add any notifiers, install the gems and then require them here
6
+ # For example, to enable the Email notifier: install the gem (from github:
7
+ #
8
+ # sudo gem install -s http://gems.github.com foca-integrity-email
9
+ #
10
+ # And then uncomment the following line:
11
+ #
12
+ # require "notifier/email"
13
+
14
+ # Load configuration and initialize Integrity
15
+ Integrity.new(File.dirname(__FILE__) + "/config.yml")
16
+
17
+ # You probably don't want to edit anything below
18
+ Integrity::App.set :environment, ENV["RACK_ENV"] || :production
19
+ Integrity::App.set :port, 8910
20
+
21
+ run Integrity::App
@@ -0,0 +1,41 @@
1
+ # Domain where integrity will be running from. This is used to have
2
+ # nice URLs in your notifications.
3
+ # For example:
4
+ # http://builder.integrityapp.com
5
+ :base_uri: http://integrity.domain.tld
6
+
7
+ # This should be a complete connection string to your database.
8
+ #
9
+ # Examples:
10
+ # * `mysql://user:password@localhost/integrity`
11
+ # * `postgres://user:password@localhost/integrity`
12
+ # * `sqlite3:///home/integrity/db/integrity.sqlite`
13
+ #
14
+ # Note:
15
+ # * The appropriate data_objects adapter must be installed (`do_mysql`, etc)
16
+ # * You must create the `integrity` database on localhost, of course.
17
+ :database_uri: sqlite3:///var/integrity.db
18
+
19
+ # This is where your project's code will be checked out to. Make sure it's
20
+ # writable by the user that runs Integrity.
21
+ :export_directory: /path/to/scm/exports
22
+
23
+ # Path to the integrity log file
24
+ :log: /var/log/integrity.log
25
+
26
+ # Enable or disable HTTP authentication for the app. BE AWARE that if you
27
+ # disable this anyone can delete and alter projects, so do it only if your
28
+ # app is running in a controlled environment (ie, behind your company's
29
+ # firewall.)
30
+ :use_basic_auth: false
31
+
32
+ # When `use_basic_auth` is true, the admin's username for HTTP authentication.
33
+ :admin_username: username
34
+
35
+ # When `use_basic_auth` is true, the admin's password. Usually saved as a
36
+ # SHA1 hash. See the next option.
37
+ :admin_password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
38
+
39
+ # If this is true, then whenever we authenticate the admin user, will hash
40
+ # it using SHA1. If not, we'll assume the provided password is in plain text.
41
+ :hash_admin_password: true
@@ -0,0 +1 @@
1
+ integrity --version 0.1.9.0
@@ -0,0 +1,6 @@
1
+ desc "Create the Integrity database"
2
+ task "db:migrate" do
3
+ require File.dirname(__FILE__) + "/integrity-config"
4
+
5
+ DataMapper.auto_migrate!
6
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + "/integrity-config"
3
+
4
+ Integrity::App.set(:environment, ENV["RACK_ENV"] || :production)
5
+ Integrity::App.disable(:run, :reload)
6
+ run Integrity::App
7
+
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ gem "integrity"
3
+ require "integrity"
4
+
5
+ Integrity.config = {
6
+ :database_uri => ENV["DATABASE_URL"],
7
+ :export_directory => File.dirname(__FILE__) + "/tmp",
8
+ :log => File.dirname(__FILE__) + "/log/integrity.log",
9
+ # Uncomment to setup a password
10
+ # :admin_usenrame => "admin",
11
+ # :admin_password => "foobar"
12
+ }
13
+
14
+ Integrity.new
@@ -0,0 +1,13 @@
1
+ ---
2
+ environment: production
3
+ chdir: /apps/integrity
4
+ address: 127.0.0.1
5
+ port: 8910
6
+ pid: /apps/integrity/thin.pid
7
+ rackup: /apps/integrity/config.ru
8
+ log: /apps/integrity/log/thin.log
9
+ max_conns: 1024
10
+ timeout: 30
11
+ max_persistent_conns: 512
12
+ daemonize: true
13
+ servers: 2
data/integrity.gemspec ADDED
@@ -0,0 +1,140 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "integrity"
3
+ s.version = "0.1.9.2"
4
+ s.date = "2009-03-16"
5
+
6
+ s.description = "Your Friendly Continuous Integration server. Easy, fun and painless!"
7
+ s.summary = "The easy and fun Continuous Integration server"
8
+ s.homepage = "http://integrityapp.com"
9
+
10
+ s.authors = ["Nicolás Sanguinetti", "Simon Rozet"]
11
+ s.email = "info@integrityapp.com"
12
+
13
+ s.require_paths = ["lib"]
14
+ s.executables = ["integrity"]
15
+
16
+ s.post_install_message = "Run `integrity help` for information on how to setup Integrity."
17
+ s.rubyforge_project = "integrity"
18
+ s.has_rdoc = false
19
+ s.rubygems_version = "1.3.1"
20
+
21
+ s.add_dependency "sinatra", [">= 0.9.1.1"]
22
+ s.add_dependency "sinatra-authorization"
23
+ s.add_dependency "haml", [">= 2.0.0"]
24
+ s.add_dependency "data_mapper", ["= 0.9.10"]
25
+ s.add_dependency "uuidtools" # required by dm-types
26
+ s.add_dependency "bcrypt-ruby" # required by dm-types
27
+ s.add_dependency "json"
28
+ s.add_dependency "thor"
29
+
30
+ if s.respond_to?(:add_development_dependency)
31
+ s.add_development_dependency "rr"
32
+ s.add_development_dependency "mocha"
33
+ s.add_development_dependency "webrat"
34
+ s.add_development_dependency "do_sqlite3"
35
+ s.add_development_dependency "dm-sweatshop"
36
+ s.add_development_dependency "ParseTree" # required by dm-sweatshop
37
+ s.add_development_dependency "jeremymcanally-context"
38
+ s.add_development_dependency "jeremymcanally-matchy"
39
+ s.add_development_dependency "jeremymcanally-pending"
40
+ s.add_development_dependency "foca-storyteller"
41
+ end
42
+
43
+ s.files = %w[
44
+ .gitignore
45
+ CHANGES
46
+ README.markdown
47
+ Rakefile
48
+ bin/integrity
49
+ config/config.sample.ru
50
+ config/config.sample.yml
51
+ config/heroku/.gems
52
+ config/heroku/Rakefile
53
+ config/heroku/config.ru
54
+ config/heroku/integrity-config.rb
55
+ config/thin.sample.yml
56
+ integrity.gemspec
57
+ lib/integrity.rb
58
+ lib/integrity/app.rb
59
+ lib/integrity/author.rb
60
+ lib/integrity/build.rb
61
+ lib/integrity/commit.rb
62
+ lib/integrity/core_ext/object.rb
63
+ lib/integrity/helpers.rb
64
+ lib/integrity/helpers/authorization.rb
65
+ lib/integrity/helpers/breadcrumbs.rb
66
+ lib/integrity/helpers/forms.rb
67
+ lib/integrity/helpers/pretty_output.rb
68
+ lib/integrity/helpers/rendering.rb
69
+ lib/integrity/helpers/resources.rb
70
+ lib/integrity/helpers/urls.rb
71
+ lib/integrity/installer.rb
72
+ lib/integrity/migrations.rb
73
+ lib/integrity/notifier.rb
74
+ lib/integrity/notifier/base.rb
75
+ lib/integrity/notifier/test.rb
76
+ lib/integrity/notifier/test/fixtures.rb
77
+ lib/integrity/notifier/test/hpricot_matcher.rb
78
+ lib/integrity/project.rb
79
+ lib/integrity/project/deprecated.rb
80
+ lib/integrity/project/notifiers.rb
81
+ lib/integrity/project/push.rb
82
+ lib/integrity/project_builder.rb
83
+ lib/integrity/scm.rb
84
+ lib/integrity/scm/git.rb
85
+ lib/integrity/scm/git/uri.rb
86
+ public/buttons.css
87
+ public/reset.css
88
+ public/spinner.gif
89
+ test/acceptance/api_test.rb
90
+ test/acceptance/browse_project_builds_test.rb
91
+ test/acceptance/browse_project_test.rb
92
+ test/acceptance/build_notifications_test.rb
93
+ test/acceptance/create_project_test.rb
94
+ test/acceptance/delete_project_test.rb
95
+ test/acceptance/edit_project_test.rb
96
+ test/acceptance/error_page_test.rb
97
+ test/acceptance/installer_test.rb
98
+ test/acceptance/manual_build_project_test.rb
99
+ test/acceptance/not_found_page_test.rb
100
+ test/acceptance/project_syndication_test.rb
101
+ test/acceptance/stylesheet_test.rb
102
+ test/acceptance/unauthorized_page_test.rb
103
+ test/helpers.rb
104
+ test/helpers/acceptance.rb
105
+ test/helpers/acceptance/email_notifier.rb
106
+ test/helpers/acceptance/git_helper.rb
107
+ test/helpers/acceptance/notifier_helper.rb
108
+ test/helpers/acceptance/textfile_notifier.rb
109
+ test/helpers/expectations.rb
110
+ test/helpers/expectations/be_a.rb
111
+ test/helpers/expectations/change.rb
112
+ test/helpers/expectations/have.rb
113
+ test/helpers/expectations/predicates.rb
114
+ test/helpers/fixtures.rb
115
+ test/helpers/initial_migration_fixture.sql
116
+ test/unit/build_test.rb
117
+ test/unit/commit_test.rb
118
+ test/unit/helpers_test.rb
119
+ test/unit/integrity_test.rb
120
+ test/unit/migrations_test.rb
121
+ test/unit/notifier/base_test.rb
122
+ test/unit/notifier/test_test.rb
123
+ test/unit/notifier_test.rb
124
+ test/unit/project_builder_test.rb
125
+ test/unit/project_test.rb
126
+ test/unit/scm_test.rb
127
+ views/_commit_info.haml
128
+ views/build.haml
129
+ views/error.haml
130
+ views/home.haml
131
+ views/integrity.sass
132
+ views/layout.haml
133
+ views/new.haml
134
+ views/not_found.haml
135
+ views/notifier.haml
136
+ views/project.builder
137
+ views/project.haml
138
+ views/unauthorized.haml
139
+ ]
140
+ end
@@ -0,0 +1,138 @@
1
+ module Integrity
2
+ class App < Sinatra::Default
3
+ set :root, File.dirname(__FILE__) + "/../.."
4
+ set :app_file, __FILE__
5
+ enable :sessions
6
+
7
+ include Integrity
8
+ include Integrity::Helpers
9
+
10
+ not_found do
11
+ status 404
12
+ show :not_found, :title => "lost, are we?"
13
+ end
14
+
15
+ error do
16
+ @error = request.env["sinatra.error"]
17
+ status 500
18
+ show :error, :title => "something has gone terribly wrong"
19
+ end
20
+
21
+ before do
22
+ # The browser only sends http auth data for requests that are explicitly
23
+ # required to do so. This way we get the real values of +#logged_in?+ and
24
+ # +#current_user+
25
+ login_required if session[:user]
26
+ end
27
+
28
+ get "/integrity.css" do
29
+ response["Content-Type"] = "text/css; charset=utf-8"
30
+ etag stylesheet_hash
31
+ sass :integrity
32
+ end
33
+
34
+ get "/?" do
35
+ @projects = Project.only_public_unless(authorized?)
36
+ show :home, :title => "projects"
37
+ end
38
+
39
+ get "/login" do
40
+ login_required
41
+
42
+ session[:user] = current_user
43
+ redirect root_url.to_s
44
+ end
45
+
46
+ get "/new" do
47
+ login_required
48
+
49
+ @project = Project.new
50
+ show :new, :title => ["projects", "new project"]
51
+ end
52
+
53
+ post "/?" do
54
+ login_required
55
+
56
+ @project = Project.new(params[:project_data])
57
+
58
+ if @project.save
59
+ update_notifiers_of(@project)
60
+ redirect project_url(@project).to_s
61
+ else
62
+ show :new, :title => ["projects", "new project"]
63
+ end
64
+ end
65
+
66
+ get "/:project.atom" do
67
+ login_required unless current_project.public?
68
+ response["Content-Type"] = "application/rss+xml; charset=utf-8"
69
+ builder :project
70
+ end
71
+
72
+ get "/:project" do
73
+ login_required unless current_project.public?
74
+ show :project, :title => ["projects", current_project.name]
75
+ end
76
+
77
+ put "/:project" do
78
+ login_required
79
+
80
+ if current_project.update_attributes(params[:project_data])
81
+ update_notifiers_of(current_project)
82
+ redirect project_url(current_project).to_s
83
+ else
84
+ show :new, :title => ["projects", current_project.permalink, "edit"]
85
+ end
86
+ end
87
+
88
+ delete "/:project" do
89
+ login_required
90
+
91
+ current_project.destroy
92
+ redirect root_url.to_s
93
+ end
94
+
95
+ get "/:project/edit" do
96
+ login_required
97
+
98
+ show :new, :title => ["projects", current_project.permalink, "edit"]
99
+ end
100
+
101
+ post "/:project/push" do
102
+ login_required
103
+
104
+ content_type "text/plain"
105
+
106
+ begin
107
+ current_project.push(params[:payload])
108
+ 201
109
+ rescue ArgumentError
110
+ [422, "Invalid Request"]
111
+ end
112
+ end
113
+
114
+ post "/:project/builds" do
115
+ login_required
116
+
117
+ current_project.build
118
+ redirect project_url(current_project).to_s
119
+ end
120
+
121
+ get "/:project/commits/:commit" do
122
+ login_required unless current_project.public?
123
+
124
+ show :build, :title => ["projects", current_project.permalink, current_commit.short_commit_identifier]
125
+ end
126
+
127
+ get "/:project/builds/:commit" do
128
+ redirect "/#{params[:project]}/commits/#{params[:commit]}", 301
129
+ end
130
+
131
+ post "/:project/commits/:commit/builds" do
132
+ login_required
133
+
134
+ current_project.build(params[:commit])
135
+ redirect commit_url(current_commit).to_s
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,39 @@
1
+ module Integrity
2
+ class Author < DataMapper::Type
3
+ primitive String
4
+ size 65535
5
+ lazy true
6
+
7
+ class AuthorStruct < Struct.new(:name, :email)
8
+ def self.parse(string)
9
+ raise ArgumentError.new("invalid author string") unless string =~ /^(.*) <(.*)>$/
10
+
11
+ new($1.strip, $2.strip)
12
+ end
13
+
14
+ def to_s
15
+ @full ||= "#{name} <#{email}>"
16
+ end
17
+
18
+ alias_method :full, :to_s
19
+ end
20
+
21
+ def self.load(value, property)
22
+ AuthorStruct.parse(value) unless value.nil?
23
+ end
24
+
25
+ def self.dump(value, property)
26
+ return nil if value.nil?
27
+
28
+ value.to_s
29
+ end
30
+
31
+ def self.typecast(value, property)
32
+ case value
33
+ when AuthorStruct then value
34
+ when NilClass then load(nil, property)
35
+ else load(value.to_s, property)
36
+ end
37
+ end
38
+ end
39
+ end