Sha256: 390b45df5c0c8704d00ab2f57eed185ea95e5da932c8aa49fc209ded58860bca

Contents?: true

Size: 869 Bytes

Versions: 19

Compression:

Stored size: 869 Bytes

Contents

module CodeClimate
  module TestReporter
    class PostResults
      def initialize(results)
        @results = results
      end

      def post
        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(@results.to_json) }
        else
          client = Client.new
          print "Sending report to #{client.host} for branch #{Git.branch_from_git_or_ci}... "
          client.post_results(@results)
        end

        puts "done."
      end

      private

      def write_to_file?
        warn "TO_FILE is deprecated, use CODECLIMATE_TO_FILE" if ENV["TO_FILE"]
        CodeClimate::TestReporter.tddium? || ENV["CODECLIMATE_TO_FILE"] || ENV["TO_FILE"]
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
codeclimate-test-reporter-1.0.9 lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/codeclimate-test-reporter-1.0.8/lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.8 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.7 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.6 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.5 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.4 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.3 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.2 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.1 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.0 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.0.pre.rc2 lib/code_climate/test_reporter/post_results.rb
codeclimate-test-reporter-1.0.0.pre.rc1 lib/code_climate/test_reporter/post_results.rb