golden_rose 0.1.0 → 1.0.0.pre

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.
@@ -2,122 +2,29 @@
2
2
  %html
3
3
  %head
4
4
  %meta{:charset => "UTF-8"}
5
- %title= @details.name
5
+ %title= @details ? @details.project_name: 'Goldenrose'
6
6
  %link{:href => "https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600&subset=latin,latin-ext", :rel => "stylesheet", :type => "text/css"}
7
- :css
8
- body { font-family: 'Source Sans Pro', sans-serif; }
9
- #container { max-width: 1170px; margin: auto;}
10
- h1 {
11
- color: #ff7726;
12
- font-size: 48px;
13
- font-weight: 600;
14
- line-height: 18px;
15
- text-align: left;
16
- margin: 73px 0 24px 0;
17
- }
18
- #details {
19
- color: #4e4e4e;
20
- margin: 0 0 60px 0;
21
- font-size: 18px;
22
- line-height: 18px;
23
- }
24
- #results { margin-right: 34px; }
25
- input[type=checkbox], input[type=checkbox] + ol > li { display: none; }
26
- input[type=checkbox]:checked + ol > li { display: block; }
27
- ol, li { position: relative; }
28
- ol { margin: 0; padding: 0 0 0 34px; }
29
- ol#collapsible { padding: 0; }
30
- ol::before {
31
- content: "▶";
32
- position: absolute;
33
- top: -33px; left: 15px;
34
- font-size: 10px;
35
- color: #ff7726;
36
- }
37
- ol#collapsible::before { display: none; }
38
- input[type=checkbox]:checked + ol::before { content: "▼"; }
39
- li { list-style: none; }
40
- label { cursor: pointer; }
41
- label, .success, .failure {
42
- padding: 13.5px 0 13.5px 34px;
43
- width: 100%;
44
- display: block;
45
- background: #f6f6f6;
46
- border-bottom: 3px #fff solid;
47
- color: #4e4e4e;
48
- letter-spacing: -0.32px;
49
- line-height: 18px;
50
- }
51
- .time, .failures-count {
52
- float: right;
53
- width: 90px;
54
- }
55
- .failures-count { color: #a80000; }
56
- .success {
57
- background: #ccffcc;
58
- color: #005e37;
59
- padding: 8.5px 0 8.5px 34px;
60
- font-weight: 400;
61
- }
62
- .failure {
63
- background: #ffcfcf;
64
- color: #a80000;
65
- }
66
- .failure-message, .failure-details {
67
- clear: both;
68
- display: block;
69
- font-size: 14px;
70
- letter-spacing: -0.28px;
71
- margin-right: 34px;
72
- }
73
- #footer {
74
- color: #4e4e4e;
75
- font-size: 14px;
76
- margin-top: 40px;
77
- }
78
- .heart { color: #ff7726 }
79
- #footer a { color: #ff7726; text-decoration: none }
7
+ = render_asset('main.css.haml', type: :css)
8
+
80
9
  %body
81
10
  #container
82
- %h1
83
- = @details.name
84
- #details
85
- #{@details.total_tests_count} tests run on
86
- %strong
87
- #{@details.model_name} iOS #{@details.os_version}
88
- with
89
- %strong
90
- #{@details.passing_count} passing
91
- and
92
- %strong
93
- #{@details.failures_count} failing
94
- in #{@details.formatted_time}
95
- #results
96
- %ol#collapsible
97
- - @items.each do |item|
98
- %li
99
- %label(for="#{item[:node_id]}")
100
- = item[:name]
101
- - if item[:failures_count]
102
- %span.failures-count
103
- = "Failures: "
104
- = item[:failures_count]
105
- %input(type="checkbox" id="#{item[:node_id]}")
106
- %ol
107
- - item[:subtests].each do |subtest|
108
- %li
109
- %span(class="#{subtest[:status]}")
110
- = subtest[:name]
111
- %span.time
112
- = subtest[:time]
113
- - if subtest[:failures]
114
- - subtest[:failures].each do |failure|
115
- .failure-message
116
- = failure[:message]
117
- .failure-details
118
- #{failure[:file_name]}:#{failure[:line_number]}
119
- #footer
120
- Made with
121
- %span.heart ❤
122
- by
123
- %a(title="PGS Software" href="https://pgs-soft.com")PGS Software
11
+ #tabs
12
+ %ul.tab
13
+ %li
14
+ %a#default-open.tablinks{href: "javascript:void(0)", onclick: "openTab(event, 'tests-id')"} Tests
15
+ %li
16
+ %a.tablinks{href: "javascript:void(0)", onclick: "openTab(event, 'build-logs-id')"} Build logs
17
+
18
+ #tests-id.tabcontent
19
+ -if @details
20
+ = render_partial '_tests.haml'
21
+ -else
22
+ %p.no-results-info No results to display!
23
+
24
+ #build-logs-id.tabcontent
25
+ = render_partial '_build_logs.haml'
26
+
27
+
28
+ = render_partial '_footer.haml'
29
+
30
+ = render_asset('main.js.haml', type: :js)
@@ -0,0 +1,38 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:charset => "UTF-8"}
5
+ %title= testable_summary_name
6
+ %link{:href => "https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600&subset=latin,latin-ext", :rel => "stylesheet", :type => "text/css"}
7
+ = render_asset('main.css.haml', type: :css)
8
+ = render_asset('test_logs.css.haml', type: :css)
9
+
10
+ %body
11
+ #container
12
+ #results
13
+ %ol#collapsible
14
+ %li
15
+ %label(for="#{item[:node_id]}")
16
+ = item[:name]
17
+ %ol
18
+ %li
19
+ %span(class="#{subtest[:status]}")
20
+ = subtest[:name]
21
+ %span.time
22
+ = subtest[:time]
23
+ - if subtest[:failures]
24
+ - subtest[:failures].each do |failure|
25
+ .failure-message
26
+ = failure[:message]
27
+ .failure-details
28
+ #{failure[:file_name]}:#{failure[:line_number]}
29
+ #test-logs
30
+ %table.table-fill
31
+ %thead
32
+ %th.text-left Started at
33
+ %th.text-left Finished at
34
+ %th.text-left Title
35
+ = render_subactivities(subtest[:activity_summaries])
36
+
37
+
38
+ = render_partial '_footer.haml'
@@ -0,0 +1,90 @@
1
+ module GoldenRose
2
+ class TestableSummary
3
+ def initialize(testable_summary)
4
+ @testable_summary = testable_summary
5
+ end
6
+
7
+ def items
8
+ @items ||= compact_results(iterate_subtests(tests))
9
+ end
10
+
11
+ def tests
12
+ raise GeneratingError, 'Tests not present.' unless @testable_summary['Tests']
13
+ @testable_summary['Tests']
14
+ end
15
+
16
+ def name
17
+ @testable_summary['TestName']
18
+ end
19
+
20
+ def formatted_time
21
+ hours = total_time / (60 * 60)
22
+ minutes = (total_time / 60) % 60
23
+ seconds = total_time % 60
24
+
25
+ "".tap do |time|
26
+ time << "#{pluralized(hours, 'hour')}, " if hours > 0
27
+ time << "#{pluralized(minutes, 'minute')} and " if minutes > 0
28
+ time << "#{pluralized(seconds, 'second')}"
29
+ end
30
+ end
31
+
32
+ def failures_count
33
+ @failures_count ||= items.reduce(0) { |count, item| count + item[:failures_count].to_i }
34
+ end
35
+
36
+ def total_tests_count
37
+ @total_tests_count ||= items.reduce(0) do |count, item|
38
+ count + (item[:subtests] ? item[:subtests].count : 0)
39
+ end
40
+ end
41
+
42
+ def passing_count
43
+ total_tests_count - failures_count
44
+ end
45
+
46
+ def total_time
47
+ @total_time ||= items.reduce(0) do |time, item|
48
+ subtests_time =
49
+ if item[:subtests]
50
+ item[:subtests].reduce(0) { |time, item| time + item[:time].to_f }
51
+ else
52
+ 0
53
+ end
54
+ time + subtests_time
55
+ end.round
56
+ end
57
+
58
+ def pluralized(number, noun)
59
+ "#{number} #{noun}#{'s' if number != 1}"
60
+ end
61
+
62
+ private
63
+
64
+ def iterate_subtests(items)
65
+ items.map do |subtest|
66
+ child_subtests = subtest["Subtests"]
67
+ next if child_subtests && child_subtests.empty?
68
+
69
+ if child_subtests
70
+ ParentItem.new(subtest).tap do |item|
71
+ item.subtests = iterate_subtests(child_subtests)
72
+ end.to_h
73
+ else
74
+ ChildItem.new(subtest).to_h
75
+ end
76
+ end.compact
77
+ end
78
+
79
+ def compact_results(items)
80
+ items.map do |subtest|
81
+ subtests = subtest[:subtests]
82
+ if subtests.any?{|sbt| sbt[:subtests]}
83
+ compact_results(subtests)
84
+ else
85
+ subtest
86
+ end
87
+ end.flatten.compact
88
+ end
89
+ end
90
+ end
@@ -1,3 +1,3 @@
1
1
  module GoldenRose
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0.pre"
3
3
  end
