xccov-parse 0.0.1 → 0.1.0

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: 50ed7111f41b0b205f74f5a3c3894222b0c701c9
4
- data.tar.gz: 11153007308e7e1727c60ab9b0640008029ecfe6
3
+ metadata.gz: bb6af6827f4b01f4e0297cbd872a08441bf35b88
4
+ data.tar.gz: b7e22890f96d710a8923b0b354157bb5f243473a
5
5
  SHA512:
6
- metadata.gz: 601bd961b612c3ae86ca87d4bebc571b52c411c72edd123537a2c2caa9756ac0318938ea1881a982dc1f26cb18fa552cc63e0998b57476e8e674ea844591c086
7
- data.tar.gz: 0f63b9b308588afa125ae9923789875970893e323a0a6462fb38d699b0926dcb0e27b15be1896bccb40e58ad79333d78e63732232cde0c93ad74602081dff20d
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
- $ xcrun xccov view --only-targets --json Build/Logs/Test/*.xccovreport > result.json
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
- module Xccov
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
@@ -1,5 +1,3 @@
1
- module Xccov
2
- class Parse
3
- VERSION = "0.0.1"
4
- end
1
+ class Xccov
2
+ VERSION = "0.1.0"
5
3
  end
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::Parse::VERSION
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.1
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-04-03 00:00:00.000000000 Z
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler