slather 0.0.3 → 0.0.21

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjE0ZGEwODBjMDJiM2QyY2IyMDhhOWU2M2Y3ZTAyYjljZjdhNDk0OQ==
4
+ Yzk0YmI1Y2EwZTU1ZTJiZjk3MWVkNTlhZWIzZGQ0NWI2MGFkNTY3Mw==
5
5
  data.tar.gz: !binary |-
6
- MzFlYjM1YzliYzk4MWJlZWExYjYzZDQyMzM5YzJhNWQ0NDZlODc0OA==
6
+ OTBhNDA4Mjc1ZDg4MWFlZDQ1ZjYzNzcxMDYzNGJmMzExMGVkZjczMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Yzg0NmNkYzY1MmUwZWExZTRkMjA0ODI2NWE1NWM4YWEwZjliYWUwZGUwZDhm
10
- NDg0NGE0YmZiY2NjODI3ODQ3ZjcwNDQzMWJlY2QyZWJjOGE5Mzc3NWE3NWQ2
11
- ZDZiYmJiOWNlMGZhNmJmMDhlNmJiNzMyYjU5ODUwNTY4NTczZmU=
9
+ NmFiYTk5YmE2YmMzMjQwMDU2NTdkY2U5MDhhYTYyOWE1NmQwYjBkOWUxOTI1
10
+ NzA5ZTUxMmEzODhlNjZkYTg0YzY4YjNlZGYyYTRlZjQzN2JlNzQ5ZjI1ZmYy
11
+ OWZlZjAwYWNmZDUyMTVjODUwOTFjNTE3NWMxZTBiZTg3YTg1OGY=
12
12
  data.tar.gz: !binary |-
13
- YTIyZThhMWFjY2VhMDA4NzUwOWE4YmI0YzFhN2Q2YTFkNDc2MzQ0NDQzMTVl
14
- ZWQ5MjIyYTVkZTc5ODBhMDg4YTIwN2Y2ZDQ2OWE5YjZiZDA1MTUxYmE3OGU3
15
- NTExNjBiZTFjYWY2ZDJjMDRkYTc2MWVkNjdkNmU5OGVmOGEwZTE=
13
+ ODg1ODJmZTAyYTg2OTRiM2Y4NzljNWE5NGNjYTJiYzEwYjUzNDViMGZjOThj
14
+ ZDAzYjg2MWIyN2I1ZjFjMDJiNGYxMWY3ZDNjOTJmNDc0MTA4M2IxN2MyOGFk
15
+ ZmI1NTdiOTc4NmJkZGMwMTJjZWVkZTgxYThjODRiN2EwMzc4ZDQ=
data/.gitignore CHANGED
@@ -21,22 +21,4 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
 
24
- # Xcode
25
- #
26
- build/
27
- *.pbxuser
28
- !default.pbxuser
29
- *.mode1v3
30
- !default.mode1v3
31
- *.mode2v3
32
- !default.mode2v3
33
- *.perspectivev3
34
- !default.perspectivev3
35
- xcuserdata
36
- *.xccheckout
37
- *.moved-aside
38
- DerivedData
39
- *.hmap
40
- *.ipa
41
- *.xcuserstate
42
24
  *.DS_Store
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # Slather
2
2
 
