xccov-parse 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/lib/xccov/parse.rb +46 -1
- data/lib/xccov/parse/version.rb +2 -4
- data/xccov-parse.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb6af6827f4b01f4e0297cbd872a08441bf35b88
|
4
|
+
data.tar.gz: b7e22890f96d710a8923b0b354157bb5f243473a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5eb4053c017188e55e61089dabcb25998b58c1d11c9db8969d49976b0182cdd5e35fd36cfe52670f2d0eb2785cc139a6ede0108f835cec137ec4f02d1f2c39b
|
7
|
+
data.tar.gz: a81283ebb6c111c1e93a01917f7f8b910281ed5017316e5a6b1788cb6798e857d81720156e6a030d645c2011d005a22c80566e731f2152020115e13c9972c853
|
data/README.md
CHANGED
@@ -19,11 +19,21 @@ Or install it yourself as:
|
|
19
19
|
## Usage
|
20
20
|
|
21
21
|
1. Generate the json result by `xcrun xccov view --only-targets --json`
|
22
|
-
```
|
23
|
-
|
22
|
+
```bash
|
23
|
+
# target: https://github.com/KazuCocoa/test.examples
|
24
|
+
$ git clone https://github.com/KazuCocoa/test.examples && cd test.examples
|
25
|
+
$ xcodebuild -workspace test.examples.xcworkspace -scheme test.examples -derivedDataPath Build/ -destination 'platform=iOS Simulator,OS=11.3,name=iPhone 7' -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
|
24
26
|
```
|
25
27
|
2. Read the JSON and get a particular line coverage
|
26
28
|
```ruby
|
29
|
+
xccov = Xccov.new
|
30
|
+
xccov.help
|
31
|
+
json = xccov.view '--only-targets', '--json', 'Build/Logs/Test/*.xccovreport'
|
32
|
+
parsed = Xccov::Parse.new(json: json)
|
33
|
+
parsed.targets_line_coverage["test.examples.app"] #=> 0.35
|
34
|
+
|
35
|
+
# or
|
36
|
+
# $ xcrun xccov view --only-targets --json Build/Logs/Test/*.xccovreport > result.json
|
27
37
|
parsed = Xccov::Parse.new(file: './result.json')
|
28
38
|
parsed.targets_line_coverage["test.examples.app"] #=> 0.35
|
29
39
|
```
|
data/lib/xccov/parse.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "xccov/parse/version"
|
2
2
|
require "json"
|
3
3
|
|
4
|
-
|
4
|
+
require 'open3'
|
5
|
+
|
6
|
+
class Xccov
|
5
7
|
class Parse
|
6
8
|
attr_reader :data
|
7
9
|
|
@@ -20,4 +22,47 @@ module Xccov
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
25
|
+
|
26
|
+
# @example
|
27
|
+
#
|
28
|
+
# xccov = Xccov.new
|
29
|
+
# xccov.help
|
30
|
+
# json = xccov.view '--only-targets', '--json', '/path/to/Build/Logs/Test/*.xccovreport'
|
31
|
+
# parsed = Xccov::Parse.new(json: json)
|
32
|
+
# parsed.targets_line_coverage["test.examples.app"] #=> 0.35
|
33
|
+
#
|
34
|
+
def initialize
|
35
|
+
@xccov = "#{get_xcrun} xccov"
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def run(*args)
|
41
|
+
cmd = args.join ' '
|
42
|
+
sto, ste, status = Open3.capture3(cmd)
|
43
|
+
if status.success?
|
44
|
+
sto
|
45
|
+
else
|
46
|
+
puts ste
|
47
|
+
raise(sto)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing(method, *args, &_block)
|
52
|
+
if respond_to_missing?
|
53
|
+
run(@xccov, method, args)
|
54
|
+
else
|
55
|
+
super
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def respond_to_missing?
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_xcrun
|
64
|
+
cmd = `which xcrun`.strip
|
65
|
+
return cmd unless cmd.empty?
|
66
|
+
raise "You should install xcrun"
|
67
|
+
end
|
23
68
|
end
|
data/lib/xccov/parse/version.rb
CHANGED
data/xccov-parse.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'xccov/parse/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "xccov-parse"
|
8
|
-
spec.version = Xccov::
|
8
|
+
spec.version = Xccov::VERSION
|
9
9
|
spec.required_ruby_version = '>= 2.2'
|
10
10
|
spec.authors = ["Kazuaki MATSUO"]
|
11
11
|
spec.email = ["fly.49.89.over@gmail.com"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xccov-parse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuaki MATSUO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|