report_builder 1.1 → 1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00892c5d6224e96d04466699112d44d4eee6b076
4
- data.tar.gz: 95dbf46bed166d49d13a6f39808e5b406549da83
3
+ metadata.gz: f9863bb61c867e174d7eb72a11753742b4d8ffaa
4
+ data.tar.gz: 1d2fc605738472f645bda76e01ecd72bd6f33687
5
5
  SHA512:
6
- metadata.gz: 5b193aaf917a4c6663cacae2059c8c0f251c8f1121d8685c88e865be3dd8831e95e1dfef083288720e9b70b7f4ae103045379790bd71d0056e2c28669d17ba5e
7
- data.tar.gz: d2ce2da99c3926e012e3d63a88ecc84f3825756aeefb792ab0e6a78fd120be618fbc8b9f4edb23fc03b6dfa712da59425a58a7a9e3cc5260f51e6dbf641684a1
6
+ metadata.gz: 20491fa5730f4bd28ce944b5d4a6b7ae44cfb2ac1469d62aa6990564f0888736f934bb8235a8facab8f7594f275074fc8c1afff36d7463a9f59b3c76c8eb1a1e
7
+ data.tar.gz: 773c9a288a135acbecf724aa8997668e7f4069f819aa541945b9e193c393a3f46e8b77c91c0accc15734c4eb02fc70d8d502329de331d1488b7f00dd237c254e
data/README.md CHANGED
@@ -77,7 +77,7 @@ gem install report_builder
77
77
  | --html_out | [PATH]NAME | Same as the -o option but will only apply the html report format |
78
78
  | --retry_out | [PATH]NAME | Same as the -o option but will only apply the retry report format |
79
79
  | -f, --format | x,y,z | List of report format - html,json,retry |
80
- | --[no-]images | | Reduce report size by excluding embedded images |
80
+ | --[no-]images | | Reduce HTML report size by excluding embedded images |
81
81
  | -T, --title | TITLE | Report title |
82
82
  | -I, --info | a:x,b:y,c:z | List of additional info about test - key:value |
83
83
  | -h, --help | | Show available command line switches |
data/bin/report_builder CHANGED
@@ -40,7 +40,7 @@ opt_parser = OptionParser.new do |opts|
40
40
  options[:report_types] = list
41
41
  end
42
42
 
43
- opts.on('--[no-]images', 'Reduce report size by excluding embedded images') do |include_images|
43
+ opts.on('--[no-]images', 'Reduce HTML report size by excluding embedded images') do |include_images|
44
44
  options[:include_images] = include_images
45
45
  end
46
46
 
@@ -55,10 +55,6 @@ module ReportBuilder
55
55
  )
56
56
  end
57
57
 
58
- def decode(data)
59
- (Base64.decode64(data) rescue data).gsub(/^data:image\/(png|gif|jpg|jpeg)\;base64,/, '')
60
- end
61
-
62
58
  private
63
59
 
64
60
  def get_files(path)
@@ -121,13 +117,22 @@ module ReportBuilder
121
117
  after['result']['duration'] ||= 0
122
118
  duration += after['result']['duration']
123
119
  status = 'failed' if after['result']['status'] == 'failed'
120
+ after['embeddings'].map! { |embedding|
121
+ decode_embedding(embedding)
122
+ } if after['embeddings']
124
123
  after.merge! 'status' => after['result']['status'], 'duration' => after['result']['duration']
125
124
  } if step['after']
125
+ step['embeddings'].map! { |embedding|
126
+ decode_embedding(embedding)
127
+ } if step['embeddings']
126
128
  step.merge! 'status' => status, 'duration' => duration
127
129
  }
128
130
  scenario['after'] ||= []
129
131
  scenario['after'].each {|after|
130
132
  after['result']['duration'] ||= 0
133
+ after['embeddings'].map! { |embedding|
134
+ decode_embedding(embedding)
135
+ } if after['embeddings']
131
136
  after.merge! 'status' => after['result']['status'], 'duration' => after['result']['duration']
132
137
  }
133
138
  scenario.merge! 'status' => scenario_status(scenario), 'duration' => total_time(scenario['before']) + total_time(scenario['steps']) + total_time(scenario['after'])
@@ -154,6 +159,33 @@ module ReportBuilder
154
159
  'passed'
155
160
  end
156
161
 