@@ -0,0 +1,54 @@
1
+ module GoldenRose
2
+ class XcactivitylogReader
3
+ def initialize(source_path)
4
+ @source_path = source_path
5
+ end
6
+
7
+ def self.read(source_path)
8
+ new(source_path).read
9
+ end
10
+
11
+ def read
12
+ fail XcactivitylogExtensionError.new(extension, @source_path) unless xcactivitylog_file?
13
+ Zlib::GzipReader.open(@source_path, &:read)
14
+ rescue Zlib::GzipFile::Error, Errno::ENOENT => e
15
+ raise XcactivitylogNotFound.new(@source_path, error: e)
16
+ end
17
+
18
+ def xcactivitylog_file?
19
+ 'xcactivitylog' == extension
20
+ end
21
+
22
+ def extension
23
+ @extension ||= @source_path.split('.').last
24
+ end
25
+
26
+ class XcactivitylogExtensionError < StandardError
27
+ attr_reader :file_extension, :path
28
+
29
+ def initialize(file_extension, path)
30
+ @file_extension = file_extension
31
+ @path = path
32
+ super "File under path #{path} has not correct .xcactivity extension!"
33
+ end
34
+ end
35
+
36
+ class XcactivitylogNotFound < StandardError
37
+ attr_reader :path, :options
38
+
39
+ def initialize(path, options = {})
40
+ @path = path
41
+ @options = options
42
+ @msg = error_msg(path, options[:error])
43
+ super @msg
44
+ end
45
+
46
+ private
47
+
48
+ def error_msg(path, error)
49
+ return "#{error.message} path => #{path}" if error
50
+ "File not found or it is not archive! path => #{path}"
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/golden_rose.rb CHANGED
@@ -5,18 +5,33 @@ require "golden_rose/child_item"
5
5
  require "golden_rose/parser"
