xcpretty-json-formatter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2ef5a7102d954fc4ef5574147d83b3e4802b036
4
+ data.tar.gz: 1a5ef61d0584d4171408f146cdad0b63783fc2e3
5
+ SHA512:
6
+ metadata.gz: 09e83fcd418329b86c20e87e3183e93ad29e592da3c9a42068653b7f1c42fb970d7795bf4759e4d9c694b6d217ab7ca62348c8a5368501ff8297026bb287ac61
7
+ data.tar.gz: d0dd1463d9fcc3fa0848c2c076f8eabe23ae67e07c57ba681e0556dc34ccd5de6dd85a5edd0d33bd150da31d657e2d64a444a71797ff6d2d4e90afb14d70cbeb
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcelo Fabri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # XCPretty JSON Formatter
2
+
3
+ Custom formatter for [xcpretty](https://github.com/supermarin/xcpretty) that saves on a JSON file all the errors, warnings and test failures, so you can process them easily later.
4
+
5
+ ## Installation
6
+
7
+ This formatter is distributed via RubyGems, and depends on a version of `xcpretty` >= 0.0.7 (when custom formatters were introduced). Run:
8
+
9
+ gem install xcpretty-json-formatter
10
+
11
+ ## Usage
12
+
13
+ Specify `xcpretty-json-formatter` as a custom formatter to `xcpretty`:
14
+
15
+ ```bash
16
+ #!/bin/bash
17
+
18
+ xcodebuild | xcpretty -f `xcpretty-json-formatter`
19
+ ```
20
+
21
+ By default, `xcpretty-json-formatter` writes the result in `build/reports/errors.json`, but you can change that with an environment variable:
22
+
23
+ ```bash
24
+ #!/bin/bash
25
+
26
+ xcodebuild | XCPRETTY_JSON_FILE_OUTPUT=result.json xcpretty -f `xcpretty-json-formatter`
27
+ ```
28
+
29
+ ## Thanks
30
+
31
+ * [Marin Usalj](http://github.com/supermarin) and [Delisa Mason](http://github.com/kattrali) for creating [xcpretty](https://github.com/supermarin/xcpretty).
32
+ * [Delisa Mason](http://github.com/kattrali) for creating [xcpretty-travis-formatter](https://github.com/kattrali/xcpretty-travis-formatter), which I used as a guide.
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcelofabri/xcpretty-json-formatter.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ print File.expand_path('../../lib/json_formatter.rb', __FILE__)
@@ -0,0 +1,130 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+
4
+ class JSONFormatter < XCPretty::Simple
5
+ FILE_PATH = 'build/reports/errors.json'
6
+
7
+ def initialize(use_unicode, colorize)
8
+ super
9
+ @warnings = []
10
+ @ld_warnings = []
11
+ @compile_warnings = []
12
+ @errors = []
13
+ @compile_errors = []
14
+ @file_missing_errors = []
15
+ @undefined_symbols_errors = []
16
+ @duplicate_symbols_errors = []
17
+ @failures = {}
18
+ end
19
+
20
+ def format_ld_warning(message)
21
+ @ld_warnings << message
22
+ write_to_file_if_needed
23
+ super
24
+ end
25
+
26
+ def format_warning(message)
27
+ @warnings << message
28
+ write_to_file_if_needed
29
+ super
30
+ end
31
+
32
+ def format_compile_warning(file_name, file_path, reason, line, cursor)
33
+ @compile_warnings << {
34
+ :file_name => file_name,
35
+ :file_path => file_path,
36
+ :reason => reason,
37
+ :line => line,
38
+ :cursor => cursor
39
+ }
40
+ write_to_file_if_needed
41
+ super
42
+ end
43
+
44
+ def format_error(message)
45
+ @errors << message
46
+ write_to_file_if_needed
47
+ super
48
+ end
49
+
50
+ def format_compile_error(file, file_path, reason, line, cursor)
51
+ @compile_errors << {
52
+ :file_name => file,
53
+ :file_path => file_path,
54
+ :reason => reason,
55
+ :line => line,
56
+ :cursor => cursor
57
+ }
58
+ write_to_file_if_needed
59
+ super
60
+ end
61
+
62
+ def format_file_missing_error(reason, file_path)
63
+ @file_missing_errors << {
64
+ :file_path => file_path,
65
+ :reason => reason
66
+ }
67
+ write_to_file_if_needed
68
+ super
69
+ end
70
+
71
+ def format_undefined_symbols(message, symbol, reference)
72
+ @undefined_symbols_errors = {
73
+ :message => message,
74
+ :symbol => symbol,
75
+ :reference => reference
76
+ }
77
+ write_to_file_if_needed
78
+ super
79
+ end
80
+
81
+ def format_duplicate_symbols(message, file_paths)
82
+ @duplicate_symbols_errors = {
83
+ :message => message,
84
+ :file_paths => file_paths,
85
+ }
86
+ write_to_file_if_needed
87
+ super
88
+ end
89
+
90
+ def format_test_summary(message, failures_per_suite)
91
+ @failures = failures_per_suite
92
+ write_to_file_if_needed
93
+ super
94
+ end
95
+
96
+ def finish
97
+ write_to_file
98
+ super
99
+ end
100
+
101
+ def json_output
102
+ {
103
+ :warnings => @warnings,
104
+ :ld_warnings => @ld_warnings,
105
+ :compile_warnings => @compile_warnings,
106
+ :errors => @errors,
107
+ :compile_errors => @compile_errors,
108
+ :file_missing_errors => @file_missing_errors,
109
+ :undefined_symbols_errors => @undefined_symbols_errors,
110
+ :duplicate_symbols_errors => @duplicate_symbols_errors,
111
+ :tests_failures => @failures
112
+ }
113
+ end
114
+
115
+ def write_to_file_if_needed
116
+ write_to_file unless XCPretty::Formatter.method_defined? :finish
117
+ end
118
+
119
+ def write_to_file
120
+ file_name = ENV['XCPRETTY_JSON_FILE_OUTPUT'] || FILE_PATH
121
+ dirname = File.dirname(file_name)
122
+ FileUtils::mkdir_p dirname
123
+
124
+ File.open(file_name, 'w') { |io|
125
+ io.write(JSON.pretty_generate(json_output))
126
+ }
127
+ end
128
+ end
129
+
130
+ JSONFormatter
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcpretty-json-formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Marcelo Fabri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcpretty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.11'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.11'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ description: Custom formatter for xcpretty that saves on a JSON file all the errors,
76
+ warnings and test failures, so you can process them easily later.
77
+ email:
78
+ - me@marcelofabri.com
79
+ executables:
80
+ - xcpretty-json-formatter
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - LICENSE
85
+ - README.md
86
+ - bin/xcpretty-json-formatter
87
+ - lib/json_formatter.rb
88
+ homepage: https://github.com/marcelofabri/xcpretty-json-formatter
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.6.0
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: xcpretty custom formatter for JSON output
112
+ test_files: []
113
+ has_rdoc: