octopusci 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/octopusci/io.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'ansi2html/main'
2
+
1
3
  module Octopusci
2
4
  class IO
3
5
  attr_accessor :job
@@ -26,6 +28,18 @@ module Octopusci
26
28
  end
27
29
  end
28
30
 
31
+ def read_all_out_as_html
32
+ out = StringIO.new
33
+ ::ANSI2HTML::Main.new(read_all_out(), out)
34
+ return out.string
35
+ end
36
+
37
+ def read_all_log_as_html
38
+ out = StringIO.new
39
+ ::ANSI2HTML::Main.new(read_all_log(), out)
40
+ return out.string
41
+ end
42
+
29
43
  def write_out(msg="", &block)
30
44
  write_raw_output(false, msg, &block)
31
45
  end
@@ -6,7 +6,7 @@
6
6
  </head>
7
7
  <body>
8
8
  <div style="background-color: #333; color: #fff; width: 100%;">
9
- <div style="padding: 10px; font-size: 16px;">Octopusci Build (<%= @status_str %>) - <a style="color: #fff" href="<%= @job['payload']['repository']['url'] %>"><%= @job['repo_name'] %></a> / <a style="color: #fff" href="<%= Octopusci::Config['general']['base_url'] %>/<%= @job['repo_name'] %>/<%= @job['branch_name'] %>"><%= @job['branch_name'] %></a></div>
9
+ <div style="padding: 10px; font-size: 16px;">Octopusci Build (<%= @status_str %>) - <a style="color: #fff" href="<%= @job['payload']['repository']['url'] %>"><%= @job['repo_name'] %></a> / <a style="color: #fff" href="<%= Octopusci::Config['general']['base_url'] %>/<%= @job['repo_name'] %>/<%= @job['branch_name'] %>/jobs"><%= @job['branch_name'] %></a></div>
10
10
  <div style="background-color: #e2e2e2; padding: 20px;">
11
11
  <div style="background-color: #ffffff; color: #333;">
12
12
  <div style="background-color: #F9F9F9; padding: 10px; border: 1px dotted #E6E6E6;">
@@ -75,7 +75,7 @@
75
75
  </table>
76
76
  </div>
77
77
  <div style="background-color: #333; color: #fff; padding: 10px;">
78
- <pre><code><%= Octopusci::IO.new(@job).read_all_out %></code></pre>
78
+ <pre><code><%= Octopusci::IO.new(@job).read_all_out_as_html %></code></pre>
79
79
  </div>
80
80
  </div>
81
81
  </div>
@@ -24,7 +24,7 @@
24
24
  <%= erb :job_summary, :locals => { :j => j } %>
25
25
  </div>
26
26
  <div class="job_content">
27
- <div class="job_output"><pre><code><%= Octopusci::IO.new(j).read_all_out %></code></pre></div>
27
+ <div class="job_output"><pre><code><%= Octopusci::IO.new(j).read_all_out_as_html %></code></pre></div>
28
28
  </div>
29
29
  </div>
30
30
  <% end %>
@@ -17,10 +17,10 @@
17
17
  </div>
18
18
  <div class="job_content">
19
19
  Output:
20
- <div class="output job_output" style="display: block;"><pre><code><%= Octopusci::IO.new(@job).read_all_out %></code></pre></div>
20
+ <div class="output job_output" style="display: block;"><pre><code><%= Octopusci::IO.new(@job).read_all_out_as_html %></code></pre></div>
21
21
  </div>
22
22
  <div class="job_content">
23
23
  Log:
24
- <div class="silent_output job_output" style="display: block;"><pre><code><%= Octopusci::IO.new(@job).read_all_log %></code></pre></div>
24
+ <div class="silent_output job_output" style="display: block;"><pre><code><%= Octopusci::IO.new(@job).read_all_log_as_html %></code></pre></div>
25
25
  </div>
26
26
  </div>
@@ -125,6 +125,37 @@
125
125
  .status.error {
126
126
  background-position: 0px -26px;
127
127
  }
128
+
129
+ .bold {
130
+ font-weight: bold;
131
+ }
132
+ .black {
133
+ color: black;
134
+ }
135
+ .red {
136
+ color: red;
137
+ }
138
+ .green {
139
+ color: green;
140
+ }
141
+ .yellow {
142
+ color: yellow;
143
+ }
144
+ .blue {
145
+ color: blue;
146
+ }
147
+ .magenta {
148
+ color: magenta;
149
+ }
150
+ .cyan {
151
+ color: cyan;
152
+ }
153
+ .white {
154
+ color: white;
155
+ }
156
+ .grey {
157
+ color: grey;
158
+ }
128
159
  </style>
129
160
  </head>
130
161
  <body>
@@ -48,14 +48,14 @@ module Octopusci
48
48
  protected!
49
49
  @job = Octopusci::JobStore.get(params[:job_id])
50
50
  content_type('text/plain')
51
- return Octopusci::IO.new(@job).read_all_out
51
+ return Octopusci::IO.new(@job).read_all_out_as_html
52
52
  end
53
53
 
54
54
  get '/jobs/:job_id/silent_output' do
55
55
  protected!
56
56
  @job = Octopusci::JobStore.get(params[:job_id])
57
57
  content_type('text/plain')
58
- return Octopusci::IO.new(@job).read_all_log
58
+ return Octopusci::IO.new(@job).read_all_log_as_html
59
59
  end
60
60
 
61
61
  get '/jobs/:job_id/status' do
@@ -1,3 +1,3 @@
1
1
  module Octopusci
2
- Version = VERSION = '0.3.1'
2
+ Version = VERSION = '0.3.2'
3
3
  end
@@ -50,6 +50,52 @@ describe Octopusci::IO do
50
50
  end
51
51
  end
52
52
 
53
+ describe "#read_all_out_as_html" do
54
+ it "should get all the output using read_all_out" do
55
+ io = Octopusci::IO.new({ 'id' => 23 })
56
+ io.should_receive(:read_all_out).and_return("\e[31msome stuff\e[0m")
57
+ io.read_all_out_as_html
58
+ end
59
+
60
+ it "should parse the output using ansi2html" do
61
+ io = Octopusci::IO.new({ 'id' => 23 })
62
+ io.stub(:read_all_out).and_return("raw out")
63
+ out = stub("string io out obj", :string => "raw out")
64
+ StringIO.stub(:new).and_return(out)
65
+ ANSI2HTML::Main.should_receive(:new).with("raw out", out)
66
+ io.read_all_out_as_html
67
+ end
68
+
69
+ it "should wrap ansi colored strings in spans which are classed based on the color" do
70
+ io = Octopusci::IO.new({ 'id' => 23 })
71
+ io.stub(:read_all_out).and_return("\e[31msome stuff\e[0m")
72
+ io.read_all_out_as_html.should == '<span class="red">some stuff</span>'
73
+ end
74
+ end
75
+
76
+ describe "#read_all_log_as_html" do
77
+ it "should get all the log using read_all_log" do
78
+ io = Octopusci::IO.new({ 'id' => 23 })
79
+ io.should_receive(:read_all_log).and_return("\e[31msome stuff\e[0m")
80
+ io.read_all_log_as_html.should == '<span class="red">some stuff</span>'
81
+ end
82
+
83
+ it "should parse the log using ansi2html" do
84
+ io = Octopusci::IO.new({ 'id' => 23 })
85
+ io.stub(:read_all_log).and_return("raw out")
86
+ out = stub("string io out obj", :string => "raw out")
87
+ StringIO.stub(:new).and_return(out)
88
+ ANSI2HTML::Main.should_receive(:new).with("raw out", out)
89
+ io.read_all_log_as_html
90
+ end
91
+
92
+ it "should wrap ansi colored strings in spans which are classed based on the color" do
93
+ io = Octopusci::IO.new({ 'id' => 23 })
94
+ io.stub(:read_all_log).and_return("\e[31msome stuff\e[0m")
95
+ io.read_all_log_as_html.should == '<span class="red">some stuff</span>'
96
+ end
97
+ end
98
+
53
99
  describe "#open_log_for_writing" do
54
100
  end
55
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopusci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-04 00:00:00.000000000 Z
13
+ date: 2011-11-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
17
- requirement: &70259579364000 !ruby/object:Gem::Requirement
17
+ requirement: &70341263390120 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70259579364000
25
+ version_requirements: *70341263390120
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: json
28
- requirement: &70259579362960 !ruby/object:Gem::Requirement
28
+ requirement: &70341263387220 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70259579362960
36
+ version_requirements: *70341263387220
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: resque
39
- requirement: &70259579362420 !ruby/object:Gem::Requirement
39
+ requirement: &70341263386620 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70259579362420
47
+ version_requirements: *70341263386620
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: actionmailer
50
- requirement: &70259579361940 !ruby/object:Gem::Requirement
50
+ requirement: &70341263383580 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70259579361940
58
+ version_requirements: *70341263383580
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: multi_json
61
- requirement: &70259579361340 !ruby/object:Gem::Requirement
61
+ requirement: &70341263381500 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70259579361340
69
+ version_requirements: *70341263381500
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: time-ago-in-words
72
- requirement: &70259579359920 !ruby/object:Gem::Requirement
72
+ requirement: &70341263380620 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,21 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *70259579359920
80
+ version_requirements: *70341263380620
81
+ - !ruby/object:Gem::Dependency
82
+ name: ansi2html
83
+ requirement: &70341263379340 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: *70341263379340
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: rake
83
- requirement: &70259579358720 !ruby/object:Gem::Requirement
94
+ requirement: &70341263376980 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ! '>='
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: '0'
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *70259579358720
102
+ version_requirements: *70341263376980
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: rspec
94
- requirement: &70259579358280 !ruby/object:Gem::Requirement
105
+ requirement: &70341263375700 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ! '>='
@@ -99,10 +110,10 @@ dependencies:
99
110
  version: '0'
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *70259579358280
113
+ version_requirements: *70341263375700
103
114
  - !ruby/object:Gem::Dependency
104
115
  name: rack-test
105
- requirement: &70259579357680 !ruby/object:Gem::Requirement
116
+ requirement: &70341263374920 !ruby/object:Gem::Requirement
106
117
  none: false
107
118
  requirements:
108
119
  - - ! '>='
@@ -110,10 +121,10 @@ dependencies:
110
121
  version: '0'
111
122
  type: :development
112
123
  prerelease: false
113
- version_requirements: *70259579357680
124
+ version_requirements: *70341263374920
114
125
  - !ruby/object:Gem::Dependency
115
126
  name: guard
116
- requirement: &70259579357000 !ruby/object:Gem::Requirement
127
+ requirement: &70341263374160 !ruby/object:Gem::Requirement
117
128
  none: false
118
129
  requirements:
119
130
  - - ! '>='
@@ -121,10 +132,10 @@ dependencies:
121
132
  version: '0'
122
133
  type: :development
123
134
  prerelease: false
124
- version_requirements: *70259579357000
135
+ version_requirements: *70341263374160
125
136
  - !ruby/object:Gem::Dependency
126
137
  name: rb-fsevent
127
- requirement: &70259579356360 !ruby/object:Gem::Requirement
138
+ requirement: &70341263373260 !ruby/object:Gem::Requirement
128
139
  none: false
129
140
  requirements:
130
141
  - - ! '>='
@@ -132,10 +143,10 @@ dependencies:
132
143
  version: '0'
133
144
  type: :development
134
145
  prerelease: false
135
- version_requirements: *70259579356360
146
+ version_requirements: *70341263373260
136
147
  - !ruby/object:Gem::Dependency
137
148
  name: growl_notify
138
- requirement: &70259579355560 !ruby/object:Gem::Requirement
149
+ requirement: &70341263372800 !ruby/object:Gem::Requirement
139
150
  none: false
140
151
  requirements:
141
152
  - - ! '>='
@@ -143,10 +154,10 @@ dependencies:
143
154
  version: '0'
144
155
  type: :development
145
156
  prerelease: false
146
- version_requirements: *70259579355560
157
+ version_requirements: *70341263372800
147
158
  - !ruby/object:Gem::Dependency
148
159
  name: guard-rspec
149
- requirement: &70259579354800 !ruby/object:Gem::Requirement
160
+ requirement: &70341263372340 !ruby/object:Gem::Requirement
150
161
  none: false
151
162
  requirements:
152
163
  - - ! '>='
@@ -154,7 +165,7 @@ dependencies:
154
165
  version: '0'
155
166
  type: :development
156
167
  prerelease: false
157
- version_requirements: *70259579354800
168
+ version_requirements: *70341263372340
158
169
  description: A multi-branch Continous Integration server that integrates with GitHub
159
170
  email:
160
171
  - cyphactor@gmail.com