3
- Generate test coverage reports for Xcode projects. Apply tests liberally.
4
-
5
- | [Parsimmon](https://github.com/ayanonagon/Parsimmon) | [![Parsimmon Coverage](https://coveralls.io/repos/ayanonagon/Parsimmon/badge.png?branch=master)](https://coveralls.io/r/ayanonagon/Parsimmon?branch=master) |
6
- |------------------------------------------------------------|:----------------------------------------------------:|
3
+ TODO: Write a gem description
7
4
 
8
5
  ## Installation
9
6
 
@@ -15,54 +12,18 @@ And then execute:
15
12
 
16
13
  $ bundle
17
14
 
18
- ## Usage
19
-
20
- Setup your project for test coverage:
21
-
22
- $ slather setup path/to/project.xcodeproj
23
-
24
- This will enable the `Generate Test Coverage` and `Instrument Program Flow` flags for your project.
25
-
26
-
27
- To test if you're ready to generate test coverage, run your test suite on your project, and then run:
28
-
29
- $ slather coverage -s path/to/project.xcodeproj
30
-
31
- ### Coveralls
32
-
33
- Login to https://coveralls.io/ and enable your repository. Right now, `slather` only supports coveralls via Travis CI.
15
+ Or install it yourself as:
34
16
 
35
- Make a `.slather.yml` file:
17
+ $ gem install slather
36
18
 
37
- ```yml
38
- # .slather.yml
39
-
40
- coverage_service: coveralls
41
- xcodeproj: path/to/project.xcodeproj
42
- ignore:
43
- - ExamplePodCode/*
44
- - ProjectTestsGroup/*
45
- ```
46
-
47
- And then in your `.travis.yml`, call `slather` after a successful_build
48
-
49
- ```yml
50
- # .travis.yml
51
-
52
- after_success: slather
53
- ```
54
-
55
- ### Custom Build Directory
19
+ ## Usage
56
20
 
57
- Slather will look for the test coverage files in `DerivedData` by default. If you send build output to a custom location, like [this](https://github.com/erikdoe/ocmock/blob/master/Tools/travis.sh#L12), then you should also set the `build_directory` property in `.slather.yml`
21
+ TODO: Write usage instructions here
58
22
 
59
23
  ## Contributing
60
24
 
61
- We'd love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We'll do our best to respond to your patch as soon as possible. You can also submit a [new Github issue](https://github.com/venmo/slather/issues/new) if you find bugs or have questions. :octocat:
62
-
63
- Please make sure to follow our general coding style and add test coverage for new features!
64
-
65
- ## Contributors
66
-
67
- * [@tpoulos](https://github.com/tpoulos), the perfect logo.
68
- * [@ayanonagon](https://github.com/ayanonagon) and [@kylef](https://github.com/benzguo), feedback and testing.
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/bin/slather CHANGED
@@ -1,85 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  require 'clamp'
3
- require 'yaml'
4
- require File.join(File.dirname(__FILE__), '../lib/slather')
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'slather')
5
5
 
6
6
  Clamp do
7
7
 
8
- self.default_subcommand = "coverage"
9
-
10
- subcommand "coverage", "Computes coverage for the supplised project" do
11
-
12
- parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
13
-
14
- option ["--travis", "-t"], :flag, "Indicate that the builds are running on Travis CI"
15
-
16
- option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
17
- option ["--simple-output", "-s"], :flag, "Post coverage results to coveralls"
18
-
19
- option ["--build-directory", "-b"], "BUILD_DIRECTORY", "The directory where gcno files will be written to. Defaults to derived data."
20
- option ["--ignore", "-i"], "IGNORE", "ignore files conforming to a path", :multivalued => true
21
-
22
- def execute
23
- puts "Slathering..."
24
-
25
- setup_service_name
26
- setup_ignore_list
27
- setup_build_directory
28
- setup_coverage_service
29
-
30
- post
31
-
32
- puts "Slathered"
33
- end
34
-
35
- def setup_build_directory
36
- project.build_directory = build_directory if build_directory
37
- end
38
-
39
- def setup_ignore_list
40
- project.ignore_list = ignore_list if !ignore_list.empty?
41
- end
42
-
43
- def setup_service_name
44
- if travis?
45
- project.ci_service = :travis_ci
46
- end
47
- end
48
-
49
- def post
50
- project.post
51
- end
52
-
53
- def project
54
- @project ||= begin
55
- xcodeproj_path_to_open = xcodeproj_path || Slather::Project.yml["xcodeproj"]
56
- if xcodeproj_path_to_open
57
- project = Slather::Project.open(xcodeproj_path_to_open)
58
- else
59
- raise StandardError, "Must provide an xcodeproj through .slather.yml"
60
- end
61
- end
62
- end
63
-
64
- def setup_coverage_service
65
- if coveralls?
66
- project.coverage_service = :coveralls
67
- elsif simple_output?
68
- project.coverage_service = :terminal
69
- end
70
- end
8
+ parameter "xcodeproj", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
71
9
 
10
+ def execute
11
+ puts "slathering..."
12
+ project = Slather::Project.open(xcodeproj_path)
13
+ project.post_to_coveralls
14
+ puts "done!"
72
15
  end
73
16
 
74
- subcommand "setup", "Configures an xcodeproj for test coverage generation" do
75
-
76
- parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
77
-
78
- def execute
79
- project = Slather::Project.open(xcodeproj_path)
80
- project.setup_for_coverage
81
- project.save
82
- end
83
-
84
- end
85
17
  end
data/lib/slather.rb CHANGED
@@ -2,11 +2,6 @@ require 'slather/version'
2
2
  require 'slather/project'
3
3
  require 'slather/coverage_file'
4
4
  require 'slather/coveralls_coverage_file'
5
- require 'slather/coverage_service/coveralls'
6
- require 'slather/coverage_service/simple_output'
7
5
 
8
6
  module Slather
9
-
10
- Encoding.default_external = "utf-8"
11
-
12
7
  end
@@ -3,16 +3,15 @@ module Slather
3
3
 
4
4
  attr_accessor :project, :gcno_file_pathname
5
5
 
6
- def initialize(project, gcno_file_pathname)
7
- self.project = project
8
- self.gcno_file_pathname = Pathname(gcno_file_pathname)
6
+ def initialize(gcno_file_pathname)
7
+ @gcno_file_pathname = Pathname(gcno_file_pathname)
9
8
  end
10
9
 
11
10
  def source_file_pathname
12
11
  @source_file_pathname ||= begin
13
12
  base_filename = gcno_file_pathname.basename.sub_ext("")
14
13
  # TODO: Handle Swift
15
- path = Dir["#{project.main_group.real_path}/**/#{base_filename}.m"].first
14
+ path = Dir["#{project.main_group.real_path}/*/#{base_filename}.m"].first
16
15
  path && Pathname(path)
17
16
  end
18
17
  end
@@ -25,8 +24,8 @@ module Slather
25
24
  source_file.read
26
25
  end
27
26
 
28
- def source_file_pathname_relative_to_repo_root
29
- source_file_pathname.relative_path_from(Pathname("./").realpath)
27
+ def source_file_pathname_relative_to_project_root
28
+ source_file_pathname.relative_path_from(project.main_group.real_path)
30
29
  end
31
30
 
32
31
  def gcov_data
@@ -58,11 +57,5 @@ module Slather
58
57
  end
59
58
  end
60
59
 
61
- def ignored?
62
- project.ignore_list.any? do |ignore|
63
- File.fnmatch(ignore, source_file_pathname_relative_to_repo_root)
64
- end
65
- end
66
-
67
60
  end
68
61
  end
@@ -11,7 +11,7 @@ module Slather
11
11
 
12
12
  def as_json
13
13
  {
14
- :name => source_file_pathname_relative_to_repo_root.to_s,
14
+ :name => source_file_pathname_relative_to_project_root.to_s,
15
15
  :source => source_data,
16
16
  :coverage => coverage_data
17
17
  }
@@ -1,95 +1,50 @@
1
1
  require 'fileutils'
2
2
  require 'xcodeproj'
3
3
  require 'json'
4
- require 'yaml'
5
4
 
6
5
  module Slather
7
6
  class Project < Xcodeproj::Project
8
7
 
9
- attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service
10
-
11
- def self.open(xcodeproj)
12
- proj = super
13
- proj.configure_from_yml
14
- proj
15
- end
16
-
17
8
  def derived_data_dir
18
9
  File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/"
19
10
  end
20
11
  private :derived_data_dir
21
12
 
22
- def build_directory
23
- @build_directory || derived_data_dir
24
- end
25
-
26
13
  def coverage_files
27
- coverage_files = Dir["#{build_directory}/**/*.gcno"].map do |file|
28
- coverage_file = coverage_file_class.new(self, file)
29
- # If there's no source file for this gcno, it probably belongs to another project.
30
- coverage_file.source_file_pathname && !coverage_file.ignored? ? coverage_file : nil
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
31
27
  end.compact
32
-
33
- if coverage_files.empty?
34
- raise StandardError, "No coverage files found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.pbxproj`"
35
- else
36
- coverage_files
37
- end
38
28
  end
39
29
  private :coverage_files
40
30
 
41
- def self.yml_filename
42
- '.slather.yml'
43
- end
44
-
45
- def self.yml
46
- @yml ||= File.exist?(yml_filename) ? YAML.load_file(yml_filename) : {}
47
- end
48
-
49
- def configure_from_yml
50
- configure_build_directory_from_yml
51
- configure_ignore_list_from_yml
52
- configure_ci_service_from_yml
53
- configure_coverage_service_from_yml
54
- end
55
-
56
- def configure_build_directory_from_yml
57
- self.build_directory = self.class.yml["build_directory"] if self.class.yml["build_directory"] && !@build_directory
58
- end
59
-
60
- def configure_ignore_list_from_yml
61
- self.ignore_list = [(self.class.yml["ignore"] || [])].flatten unless self.ignore_list
62
- end
63
-
64
- def configure_ci_service_from_yml
65
- self.ci_service = (self.class.yml["ci_service"] || :travis_ci) unless self.ci_service
66
- end
67
-
68
- def ci_service=(service)
69
- @ci_service = service && service.to_sym
70
- end
71
-
72
- def configure_coverage_service_from_yml
73
- self.coverage_service = (self.class.yml["coverage_service"] || :terminal) unless coverage_service
74
- end
75
-
76
- def coverage_service=(service)
77
- service = service && service.to_sym
78
- if service == :coveralls
79
- extend(Slather::CoverageService::Coveralls)
80
- elsif service == :terminal
81
- extend(Slather::CoverageService::SimpleOutput)
82
- else
83
- raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal` or `coveralls`"
84
- end
85
- @coverage_service = service
86
- end
87
-
88
- def setup_for_coverage
89
- build_configurations.each do |build_configuration|
90
- build_configuration.build_settings["GCC_INSTRUMENT_PROGRAM_FLOW_ARCS"] = "YES"
91
- build_configuration.build_settings["GCC_GENERATE_TEST_COVERAGE_FILES"] = "YES"
92
- end
31
+ def coveralls_coverage_data
32
+ {
33
+ :service_job_id => ENV['TRAVIS_JOB_ID'],
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
+ puts "file data!!!!!"
44
+ f.rewind
45
+ puts f.read
46
+ `curl -s --form json_file=@#{f.path} https://coveralls.io/api/v1/jobs`
47
+ FileUtils.rm(f)
93
48
  end
94
49
 
95
50
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.21"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,29 +110,10 @@ files:
110
110
  - bin/slather
111
111
  - lib/slather.rb
112
112
  - lib/slather/coverage_file.rb
113
- - lib/slather/coverage_service/coveralls.rb
114
- - lib/slather/coverage_service/simple_output.rb
115
113
  - lib/slather/coveralls_coverage_file.rb
116
114
  - lib/slather/project.rb
117
115
  - lib/slather/version.rb
118
116
  - slather.gemspec
119
- - spec/fixtures/fixtures.xcodeproj/project.pbxproj
120
- - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
121
- - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
122
- - spec/fixtures/fixtures/fixtures.h
123
- - spec/fixtures/fixtures/fixtures.m
124
- - spec/fixtures/fixtures/more_files/peekaview.h
125
- - spec/fixtures/fixtures/more_files/peekaview.m
126
- - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
127
- - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
128
- - spec/fixtures/fixturesTests/fixturesTests.m
129
- - spec/fixtures/fixturesTests/peekaviewTests.m
130
- - spec/slather/coverage_file_spec.rb
131
- - spec/slather/coverage_service/coveralls_spec.rb
132
- - spec/slather/coverage_service/simple_output_spec.rb
133
- - spec/slather/fixtures.gcno
134
- - spec/slather/project_spec.rb
135
- - spec/spec_helper.rb
136
117
  homepage: https://github.com/marklarr/slather
137
118
  licenses:
138
119
  - MIT
@@ -157,22 +138,5 @@ rubygems_version: 2.2.2
157
138
  signing_key:
158
139
  specification_version: 4
159
140
  summary: Test coverage reports for Xcode projects
160
- test_files:
161
- - spec/fixtures/fixtures.xcodeproj/project.pbxproj
162
- - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
163
- - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
164
- - spec/fixtures/fixtures/fixtures.h
165
- - spec/fixtures/fixtures/fixtures.m
166
- - spec/fixtures/fixtures/more_files/peekaview.h
167
- - spec/fixtures/fixtures/more_files/peekaview.m
168
- - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
169
- - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
170
- - spec/fixtures/fixturesTests/fixturesTests.m
171
- - spec/fixtures/fixturesTests/peekaviewTests.m
172
- - spec/slather/coverage_file_spec.rb
173
- - spec/slather/coverage_service/coveralls_spec.rb
174
- - spec/slather/coverage_service/simple_output_spec.rb
175
- - spec/slather/fixtures.gcno
176
- - spec/slather/project_spec.rb
177
- - spec/spec_helper.rb
141
+ test_files: []
178
142
  has_rdoc: