Sha256: a2e1e1fc8a9cac944c840258e4b229d474ed1daed864447ac570b1334e6dbaf9

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module Slather
  module CoverageService
    module Coveralls

      def coverage_file_class
        Slather::CoverallsCoverageFile
      end

      def travis_job_id
        ENV['TRAVIS_JOB_ID']
      end

      def coveralls_coverage_data
        if ci_service == :travis_ci
          if travis_job_id
            {
              :service_job_id => travis_job_id,
              :service_name => "travis-ci",
              :source_files => coverage_files.map(&:as_json)
            }.to_json
          else
            raise StandardError, "Environment variable `TRAVIS_JOB_ID` not set. Is this running on a travis build?"
          end
        else
          raise StandardError, "No support for ci named #{ci_service}"
        end
      end
      private :coveralls_coverage_data

      def post
        f = File.open('coveralls_json_file', 'w+')
        f.write(coveralls_coverage_data)
        `curl -s --form json_file=@#{f.path} #{coveralls_api_jobs_path}`
        FileUtils.rm(f)
      end

      def coveralls_api_jobs_path
        "https://coveralls.io/api/v1/jobs"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slather-0.0.235 lib/slather/coverage_service/coveralls.rb
slather-0.0.234 lib/slather/coverage_service/coveralls.rb