Class: CodeClimate::TestReporter::Formatter
- Inherits:
-
Object
- Object
- CodeClimate::TestReporter::Formatter
- Defined in:
- lib/code_climate/test_reporter/formatter.rb
Instance Method Summary collapse
- #format(result) ⇒ Object
-
#short_filename(filename) ⇒ Object
actually private …
Instance Method Details
#format(result) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/code_climate/test_reporter/formatter.rb', line 15 def format(result) return true unless CodeClimate::TestReporter.run? print "Coverage = #{result.source_files.covered_percent.round(2)}%. " payload = to_payload(result) PayloadValidator.validate(payload) if write_to_file? file_path = File.join(Dir.tmpdir, "codeclimate-test-coverage-#{SecureRandom.uuid}.json") print "Coverage results saved to #{file_path}... " File.open(file_path, "w") { |file| file.write(payload.to_json) } else client = Client.new print "Sending report to #{client.host} for branch #{Git.branch_from_git_or_ci}... " client.post_results(payload) end puts "done." true rescue => ex puts ExceptionMessage.new(ex). false end |
#short_filename(filename) ⇒ Object
actually private …
40 41 42 43 44 |
# File 'lib/code_climate/test_reporter/formatter.rb', line 40 def short_filename(filename) return filename unless ::SimpleCov.root filename = filename.gsub(/^#{::SimpleCov.root}/, ".").gsub(/^\.\//, "") apply_prefix filename end |