Skip to content

Commit

Permalink
Polish the build output [integrity#3 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
foca committed Jul 25, 2008
1 parent bfb0d7f commit 99191f2
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 85 deletions.
5 changes: 4 additions & 1 deletion lib/integrity/build.rb
Expand Up @@ -40,7 +40,10 @@ def commit_message
end

def commited_at
commit_metadata[:date]
case commit_metadata[:date]
when String then Time.parse(commit_metadata[:date])
else commit_metadata[:date]
end
end

private
Expand Down
11 changes: 2 additions & 9 deletions lib/integrity/ui/web/views/build.haml
@@ -1,9 +1,2 @@
%h1#build{ :class => @build.status }
= @build.short_commit_identifier
#commit_informations
%blockquote
%p&= @build.commit_message
%p.cite.commit_author&= @build.commit_author.full
%pre.output
:preserve
#{bash_color_codes @build.output}
#build{ :class => @build.status }
= haml(:build_info, :layout => false)
22 changes: 22 additions & 0 deletions lib/integrity/ui/web/views/build_info.haml
@@ -0,0 +1,22 @@
%h1
Built
&= @build.short_commit_identifier
= @build.successful? ? "successfully" : "and failed"
%blockquote
%p&= @build.commit_message
%p.meta<
%span.who<
by:
&= @build.commit_author.name
|
%span.when{ :title => @build.commited_at.iso8601 }<
&= pretty_date @build.commited_at
|
%span.what<
commit:
&= @build.commit_identifier

%h2 Build Output:
%pre.output
:preserve
#{bash_color_codes @build.output}
136 changes: 80 additions & 56 deletions lib/integrity/ui/web/views/integrity.sass
Expand Up @@ -2,18 +2,20 @@
!nice_fonts = "Georgia, Times New Roman, serif"
!monospace_fonts = "Monaco, Deja Vu Sans Mono, Inconsolata, Consolas, monospace"

!page_bg = #e0e0e0
!content_bg = #eee
!header_bg = #fff
!text_color = #333
!title_color = #4e4e4e
!link_color = #ed1556
!link_bg = #fff
!rule_color = #c0c0c0
!watermark = #ccc
!quote_bg = #FFF
!success_bg = green
!failed_bg = red
!page_bg = #e0e0e0
!content_bg = #eee
!header_bg = #fff
!text_color = #333
!title_color = #4e4e4e
!link_color = #ed1556
!link_bg = #fff
!rule_color = #c0c0c0
!watermark = #ccc
!quote_bg = #FFF
!success_bg = #bbf8aa
!success_color = #337022
!failed_bg = #fba
!failed_color = #f10

html
:background-color = !page_bg
Expand Down Expand Up @@ -205,53 +207,73 @@ a
:font-weight bold
:display block

pre.output
:background #111
:color #fff
:padding .5em
:overflow-x auto
:overflow-y auto
:max-height 50em
:font-size .825em
#build, #last_build
h1, blockquote
:border
:width 0 1px
:style solid
h1
:border-top-width 1px
blockquote
:bottom-bottom-width 1px
:line-height 1.4

.color30
:color #333
.color31
:color #e33
.color32
:color #3e3
.color33
:color #ee3
.color34
:color #33e
.color35
:color #e3e
.color36
:color #3ee
.color37
:color #fff
&.success
h1, blockquote
:background-color = !success_bg
:border-color = (!success_bg - #222) (!success_bg + #111) (!success_bg + #111) (!success_bg - #222)
h1
:color = !success_color
.meta
:color = !success_bg - #444

blockquote
:background-color = !quote_bg
:padding 1.5em
:border = 1px solid !rule_color
p
&.cite
:margin-top 1em
&.cite:before
:content ""
&.commit_author
:font-weight bold
margin-bottom: 2em
&.failed
h1, blockquote
:background-color = !failed_bg
:border-color = (!failed_bg - #222) (!failed_bg + #111) (!failed_bg + #111) (!failed_bg - #222)
h1
:color = !failed_color
.meta
:color = !failed_bg - #444

h1
:margin-top .5em
:margin-bottom 0
:padding .25em
:color = !success_color

h1#build
padding: 0.25em
&.success
:background-color = !success_bg
:color white !important
&.failed
:background-color = !failed_bg
:color white !important
blockquote
:padding .75em
:margin-bottom 2em
.meta
:margin-top 1em
:display block
:font-size .9em

pre.output
:background #111
:color #fff
:padding .5em
:overflow auto
:max-height 50em
:font-size .825em

.color30
:color #333
.color31
:color #e33
.color32
:color #3e3
.color33
:color #ee3
.color34
:color #33e
.color35
:color #e3e
.color36
:color #3ee
.color37
:color #fff

a
&.success
Expand All @@ -272,3 +294,5 @@ a
:width 50em !important
:color #666
:text-align right
strong
:font-weight bold
10 changes: 4 additions & 6 deletions lib/integrity/ui/web/views/project.haml
Expand Up @@ -8,12 +8,10 @@
You can request a
%button{ :type => :submit } manual build
- else
#last_build{ :class => @project.last_build.status }
%h1= @project.last_build.human_readable_status
%pre.output
:preserve
#{bash_color_codes @project.last_build.output}

- @build = @project.last_build
#last_build{ :class => @build.status }
= haml(:build_info, :layout => false)

%form{ :action => project_url(@project, :builds), :method => :post }
%p.submit
%button{ :type => :submit } Request Manual Build
Expand Down
31 changes: 18 additions & 13 deletions spec/ui/web_spec.rb
Expand Up @@ -24,6 +24,7 @@ def mock_project(messages={})
def mock_build(messages={})
messages = {
:status => :success,
:successful? => true,
:output => 'output',
:project => @project,
:commit_identifier => '9f6302002d2259c05a64767e0dedb15d280a4848',
Expand All @@ -35,12 +36,6 @@ def mock_build(messages={})
:commited_at => Time.mktime(2008, 7, 24, 17, 15),
:commit_message => "Add Object#tap for versions of ruby that don't have it"
}.merge(messages)
messages[:human_readable_status] =
if messages[:status] == :success
'Build Successful'
else
'Build Failed'
end
messages[:short_commit_identifier] = messages[:commit_identifier][0..5]
mock('build', messages)
end
Expand Down Expand Up @@ -252,16 +247,16 @@ def provide_valid_credentials!
status.should == 200
end

it 'should have class "success" if the latest build was successful' do
it 'should have a container with class "success" if the latest build was successful' do
@project.last_build.stub!(:status).and_return(:success)
get_it '/integrity'
body.should have_tag('#last_build[@class=success]')
body.should have_tag('#last_build.success')
end

it 'should have class "failed" if the latest build failed' do
it 'should have a container with class "failed" if the latest build failed' do
@project.last_build.stub!(:status).and_return(:failed)
get_it '/integrity'
body.should have_tag('#last_build[@class=failed]')
body.should have_tag('#last_build.failed')
end

it 'should display the output of the latest build' do
Expand Down Expand Up @@ -508,7 +503,7 @@ def do_get
it 'should colorize the status of the build' do
@build.should_receive(:status).and_return(:success)
do_get
body.should have_tag('h1[@class=success]')
body.should have_tag('#build.success')
end

it 'should display the short commit identifier' do
Expand All @@ -518,9 +513,19 @@ def do_get
end

it 'should display the author of the commit' do
@build.commit_author.should_receive(:full).and_return('Nicolás Sanguinetti <contacto@nicolassanguinetti.info>')
do_get
body.should have_tag('.commit_author', 'Nicolás Sanguinetti <contacto@nicolassanguinetti.info>')
body.should have_tag('.who', /Nicolás Sanguinetti/)
end

it 'should display the date of the commit' do
do_get
body.should have_tag('.when', /(today|yesterday|on July 24th)/)
end

it 'should display the full commit identifier' do
@build.should_receive(:commit_identifier).at_least(:once).and_return('blah blah blah')
do_get
body.should have_tag('.what', /blah blah blah/)
end

it 'should display the commit message' do
Expand Down

0 comments on commit 99191f2

Please sign in to comment.