6
6
  require "golden_rose/execution_details"
7
7
  require "golden_rose/results_filterer"
8
+ require "golden_rose/testable_summary"
8
9
  require "golden_rose/generators/html_format"
9
10
  require "golden_rose/cli/app"
11
+ require "golden_rose/build_log"
12
+ require "golden_rose/xcactivitylog_reader"
13
+ require "golden_rose/file_resource"
14
+ require "golden_rose/info"
15
+ require "golden_rose/class_configurator"
16
+
17
+
10
18
 
11
19
  module GoldenRose
12
- def self.generate(folder_path, output_path, format: :html)
13
- parsed_plist = Parser.new(folder_path).parse!
14
- results = ResultsFilterer.new(parsed_plist).filter!
20
+ def self.generate(folder_path, output_path, force_save, format: :html)
21
+ parser = Parser.new(folder_path)
22
+ ClassConfigurator.configure(parser.source_type, folder_path, output_path)
23
+
24
+ parsed_data = parser.parse!
25
+
26
+ parsed_plist = parsed_data.parsed_test_summaries_plist
27
+ test_results = ResultsFilterer.new(parsed_plist).filter!
28
+
29
+ build_log = parsed_data.parsed_build_logs
15
30
 
16
31
  case format
17
32
  when :html
18
- Generators::HtmlFormat.new(results, output_path).output
19
- else
33
+ Generators::HtmlFormat.new(test_results, build_log, output_path, force_save).output
34
+ else
20
35
  raise GeneratingError, "Format not supported."
21
36
  end
22
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden_rose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Róża Szylar (PGS Software)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubytree
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.7
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.7
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: |-
126
154
  A tool for generating reports from Xcode results bundle.
127
155
  Analyze results bundle directory created by Xcode during building, testing, running and generates HTML report with results.
@@ -145,17 +173,34 @@ files:
145
173
  - exe/golden_rose
146
174
  - golden_rose.gemspec
147
175
  - lib/golden_rose.rb
176
+ - lib/golden_rose/build_log.rb
177
+ - lib/golden_rose/build_log/build_section.rb
178
+ - lib/golden_rose/build_log/build_target.rb
179
+ - lib/golden_rose/build_log/parser.rb
148
180
  - lib/golden_rose/child_item.rb
181
+ - lib/golden_rose/class_configurator.rb
149
182
  - lib/golden_rose/cli/app.rb
150
183
  - lib/golden_rose/execution_details.rb
184
+ - lib/golden_rose/file_resource.rb
151
185
  - lib/golden_rose/generators/html_format.rb
186
+ - lib/golden_rose/info.rb
152
187
  - lib/golden_rose/parent_item.rb
153
188
  - lib/golden_rose/parser.rb
154
189
  - lib/golden_rose/results_filterer.rb
155
190
  - lib/golden_rose/subtest_item.rb
191
+ - lib/golden_rose/templates/_build_logs.haml
192
+ - lib/golden_rose/templates/_footer.haml
193
+ - lib/golden_rose/templates/_test_logs.haml
194
+ - lib/golden_rose/templates/_tests.haml
195
+ - lib/golden_rose/templates/assets/javascript/main.js.haml
196
+ - lib/golden_rose/templates/assets/styles/main.css.haml
197
+ - lib/golden_rose/templates/assets/styles/test_logs.css.haml
156
198
  - lib/golden_rose/templates/index.haml
199
+ - lib/golden_rose/templates/test_logs/index.haml
200
+ - lib/golden_rose/testable_summary.rb
157
201
  - lib/golden_rose/version.rb
158
- homepage: https://github.com/PGSSoft/golden_rose
202
+ - lib/golden_rose/xcactivitylog_reader.rb
203
+ homepage: https://github.com/PGSSoft/GoldenRose
159
204
  licenses:
160
205
  - MIT
161
206
  metadata: {}
@@ -170,12 +215,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
215
  version: '0'
171
216
  required_rubygems_version: !ruby/object:Gem::Requirement
172
217
  requirements:
173
- - - ">="
218
+ - - ">"
174
219
  - !ruby/object:Gem::Version
175
- version: '0'
220
+ version: 1.3.1
176
221
  requirements: []
177
222
  rubyforge_project:
178
- rubygems_version: 2.4.5.1
223
+ rubygems_version: 2.6.11
179
224
  signing_key:
180
225
  specification_version: 4
181
226
  summary: A tool for generating reports from Xcode results bundle.