162
+ def decode_image(data)
163
+ base64 = /^([A-Za-z0-9+\/]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$/
164
+ if data =~ base64
165
+ data_base64 = Base64.decode64(data).gsub(/^data:image\/(png|gif|jpg|jpeg)\;base64,/, '')
166
+ if data_base64 =~ base64
167
+ data_base64
168
+ else
169
+ data
170
+ end
171
+ else
172
+ ''
173
+ end
174
+ end
175
+
176
+ def decode_text(data)
177
+ Base64.decode64 data
178
+ end
179
+
180
+ def decode_embedding(embedding)
181
+ if embedding['mime_type'] =~ /^image\/(png|gif|jpg|jpeg)/
182
+ embedding['data'] = decode_image(embedding['data'])
183
+ elsif embedding['mime_type'] =~ /^text\/plain/
184
+ embedding['data'] = decode_text(embedding['data'])
185
+ end
186
+ embedding
187
+ end
188
+
157
189
  def total_time(data)
158
190
  total_time = 0
159
191
  data.each {|item| total_time += item['duration']}
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'report_builder'
3
- s.version = '1.1'
3
+ s.version = '1.2'
4
4
  s.bindir = 'bin'
5
5
  s.summary = 'ReportBuilder'
6
6
  s.description = 'Ruby gem to merge Cucumber JSON reports and build mobile friendly HTML Test Report, JSON report and retry file.'
@@ -30,6 +30,7 @@
30
30
  <%end%>
31
31
 
32
32
  <h5><%=scenario['name']%></h5>
33
+ <%=feature['uri']%>:<%=scenario['line']%>
33
34
 
34
35
  <%if scenario['before']%>
35
36
  <%scenario['before'].each do |before|%>
@@ -99,16 +100,15 @@
99
100
 
100
101
  <%if step['embeddings']%>
101
102
  <%step['embeddings'].each do |embedding|%>
102
- <%data=decode(embedding['data'])%>
103
103
  <%if embedding['mime_type'] =~ /^image\/(png|gif|jpg|jpeg)/ %>
104
104
  <%if options[:include_images]%>
105
- <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=data%>">
105
+ <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=embedding['data']%>">
106
106
  <%end%>
107
107
  <%elsif embedding['mime_type'] =~ /^text\/plain/%>
108
- <%if data.include?('|||')%>
109
- <%title, link = src.split('|||')%><a href="<%=link%>"><%title%></a>
108
+ <%if embedding['data'].include?('|||')%>
109
+ <%title, link = embedding['data'].split('|||')%><a href="<%=link%>"><%=title%></a>
110
110
  <%else%>
111
- <%data%>
111
+ <%=embedding['data']%>
112
112
  <%end%>
113
113
  <%end%>
114
114
  <%end%>
@@ -129,16 +129,15 @@
129
129
 
130
130
  <%if after['embeddings']%>
131
131
  <%after['embeddings'].each do |embedding|%>
132
- <%data=decode(embedding['data'])%>
133
132
  <%if embedding['mime_type'] =~ /^image\/(png|gif|jpg|jpeg)/ %>
134
133
  <%if options[:include_images]%>
135
- <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=data%>">
134
+ <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=embedding['data']%>">
136
135
  <%end%>
137
136
  <%elsif embedding['mime_type'] =~ /^text\/plain/%>
138
- <%if data.include?('|||')%>
139
- <%title, link = src.split('|||')%><a href="<%=link%>"><%title%></a>
137
+ <%if embedding['data'].include?('|||')%>
138
+ <%title, link = embedding['data'].split('|||')%><a href="<%=link%>"><%=title%></a>
140
139
  <%else%>
141
- <%data%>
140
+ <%=embedding['data']%>
142
141
  <%end%>
143
142
  <%end%>
144
143
  <%end%>
@@ -165,16 +164,15 @@
165
164
 
166
165
  <%if after['embeddings']%>
167
166
  <%after['embeddings'].each do |embedding|%>
168
- <%data=decode(embedding['data'])%>
169
167
  <%if embedding['mime_type'] =~ /^image\/(png|gif|jpg|jpeg)/ %>
170
168
  <%if options[:include_images]%>
171
- <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=data%>">
169
+ <img class="materialboxed" data-caption='<%=scenario['name']%>' width="250" src="data:<%=embedding['mime_type']%>;base64,<%=embedding['data']%>">
172
170
  <%end%>
173
171
  <%elsif embedding['mime_type'] =~ /^text\/plain/%>
174
- <%if data.include?('|||')%>
175
- <%title, link = src.split('|||')%><a href="<%=link%>"><%title%></a>
172
+ <%if embedding['data'].include?('|||')%>
173
+ <%title, link = embedding['data'].split('|||')%><a href="<%=link%>"><%=title%></a>
176
174
  <%else%>
177
- <%data%>
175
+ <%=embedding['data']%>
178
176
  <%end%>
179
177
  <%end%>
180
178
  <%end%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: report_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajat Thareja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-07 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json