giraffesoft-integrity 0.1.4

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/public/reset.css ADDED
@@ -0,0 +1,7 @@
1
+ /*
2
+ Copyright (c) 2008, Yahoo! Inc. All rights reserved.
3
+ Code licensed under the BSD License:
4
+ http://developer.yahoo.net/yui/license.txt
5
+ version: 2.5.2
6
+ */
7
+ html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;font-variant:normal;}sup {vertical-align:text-top;}sub {vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
Binary file
@@ -0,0 +1,91 @@
1
+ module FormFieldHpricotMatchers
2
+ # TODO: Add support for selects
3
+ class HaveField
4
+ include RspecHpricotMatchers
5
+
6
+ def initialize(id, type, tagname)
7
+ @tagname = tagname
8
+ @type = type
9
+ @id = id
10
+ @tag_matcher = have_tag("#{@tagname}##{@id}", @tagname == "textarea" ? @value : nil)
11
+ @label_set = true # always check for a label, unless explicitly told not to
12
+ end
13
+
14
+ def named(name)
15
+ @name_set = true
16
+ @name = name
17
+ self
18
+ end
19
+
20
+ def with_label(label)
21
+ @label = label
22
+ self
23
+ end
24
+
25
+ def without_label
26
+ @label_set = false
27
+ self
28
+ end
29
+
30
+ def with_value(value)
31
+ @value_set = true
32
+ @value = value
33
+ self
34
+ end
35
+
36
+ def checked
37
+ @checked = "checked"
38
+ self
39
+ end
40
+
41
+ def unchecked
42
+ @checked = ""
43
+ self
44
+ end
45
+
46
+ def matches?(actual)
47
+ (@label_set ? have_tag("label[@for=#{@id}]", @label).matches?(actual) : true) &&
48
+ @tag_matcher.matches?(actual) do |field|
49
+ field["type"].should == @type if @type
50
+ field["name"].should == @name if @name_set
51
+ field["value"].should == @value if @value_set && @tagname == "input"
52
+ field["checked"].should == @checked if @checked
53
+ end
54
+ end
55
+
56
+ def failure_message
57
+ attrs = [
58
+ "id ##{@id}",
59
+ @name && "name '#{@name}'",
60
+ @type && "type '#{@type}'",
61
+ @label && "labelled '#{@label}'",
62
+ @value && "value '#{@value}'"
63
+ ].compact.join(", ")
64
+ "You expected a #{@tagname}#{@type ? " (#{@type})" : ""} with #{attrs} but found none.\n\n#{@tag_matcher.failure_message}"
65
+ end
66
+ end
67
+
68
+ def have_field(id, type="text", tagname="input")
69
+ HaveField.new(id, type, tagname)
70
+ end
71
+
72
+ def have_textfield(id)
73
+ have_field(id)
74
+ end
75
+
76
+ def have_password(id)
77
+ have_field(id, "password")
78
+ end
79
+
80
+ def have_checkbox(id)
81
+ have_field(id, "checkbox")
82
+ end
83
+
84
+ def have_radio(id)
85
+ have_field(id, "radio")
86
+ end
87
+
88
+ def have_textarea(id)
89
+ have_field(id, nil, "textarea")
90
+ end
91
+ end
@@ -0,0 +1,135 @@
1
+ require File.dirname(__FILE__) + '/../lib/integrity'
2
+ require 'spec'
3
+
4
+ module LoggingSpecHelper
5
+ def self.included(mod)
6
+ mod.before(:each) { Integrity.stub!(:log) }
7
+ end
8
+ end
9
+
10
+ module NotifierSpecHelper
11
+ def self.included(mod)
12
+ mod.before(:each) { Integrity.stub!(:config).and_return(:base_uri => "http://localhost:4567") }
13
+ end
14
+
15
+ class Integrity::Notifier::Stub < Integrity::Notifier::Base
16
+ def self.to_haml
17
+ ""
18
+ end
19
+
20
+ def deliver!
21
+ nil
22
+ end
23
+ end
24
+
25
+ def mock_build(messages={})
26
+ messages = {
27
+ :project => stub("project", :name => "Integrity", :permalink => "integrity"),
28
+ :commit_identifier => "e7e02bc669d07064cdbc7e7508a21a41e040e70d",
29
+ :short_commit_identifier => "e7e02b",
30
+ :status => :success,
31
+ :successful? => true,
32
+ :commit_message => "the commit message",
33
+ :commit_author => stub("author", :name => "Nicolás Sanguinetti"),
34
+ :commited_at => Time.mktime(2008, 07, 25, 18, 44),
35
+ :output => "the output \e[31mwith color coding\e[0m"
36
+ }.merge(messages)
37
+ @build ||= stub("build", messages)
38
+ end
39
+
40
+ def notifier_config(overrides={})
41
+ @config ||= overrides
42
+ end
43
+
44
+ def notifier
45
+ @notifier ||= stub("notifier", :method_missing => nil)
46
+ end
47
+
48
+ def the_form(locals = {})
49
+ locals = { :config => {} }.merge(locals)
50
+ require 'haml'
51
+ @form ||= Haml::Engine.new(klass.to_haml).render(self, locals)
52
+ end
53
+ end
54
+
55
+ describe "A notifier", :shared => true do
56
+ it "should have a `notify_of_build' class method" do
57
+ klass.should respond_to(:notify_of_build)
58
+ end
59
+
60
+ it "should have a `to_haml' class method" do
61
+ klass.should respond_to(:to_haml)
62
+ end
63
+ end
64
+
65
+ module DatabaseSpecHelper
66
+ def self.included(mod)
67
+ mod.before(:each) { setup_database! }
68
+ end
69
+
70
+ def setup_database!
71
+ DataMapper.setup(:default, 'sqlite3::memory:')
72
+ DataMapper.auto_migrate!
73
+ end
74
+ end
75
+
76
+ module AppSpecHelper
77
+ def self.included(mod)
78
+ require 'rspec_hpricot_matchers'
79
+ require Integrity.root / 'spec/form_field_matchers'
80
+
81
+ mod.send(:include, DatabaseSpecHelper)
82
+ mod.send(:include, RspecHpricotMatchers)
83
+ mod.send(:include, FormFieldHpricotMatchers)
84
+ end
85
+
86
+ def mock_project(messages={})
87
+ messages = {
88
+ :name => "Integrity",
89
+ :permalink => "integrity",
90
+ :new_record? => false,
91
+ :uri => "git://github.com/foca/integrity.git",
92
+ :branch => "master",
93
+ :command => "rake",
94
+ :public? => true,
95
+ :builds => [],
96
+ :config_for => {},
97
+ :build => nil,
98
+ :update_attributes => true,
99
+ :save => true,
100
+ :destroy => nil,
101
+ :errors => stub("errors", :on => nil),
102
+ :notifies? => false,
103
+ :enable_notifiers => nil
104
+ }.merge(messages)
105
+
106
+ @project ||= stub("project", messages)
107
+ end
108
+
109
+ def mock_build(messages={})
110
+ messages = {
111
+ :status => :success,
112
+ :successful? => true,
113
+ :output => 'output',
114
+ :project => @project,
115
+ :commit_identifier => '9f6302002d2259c05a64767e0dedb15d280a4848',
116
+ :commit_author => mock("author",
117
+ :name => 'Nicolás Sanguinetti',
118
+ :email => 'contacto@nicolassanguinetti.info',
119
+ :full =>'Nicolás Sanguinetti <contacto@nicolassanguinetti.info>'
120
+ ),
121
+ :commited_at => Time.mktime(2008, 7, 24, 17, 15),
122
+ :commit_message => "Add Object#tap for versions of ruby that don't have it"
123
+ }.merge(messages)
124
+ messages[:short_commit_identifier] = messages[:commit_identifier][0..5]
125
+ mock('build', messages)
126
+ end
127
+
128
+ def disable_basic_auth!
129
+ Integrity.stub!(:config).and_return(:use_basic_auth => false)
130
+ end
131
+
132
+ def enable_basic_auth!
133
+ Integrity.stub!(:config).and_return(:use_basic_auth => true, :admin_username => 'user', :admin_password => 'pass')
134
+ end
135
+ end
@@ -0,0 +1,49 @@
1
+ module Sinatra
2
+ class EventContext
3
+ def params
4
+ @params ||= ParamsParser.new(@route_params.merge(@request.params)).to_hash
5
+ end
6
+
7
+ private
8
+
9
+ class ParamsParser
10
+ attr_reader :hash
11
+
12
+ def initialize(hash)
13
+ @hash = nested(hash)
14
+ end
15
+
16
+ alias :to_hash :hash
17
+
18
+ protected
19
+
20
+ def nested(hash)
21
+ hash.inject(indifferent_hash) do |par, (key,val)|
22
+ if key =~ /([^\[]+)\[([^\]]+)\](.*)/ # a[b] || a[b][c] ($1 == a, $2 == b, $3 == [c])
23
+ par[$1] ||= indifferent_hash
24
+ par[$1].merge_recursive nested("#{$2}#{$3}" => val)
25
+ else
26
+ par[key] = val
27
+ end
28
+ par
29
+ end
30
+ end
31
+
32
+ def indifferent_hash
33
+ Hash.new {|h,k| h[k.to_s] if Symbol === k}
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ class Hash
40
+ def merge_recursive(other)
41
+ update(other) do |key, old_value, new_value|
42
+ if Hash === old_value && Hash === new_value
43
+ old_value.merge_recursive(new_value)
44
+ else
45
+ new_value
46
+ end
47
+ end
48
+ end
49
+ end
data/views/build.haml ADDED
@@ -0,0 +1,2 @@
1
+ #build{ :class => @build.status }
2
+ = haml(:build_info, :layout => false)
@@ -0,0 +1,22 @@
1
+ %h1
2
+ Built
3
+ &= @build.short_commit_identifier
4
+ = @build.successful? ? "successfully" : "and failed"
5
+ %blockquote
6
+ %p&= @build.commit_message
7
+ %p.meta<
8
+ %span.who<
9
+ by:
10
+ &= @build.commit_author.name
11
+ |
12
+ %span.when{ :title => @build.commited_at.iso8601 }<
13
+ &= pretty_date @build.commited_at
14
+ |
15
+ %span.what<
16
+ commit:
17
+ &= @build.commit_identifier
18
+
19
+ %h2 Build Output:
20
+ %pre.output
21
+ :preserve
22
+ #{bash_color_codes h(@build.output)}
data/views/error.haml ADDED
@@ -0,0 +1,29 @@
1
+ .error
2
+ %h1
3
+ Whatever you do, DON'T PANIC!
4
+
5
+ %dl
6
+ %dt This is what happened:
7
+ %dd
8
+ %strong&= @error.message
9
+ %pre.backtrace= @error.backtrace.join("\n")
10
+
11
+ %dt What can I do?
12
+ %dd
13
+ Is your
14
+ %a{ :href => "http://integrityapp.com/configure" } config
15
+ ok? If not, try restarting integrity. If you think everything is fine,
16
+ then drop by our irc channel:
17
+ %a{ :href => "irc://irc.freenode.org:6667/integrity" } #integrity
18
+ on freenode, and we'll try to help.
19
+
20
+ %dt
21
+ What the hell is
22
+ = succeed "?" do
23
+ %strong Integrity
24
+ %dd
25
+ Integrity is your friendly
26
+ %a{ :href => "http://en.wikipedia.org/wiki/Continuous_integration" } Continuous Integration
27
+ server. If you want to know more about us, check our website at
28
+ = succeed "." do
29
+ %a{ :href => "http://integrityapp.com" } integrityapp.com
data/views/home.haml ADDED
@@ -0,0 +1,22 @@
1
+ - if @projects.empty?
2
+ .blank_slate
3
+ %p None yet, huh?
4
+ %h1
5
+ Why don't you
6
+ = succeed "?" do
7
+ %a{ :href => "/new" } create your first project
8
+ - else
9
+ %ul#projects
10
+ - @projects.each do |project|
11
+ %li{ :class => cycle("even", "odd") + (project.building? ? ' building' : '') + (project.last_build ? (project.last_build.successful? ? ' success' : ' failed') : '') }
12
+ %a{ :href => project_url(project) }&= project.name
13
+ .meta
14
+ - if project.building?
15
+ Building!
16
+ - elsif project.last_build.nil?
17
+ Never built yet
18
+ - else
19
+ = "Built #{project.last_build.short_commit_identifier}"
20
+ = project.last_build.successful? ? "successfully" : "and failed"
21
+ %p#new
22
+ %a{ :href => "/new" } Add a new project
@@ -0,0 +1,387 @@
1
+ !default_fonts = "Helvetica Neue, Helvetica, Arial, sans-serif"
2
+ !nice_fonts = "Georgia, Times New Roman, serif"
3
+ !monospace_fonts = "Monaco, Deja Vu Sans Mono, Inconsolata, Consolas, monospace"
4
+
5
+ !page_bg = #e0e0e0
6
+ !content_bg = #eee
7
+ !header_bg = #fff
8
+ !text_color = #333
9
+ !light_color = #999
10
+ !title_color = #4e4e4e
11
+ !link_color = #ed1556
12
+ !link_bg = #fff
13
+ !rule_color = #c0c0c0
14
+ !watermark = #ccc
15
+ !quote_bg = #fff
16
+ !success_bg = #bbf8aa
17
+ !success_color = #337022
18
+ !failed_bg = #fba
19
+ !failed_color = #f10
20
+
21
+ html
22
+ :background-color = !page_bg
23
+
24
+ body
25
+ :font-size 100%
26
+ :font-family = !default_fonts
27
+ :color = !text_color
28
+
29
+ a
30
+ :color = !link_color
31
+ :text-decoration none
32
+ &:hover
33
+ :color = !link_bg
34
+ :background-color = !link_color
35
+
36
+ #header, #content, #footer
37
+ :width 40em
38
+ :margin 0 auto
39
+ :background = !content_bg
40
+ :padding 0 2em
41
+ :z-index 0
42
+ :position relative
43
+ :font-size 1em
44
+
45
+ #header
46
+ :background = !header_bg
47
+ h1
48
+ :font-weight bold
49
+ :font-size 1.5em
50
+ address.watermark
51
+ :position absolute
52
+ :font-weight bold
53
+ :right 3em
54
+ :top 0
55
+ :font-size .75em
56
+ :color = !watermark
57
+ a
58
+ :color = !watermark
59
+ :font-weight bold
60
+ :font-size 2em
61
+ &:hover
62
+ :background transparent
63
+ :color = !watermark - #222
64
+
65
+ #content
66
+ :padding-top 1em
67
+ :padding-bottom 2em
68
+
69
+ strong
70
+ :font-weight bold
71
+ em
72
+ :font-style italic
73
+
74
+ h1, h2, h3, h4, h5, h6
75
+ :color = !title_color
76
+ h1
77
+ :font-size 2em
78
+ :font-weight bold
79
+ :margin-bottom .75em
80
+ :padding .25em 0
81
+ :line-height 1.2
82
+ :border-bottom = 1px solid !rule_color
83
+ h2
84
+ :font-weight bold
85
+ :font-size 1.5em
86
+ :margin 1em 0 .2em
87
+ h3
88
+ :font-weight bold
89
+ :font-size 1.25em
90
+ :margin .25em 0
91
+ h4, h5, h6
92
+ :font-weight bold
93
+ :margin-top .5em
94
+
95
+ code, pre, textarea, input
96
+ :font-family = !monospace_fonts
97
+ pre
98
+ margin .5em :0
99
+ padding .5em
100
+
101
+ form
102
+ p
103
+ :margin-top 1em
104
+ :position relative
105
+ &.checkbox label
106
+ :margin-top 0 !important
107
+ input.text, textarea
108
+ :width 30em
109
+ :padding .2em .4em
110
+ :color = !title_color
111
+ :height 1.4em
112
+ label
113
+ :float left
114
+ :display block
115
+ :margin-top .5em
116
+ :width 8em
117
+ :margin-right .75em
118
+ .with_errors
119
+ label
120
+ :background red
121
+ :color white
122
+ :position relative
123
+ :top -.7em
124
+ &.required
125
+ label
126
+ :position static
127
+ :margin-right .25em
128
+ :padding 0 .2em
129
+ input, textarea
130
+ :border 2px solid #f22
131
+ :background #fee
132
+ :color = !text_color - #111
133
+ .required
134
+ label
135
+ :float none
136
+ :display block
137
+ :width auto
138
+ :position relative
139
+ :font-weight bold
140
+ :margin-top 1em
141
+ :text-indent -.65em
142
+ &:before
143
+ :content "* "
144
+ :color = !link_color
145
+ input.text
146
+ :width 25.6em
147
+ :font-size 24px
148
+ :font-weight bold
149
+ .normal
150
+ :margin-top 2em
151
+ h2.notifier label
152
+ :float none
153
+ :width auto
154
+ :margin-right 0
155
+ .warning
156
+ :font-size .5em
157
+ :font-weight normal
158
+ :color = !light_color
159
+ fieldset
160
+ :padding-bottom 1em
161
+ :margin-left 1.35em
162
+ :border-bottom = 1px solid !rule_color
163
+ :margin-bottom 1em
164
+ h3
165
+ :margin-top 1em
166
+ :margin-bottom 0
167
+ p.normal
168
+ :margin-top 1em
169
+ p label
170
+ :width 6.7em
171
+ p.submit
172
+ :margin-top 2em
173
+ &:after
174
+ :display block
175
+ :clear both
176
+ :float none
177
+ :content "."
178
+ :text-indent -9999em
179
+ :text-align left
180
+ &.destroy
181
+ :margin-top 0
182
+ button
183
+ :float none
184
+ :display inline
185
+
186
+ .blank_slate, .error
187
+ p
188
+ :position relative
189
+ :top .3em
190
+ h1
191
+ :border-width 0
192
+ :margin 0
193
+ :padding 0
194
+ button
195
+ :float none
196
+ :border 0 none
197
+ :background transparent
198
+ :display inline
199
+ :color = !link_color
200
+ :padding 0.25em 0
201
+ :margin 0
202
+ &:hover
203
+ :background = !link_color
204
+ :color = !link_bg
205
+
206
+ .error
207
+ dt
208
+ :margin
209
+ :top 1.4em
210
+ :bottom .3em
211
+ :font
212
+ :size 1.75em
213
+ :family = !nice_fonts
214
+ dd
215
+ :line-height 1.4
216
+
217
+ .backtrace
218
+ :margin 1em 0
219
+ :overflow scroll
220
+ :height 30em
221
+ :border = 1px solid !rule_color
222
+ :line-height 1.6
223
+
224
+ #projects
225
+ :margin 1em 0 2em
226
+ :border-top = 1px solid !rule_color
227
+ li
228
+ :position relative
229
+ :border-bottom = 1px solid !rule_color
230
+ &.odd
231
+ :background = !content_bg - #080808
232
+ &.building
233
+ :background transparent url(/spinner.gif) no-repeat scroll right
234
+ a
235
+ :font-size 2em
236
+ :padding .25em
237
+ :line-height 1.2
238
+ :font-weight bold
239
+ :display block
240
+ &.success
241
+ :color = !success_color
242
+ &.failed
243
+ :color = !failed_color
244
+ .meta
245
+ :position absolute
246
+ :right .6em
247
+ :top 1.5em
248
+ :font-size 0.8em
249
+ :color = !light_color
250
+ :text-align right
251
+ &.building .meta
252
+ :right 1.6em
253
+ &.success .meta
254
+ :color = !success_color
255
+ &.failed .meta
256
+ :color = !failed_color
257
+
258
+
259
+ #previous_builds
260
+ li
261
+ a
262
+ :display block
263
+ :padding .25em
264
+ :margin-bottom .25em
265
+ :border
266
+ :width 1px
267
+ :style solid
268
+ strong
269
+ :font-size 1.3em
270
+ .attribution
271
+ :font-size .9em
272
+
273
+ #projects, #previous_builds
274
+ li
275
+ &.success a
276
+ :background-color = !success_bg
277
+ :border-color = !success_bg - #222
278
+ :color = !success_color
279
+ .attribution
280
+ :color = !success_bg - #444
281
+ &:hover
282
+ :background-color = !success_bg + #222
283
+ &.failed a
284
+ :background-color = !failed_bg
285
+ :border-color = !failed_bg - #222
286
+ :color = !failed_color
287
+ .attribution
288
+ :color = !failed_bg - #444
289
+ &:hover
290
+ :background-color = !failed_bg + #222
291
+
292
+
293
+ #build, #last_build
294
+ h1, blockquote
295
+ :border
296
+ :width 0 1px
297
+ :style solid
298
+ h1
299
+ :border-top-width 1px
300
+ blockquote
301
+ :bottom-bottom-width 1px
302
+ :line-height 1.4
303
+
304
+ &.success
305
+ h1, blockquote
306
+ :background-color = !success_bg
307
+ :border-color = (!success_bg - #222) (!success_bg + #111) (!success_bg + #111) (!success_bg - #222)
308
+ h1
309
+ :color = !success_color
310
+ .meta
311
+ :color = !success_bg - #444
312
+
313
+ &.failed
314
+ h1, blockquote
315
+ :background-color = !failed_bg
316
+ :border-color = (!failed_bg - #222) (!failed_bg + #111) (!failed_bg + #111) (!failed_bg - #222)
317
+ h1
318
+ :color = !failed_color
319
+ .meta
320
+ :color = !failed_bg - #444
321
+
322
+ h1
323
+ :margin-top .5em
324
+ :margin-bottom 0
325
+ :padding .25em
326
+ :color = !success_color
327
+
328
+ blockquote
329
+ :padding .75em
330
+ :margin-bottom 2em
331
+ .meta
332
+ :margin-top 1em
333
+ :display block
334
+ :font-size .9em
335
+
336
+ pre.output
337
+ :background #111
338
+ :color #fff
339
+ :padding .5em
340
+ :overflow auto
341
+ :max-height 50em
342
+ :font-size .825em
343
+
344
+ .color30
345
+ :color #333
346
+ .color31
347
+ :color #e33
348
+ .color32
349
+ :color #3e3
350
+ .color33
351
+ :color #ee3
352
+ .color34
353
+ :color #33e
354
+ .color35
355
+ :color #e3e
356
+ .color36
357
+ :color #3ee
358
+ .color37
359
+ :color #fff
360
+
361
+ #push_url
362
+ :display block
363
+ :margin
364
+ :top 1em
365
+ :left 2em
366
+
367
+ a
368
+ &.success
369
+ :color = !success_bg
370
+ &:hover
371
+ :background-color = !success_bg
372
+ :color white
373
+ &.failed
374
+ :color = !failed_bg
375
+ &:hover
376
+ :background-color = !failed_bg
377
+ :color white
378
+
379
+ #footer
380
+ :padding 1.5em 2.5em
381
+ :border-top 1px solid #ccc
382
+ :font-size .8em
383
+ :width 50em !important
384
+ :color #666
385
+ :text-align right
386
+ strong
387
+ :font-weight bold