xcperfect 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/README.md +8 -8
- data/lib/xcperfect.rb +1 -0
- data/lib/xcperfect/ansi.rb +13 -0
- data/lib/xcperfect/bar.rb +24 -0
- data/lib/xcperfect/formatters/all.rb +21 -8
- data/lib/xcperfect/formatters/formatter.rb +8 -12
- data/lib/xcperfect/parser.rb +1 -1
- data/lib/xcperfect/printer.rb +0 -2
- data/lib/xcperfect/version.rb +1 -1
- data/xcperfect.gemspec +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2314ead27375f324020955f3715ab6857ba356cc
|
4
|
+
data.tar.gz: a1afc6fed3d96d64c6e36cc3c27bd2a0ac0be790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69876044da3ecb662dc85ba25e4ceca6c18f8e0efe2db6d4533eb122f1767f7a36b7ab685c98a66a113f162a80526e7a0523cb3492bfada61f5dacb2c762bc40
|
7
|
+
data.tar.gz: 57b14bc960f08de8e4b0e36ce62ef33ed13828ab9405874d9b7fa00d98951f4646ccb7c72c95ab5d4517c326a7d7d553f936632a8cd22fa7f7e227a6547f30c3
|
data/.hound.yml
ADDED
data/README.md
CHANGED
@@ -5,6 +5,9 @@
|
|
5
5
|
<a href="https://travis-ci.org/mkchoi212/xcperfect">
|
6
6
|
<img src="https://travis-ci.org/mkchoi212/xcperfect.svg?branch=master">
|
7
7
|
</a>
|
8
|
+
<a href="https://badge.fury.io/rb/xcperfect">
|
9
|
+
<img src="https://badge.fury.io/rb/xcperfect.svg">
|
10
|
+
</a>
|
8
11
|
</p>
|
9
12
|
</p>
|
10
13
|
<br>
|
@@ -17,23 +20,20 @@ $ gem install xcperfect
|
|
17
20
|
|
18
21
|
## Usage
|
19
22
|
|
20
|
-
|
21
|
-
$ xcrun xccov --json [options] | xcperfect
|
22
|
-
```
|
23
|
-
|
24
|
-
or
|
23
|
+
- Pipe
|
25
24
|
|
26
25
|
```bash
|
27
|
-
$ xcrun xccov --json [options]
|
28
|
-
$ xcperfect report.json
|
26
|
+
$ xcrun xccov --json [options] | xcperfect [options]
|
29
27
|
```
|
30
28
|
|
31
|
-
|
29
|
+
- Feed it in via flags
|
32
30
|
|
33
31
|
```bash
|
34
32
|
$ xcperfect [--file | -f] report.json [options]
|
35
33
|
```
|
36
34
|
|
35
|
+
> ⚠️ Please note that `xcperfect` only takes in `xccov` json output
|
36
|
+
|
37
37
|
## Formats
|
38
38
|
|
39
39
|
- `--all`, `-a` **Default**
|
data/lib/xcperfect.rb
CHANGED
data/lib/xcperfect/ansi.rb
CHANGED
@@ -27,6 +27,19 @@ module XCPerfect
|
|
27
27
|
!!@colorize
|
28
28
|
end
|
29
29
|
|
30
|
+
def color_for(percentage)
|
31
|
+
case (percentage * 100).round
|
32
|
+
when 0..33
|
33
|
+
->(x) { red(x) }
|
34
|
+
when 33...66
|
35
|
+
->(x) { yellow(x) }
|
36
|
+
when 66..100
|
37
|
+
->(x) { green(x) }
|
38
|
+
else
|
39
|
+
raise "Percentage of #{percentage * 100} is not possible"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
30
43
|
def white(text)
|
31
44
|
ansi_parse(text, :plain, :bold)
|
32
45
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'xcperfect/ansi'
|
2
|
+
|
3
|
+
module XCPerfect
|
4
|
+
# Bar is a "progress bar" that is used to represent
|
5
|
+
# the code coverage percentage
|
6
|
+
class Bar
|
7
|
+
BLOCK = '█'.freeze
|
8
|
+
BLOCK_ASCII = '#'.freeze
|
9
|
+
extend ANSI
|
10
|
+
|
11
|
+
def self.create(percentage, bar_length, color, ascii)
|
12
|
+
@colorize = color
|
13
|
+
block_symbol = ascii ? BLOCK_ASCII : BLOCK
|
14
|
+
|
15
|
+
progress_length = (bar_length * percentage).round
|
16
|
+
filled = block_symbol * progress_length
|
17
|
+
remaining = red('-' * (bar_length - progress_length))
|
18
|
+
|
19
|
+
color_func = color_for(percentage)
|
20
|
+
bar = color_func.call(filled) + remaining
|
21
|
+
"|#{bar}| #{percentage * 100} %"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,6 +3,15 @@ module XCPerfect
|
|
3
3
|
class All < Formatter
|
4
4
|
DOWN = '▼'.freeze
|
5
5
|
DOWN_ASCII = '->'.freeze
|
6
|
+
STAT_WIDTH = 10
|
7
|
+
|
8
|
+
def bar_width
|
9
|
+
((@terminal_width - 8) * 0.3) - STAT_WIDTH
|
10
|
+
end
|
11
|
+
|
12
|
+
def signature_width
|
13
|
+
(@terminal_width - 8) * 0.62
|
14
|
+
end
|
6
15
|
|
7
16
|
def pretty_name(target)
|
8
17
|
symbol = yellow(@use_ascii ? DOWN_ASCII : DOWN)
|
@@ -12,21 +21,25 @@ module XCPerfect
|
|
12
21
|
def pretty_functions(file)
|
13
22
|
file['functions'].map do |function|
|
14
23
|
filename = file['name']
|
15
|
-
signature, covered, total, percentage =
|
16
|
-
|
17
|
-
|
24
|
+
signature, covered, total, percentage = @parser.extract_coverage_info(function)
|
25
|
+
|
26
|
+
line_stats = "#{covered} / #{total}".ljust(STAT_WIDTH)
|
18
27
|
highlighted = Syntax.highlight(filename, signature)
|
28
|
+
|
19
29
|
delta = highlighted.length - signature.length
|
20
|
-
|
21
|
-
|
30
|
+
highlighted = highlighted.ljust(signature_width + delta)
|
31
|
+
|
32
|
+
texts = spaces(8) + [highlighted, line_stats].join(' ')
|
33
|
+
bar = Bar.create(percentage, bar_width, @colorize, @use_ascii)
|
34
|
+
texts + bar
|
22
35
|
end
|
23
36
|
end
|
24
37
|
|
25
38
|
def pretty_files(target)
|
26
39
|
target['files'].map do |file|
|
27
|
-
name =
|
28
|
-
|
29
|
-
[name,
|
40
|
+
name = spaces(4) + pretty_name(file)
|
41
|
+
functions = pretty_functions(file)
|
42
|
+
[name, functions]
|
30
43
|
end.join("\n")
|
31
44
|
end
|
32
45
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'xcperfect/ansi'
|
2
|
+
require 'xcperfect/bar'
|
2
3
|
require 'xcperfect/parser'
|
3
4
|
|
4
5
|
module XCPerfect
|
@@ -19,19 +20,14 @@ module XCPerfect
|
|
19
20
|
puts @json
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
23
|
+
def spaces(cnt)
|
24
|
+
' ' * cnt
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
orange(percent_str)
|
30
|
-
when 66..100
|
31
|
-
green(percent_str)
|
32
|
-
else
|
33
|
-
raise "Percentage of #{percentage} % is not possible :("
|
34
|
-
end
|
27
|
+
def color_percentage(percentage)
|
28
|
+
color_func = color_for(percentage)
|
29
|
+
str_rep = (percentage * 100).to_s + ' %'
|
30
|
+
color_func.call(str_rep)
|
35
31
|
end
|
36
32
|
|
37
33
|
def pretty_coverage_info(target)
|
data/lib/xcperfect/parser.rb
CHANGED
data/lib/xcperfect/printer.rb
CHANGED
data/lib/xcperfect/version.rb
CHANGED
data/xcperfect.gemspec
CHANGED
@@ -10,10 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.required_ruby_version = '>= 2.0.0'
|
11
11
|
spec.description =
|
12
12
|
%q{
|
13
|
-
|
13
|
+
Make your xccov output prettier. Because who doesn't
|
14
14
|
like pretty outputs? Am I rite?
|
15
15
|
}
|
16
|
-
spec.summary = %q(
|
16
|
+
spec.summary = %q(Better looking xccov reports)
|
17
17
|
spec.homepage = 'https://github.com/mkchoi212/xcperfect'
|
18
18
|
spec.license = 'MIT'
|
19
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcperfect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike JS. Choi
|
@@ -66,8 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.49.0
|
69
|
-
description: "\n
|
70
|
-
|
69
|
+
description: "\n Make your xccov output prettier. Because who doesn't\n like
|
70
|
+
pretty outputs? Am I rite?\n "
|
71
71
|
email:
|
72
72
|
- mkchoi212@icloud.com
|
73
73
|
executables:
|
@@ -76,6 +76,7 @@ extensions: []
|
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
|
+
- ".hound.yml"
|
79
80
|
- ".rubocop.yml"
|
80
81
|
- ".travis.yml"
|
81
82
|
- Gemfile
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- bin/xcperfect
|
90
91
|
- lib/xcperfect.rb
|
91
92
|
- lib/xcperfect/ansi.rb
|
93
|
+
- lib/xcperfect/bar.rb
|
92
94
|
- lib/xcperfect/formatters/all.rb
|
93
95
|
- lib/xcperfect/formatters/formatter.rb
|
94
96
|
- lib/xcperfect/formatters/simple.rb
|
@@ -120,5 +122,5 @@ rubyforge_project:
|
|
120
122
|
rubygems_version: 2.5.2
|
121
123
|
signing_key:
|
122
124
|
specification_version: 4
|
123
|
-
summary:
|
125
|
+
summary: Better looking xccov reports
|
124
126
|
test_files: []
|