slather 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/slather +15 -0
- data/lib/slather.rb +7 -0
- data/lib/slather/coverage_file.rb +61 -0
- data/lib/slather/coveralls_coverage_file.rb +21 -0
- data/lib/slather/project.rb +48 -0
- data/lib/slather/version.rb +3 -0
- data/slather.gemspec +27 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjFhMzQxM2RiNzJlNDIzYWU1MmZkODg2ZDRlM2YwM2U5ZTk2NmIzNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWY0ODcxNmU1NGY4Nzc0NDRiNTkyMWFlMGY5ZDMwNGMwODUyYmJiYQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2UzZTljNGM1ZjZkYWE2YjJhYmRhZDBiNzg1ZTU3MTU5NDc0MjcwZTUyMmEy
|
10
|
+
OWEyMjFlODFiNDRiMGE5MDQxNTEyNDhjZWUyMmYxOGRjZWQ4ZWFhNmY3MzI4
|
11
|
+
MDJkMDg4MjE3ZGIyNjNjYzhiZjI5OWU3NjA4YWM3NTIxYTRiYTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjBmZmRjMjJiNjU5MmIxNDcxNjU3OGE2Y2NhYjMwMGQ2NTc0NWZhMWU3MjI5
|
14
|
+
NDU4ODNlYTJiMTAwYzdmMjYwNzM1N2E0YTk5MTQ5Y2RjYzEzNWQ0ZjA1YWQy
|
15
|
+
Mjg5ZGE4NGVlMzUzY2U4OTU2MDdkNDJlNzM0NGRlMDI2MGI2MjA=
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
|
24
|
+
*.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mark Larsen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Slather
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'slather'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install slather
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/slather/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/slather
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'clamp'
|
4
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'slather')
|
5
|
+
|
6
|
+
Clamp do
|
7
|
+
|
8
|
+
parameter "xcodeproj", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
|
9
|
+
|
10
|
+
def execute
|
11
|
+
project = Slather::Project.open(xcodeproj_path)
|
12
|
+
project.post_to_coveralls
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/slather.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Slather
|
2
|
+
class CoverageFile
|
3
|
+
|
4
|
+
attr_accessor :project, :gcno_file_pathname
|
5
|
+
|
6
|
+
def initialize(gcno_file_pathname)
|
7
|
+
@gcno_file_pathname = Pathname(gcno_file_pathname)
|
8
|
+
end
|
9
|
+
|
10
|
+
def source_file_pathname
|
11
|
+
@source_file_pathname ||= begin
|
12
|
+
base_filename = gcno_file_pathname.basename.sub_ext("")
|
13
|
+
# TODO: Handle Swift
|
14
|
+
path = Dir["#{project.main_group.real_path}/*/#{base_filename}.m"].first
|
15
|
+
path && Pathname(path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def source_file
|
20
|
+
File.new(source_file_pathname)
|
21
|
+
end
|
22
|
+
|
23
|
+
def source_data
|
24
|
+
source_file.read
|
25
|
+
end
|
26
|
+
|
27
|
+
def source_file_pathname_relative_to_project_root
|
28
|
+
source_file_pathname.relative_path_from(project.main_group.real_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def gcov_data
|
32
|
+
@gcov_data ||= begin
|
33
|
+
gcov_output = `gcov #{source_file_pathname} --object-directory #{gcno_file_pathname.parent}`
|
34
|
+
# Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
|
35
|
+
gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)
|
36
|
+
|
37
|
+
gcov_file = File.new("./#{source_file_pathname.basename}.gcov")
|
38
|
+
gcov_data = gcov_file.read
|
39
|
+
|
40
|
+
gcov_files_created.each { |file| FileUtils.rm(file) }
|
41
|
+
|
42
|
+
gcov_data
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def coverage_for_line(line)
|
47
|
+
line =~ /^(.+?):/
|
48
|
+
|
49
|
+
match = $1.strip
|
50
|
+
case match
|
51
|
+
when /[0-9]+/
|
52
|
+
match.to_i
|
53
|
+
when /#+/
|
54
|
+
0
|
55
|
+
when "-"
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Slather
|
2
|
+
class CoverallsCoverageFile < CoverageFile
|
3
|
+
|
4
|
+
def coverage_data
|
5
|
+
first_line_start = gcov_data =~ /^\s+(-|#+|[0-9+]):\s+1:/
|
6
|
+
|
7
|
+
gcov_data[first_line_start..-1].split("\n").map do |line|
|
8
|
+
coverage_for_line(line)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def as_json
|
13
|
+
{
|
14
|
+
:name => source_file_pathname_relative_to_project_root.to_s,
|
15
|
+
:source => source_data,
|
16
|
+
:coverage => coverage_data
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'xcodeproj'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Slather
|
6
|
+
class Project < Xcodeproj::Project
|
7
|
+
|
8
|
+
def derived_data_dir
|
9
|
+
File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/"
|
10
|
+
end
|
11
|
+
private :derived_data_dir
|
12
|
+
|
13
|
+
def coverage_files
|
14
|
+
Dir["#{derived_data_dir}/**/*.gcno"].map do |file|
|
15
|
+
coverage_file = Slather::CoverallsCoverageFile.new(file)
|
16
|
+
coverage_file.project = self
|
17
|
+
# If there's no source file for this gcno, or the gcno is old, it probably belongs to another project.
|
18
|
+
if coverage_file.source_file_pathname
|
19
|
+
stale_seconds_limit = 60
|
20
|
+
if (Time.now - File.mtime(file) < stale_seconds_limit)
|
21
|
+
next coverage_file
|
22
|
+
else
|
23
|
+
puts "Skipping #{file} -- older than #{stale_seconds_limit} seconds ago."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
next nil
|
27
|
+
end.compact
|
28
|
+
end
|
29
|
+
private :coverage_files
|
30
|
+
|
31
|
+
def coveralls_coverage_data
|
32
|
+
{
|
33
|
+
:service_job_id => ENV['TRAVIS_JOB_ID'] || 27647662,
|
34
|
+
:service_name => "travis-ci",
|
35
|
+
:source_files => coverage_files.map(&:as_json)
|
36
|
+
}.to_json
|
37
|
+
end
|
38
|
+
private :coveralls_coverage_data
|
39
|
+
|
40
|
+
def post_to_coveralls
|
41
|
+
f = File.open('coveralls_json_file', 'w+')
|
42
|
+
f.write(coveralls_coverage_data)
|
43
|
+
`curl -s --form json_file=@#{f.path} https://coveralls.io/api/v1/jobs`
|
44
|
+
FileUtils.rm(f)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/slather.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'slather/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "slather"
|
8
|
+
spec.version = Slather::VERSION
|
9
|
+
spec.authors = ["Mark Larsen"]
|
10
|
+
spec.email = ["mark@venmo.com"]
|
11
|
+
spec.summary = %q{Test coverage reports for Xcode projects}
|
12
|
+
spec.homepage = "https://github.com/marklarr/slather"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
22
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
23
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
24
|
+
|
25
|
+
spec.add_dependency "clamp", "~> 0.6"
|
26
|
+
spec.add_dependency "xcodeproj", "~> 0.17"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slather
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Larsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: clamp
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.6'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: xcodeproj
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.17'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.17'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- mark@venmo.com
|
100
|
+
executables:
|
101
|
+
- slather
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/slather
|
111
|
+
- lib/slather.rb
|
112
|
+
- lib/slather/coverage_file.rb
|
113
|
+
- lib/slather/coveralls_coverage_file.rb
|
114
|
+
- lib/slather/project.rb
|
115
|
+
- lib/slather/version.rb
|
116
|
+
- slather.gemspec
|
117
|
+
homepage: https://github.com/marklarr/slather
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ! '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.2.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Test coverage reports for Xcode projects
|
141
|
+
test_files: []
|
142
|
+
has_rdoc:
|