coveralls-0.8.22/0000755000004100000410000000000013320556542013632 5ustar www-datawww-datacoveralls-0.8.22/.travis.yml0000644000004100000410000000047613320556542015752 0ustar www-datawww-datalanguage: ruby cache: bundler sudo: false rvm: - 1.9.3 - 2.0.0 - 2.1 - 2.2 - 2.3 - 2.4 - 2.5 - ruby-head - jruby matrix: allow_failures: - rvm: ruby-head - rvm: jruby # NOTE: The tests never pass with 1.9.3 since WebMock stopped supporting 1.9. - rvm: 1.9.3 fast_finish: true coveralls-0.8.22/.rspec0000644000004100000410000000001713320556542014745 0ustar www-datawww-data--color --warn coveralls-0.8.22/README.md0000644000004100000410000000075513320556542015120 0ustar www-datawww-data# [Coveralls](http://coveralls.io) for Ruby [![Test Coverage](https://coveralls.io/repos/lemurheavy/coveralls-ruby/badge.svg?branch=master)](https://coveralls.io/r/lemurheavy/coveralls-ruby) [![Build Status](https://secure.travis-ci.org/lemurheavy/coveralls-ruby.svg?branch=master)](https://travis-ci.org/lemurheavy/coveralls-ruby) [![Gem Version](https://badge.fury.io/rb/coveralls.svg)](http://badge.fury.io/rb/coveralls) ### [Read the docs →](https://docs.coveralls.io/ruby-on-rails) coveralls-0.8.22/bin/0000755000004100000410000000000013320556542014402 5ustar www-datawww-datacoveralls-0.8.22/bin/coveralls0000755000004100000410000000035313320556542016323 0ustar www-datawww-data#!/usr/bin/env ruby lib = File.expand_path(File.dirname(__FILE__) + '/../lib') $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib) require 'coveralls' require 'coveralls/command' Coveralls::CommandLine.startcoveralls-0.8.22/spec/0000755000004100000410000000000013320556542014564 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/0000755000004100000410000000000013320556542016556 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/0000755000004100000410000000000013320556542020427 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/sample.rb0000755000004100000410000000016413320556542022241 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end # :nocov: def bar @foo end # :nocov: end coveralls-0.8.22/spec/coveralls/fixtures/app/0000755000004100000410000000000013320556542021207 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/app/controllers/0000755000004100000410000000000013320556542023555 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/app/controllers/sample.rb0000755000004100000410000000016413320556542025367 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end # :nocov: def bar @foo end # :nocov: end coveralls-0.8.22/spec/coveralls/fixtures/app/models/0000755000004100000410000000000013320556542022472 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/app/models/house.rb0000755000004100000410000000013513320556542024144 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.8.22/spec/coveralls/fixtures/app/models/airplane.rb0000755000004100000410000000013513320556542024614 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.8.22/spec/coveralls/fixtures/app/models/dog.rb0000755000004100000410000000013513320556542023572 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.8.22/spec/coveralls/fixtures/app/models/user.rb0000755000004100000410000000013513320556542023777 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.8.22/spec/coveralls/fixtures/app/models/robot.rb0000755000004100000410000000013513320556542024146 0ustar www-datawww-data# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.8.22/spec/coveralls/fixtures/app/vendor/0000755000004100000410000000000013320556542022504 5ustar www-datawww-datacoveralls-0.8.22/spec/coveralls/fixtures/app/vendor/vendored_gem.rb0000644000004100000410000000004113320556542025462 0ustar www-datawww-data# this file should not be coveredcoveralls-0.8.22/spec/coveralls/output_spec.rb0000644000004100000410000000501013320556542021451 0ustar www-datawww-datarequire 'spec_helper' describe Coveralls::Output do it "defaults the IO to $stdout" do old_stdout = $stdout out = StringIO.new $stdout = out Coveralls::Output.puts "this is a test" expect(out.string).to eq "this is a test\n" $stdout = old_stdout end it "accepts an IO injection" do out = StringIO.new Coveralls::Output.output = out Coveralls::Output.puts "this is a test" expect(out.string).to eq "this is a test\n" end describe ".puts" do it "accepts an IO injection" do out = StringIO.new Coveralls::Output.puts "this is a test", :output => out expect(out.string).to eq "this is a test\n" end end describe ".print" do it "accepts an IO injection" do out = StringIO.new Coveralls::Output.print "this is a test", :output => out expect(out.string).to eq "this is a test" end end describe 'when silenced' do before do @original_stdout = $stdout @output = StringIO.new Coveralls::Output.silent = true $stdout = @output end it "should not puts" do Coveralls::Output.puts "foo" @output.rewind @output.read.should == "" end it "should not print" do Coveralls::Output.print "foo" @output.rewind @output.read.should == "" end after do $stdout = @original_stdout end end describe '.format' do it "accepts a color argument" do require 'term/ansicolor' string = 'Hello' ansi_color_string = Term::ANSIColor.red(string) Coveralls::Output.format(string, :color => 'red').should eq(ansi_color_string) end it "also accepts no color arguments" do unformatted_string = "Hi Doggie!" Coveralls::Output.format(unformatted_string).should eq(unformatted_string) end it "rejects formats unrecognized by Term::ANSIColor" do string = 'Hi dog!' Coveralls::Output.format(string, :color => "not_a_real_color").should eq(string) end it "accepts more than 1 color argument" do string = 'Hi dog!' multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) } Coveralls::Output.format(string, :color => 'red underline').should eq(multi_formatted_string) end context "no color" do before { Coveralls::Output.no_color = true } it "does not add color to string" do unformatted_string = "Hi Doggie!" Coveralls::Output.format(unformatted_string, :color => 'red'). should eq(unformatted_string) end end end end coveralls-0.8.22/spec/coveralls/coveralls_spec.rb0000644000004100000410000000437413320556542022117 0ustar www-datawww-datarequire 'spec_helper' describe Coveralls do before do SimpleCov.stub(:start) stub_api_post Coveralls.testing = true end describe "#will_run?" do it "checks CI environemnt variables" do Coveralls.will_run?.should be_truthy end context "with CI disabled" do before do @ci = ENV['CI'] ENV['CI'] = nil @coveralls_run_locally = ENV['COVERALLS_RUN_LOCALLY'] ENV['COVERALLS_RUN_LOCALLY'] = nil Coveralls.testing = false end after do ENV['CI'] = @ci ENV['COVERALLS_RUN_LOCALLY'] = @coveralls_run_locally end it "indicates no run" do Coveralls.will_run?.should be_falsy end end end describe "#should_run?" do it "outputs to stdout when running locally" do Coveralls.testing = false Coveralls.run_locally = true silence do Coveralls.should_run? end end end describe "#wear!" do it "receives block" do ::SimpleCov.should_receive(:start) silence do subject.wear! do add_filter 's' end end end it "uses string" do ::SimpleCov.should_receive(:start).with 'test_frameworks' silence do subject.wear! 'test_frameworks' end end it "uses default" do ::SimpleCov.should_receive(:start).with no_args silence do subject.wear! end ::SimpleCov.filters.map(&:filter_argument).should include 'vendor' end end describe "#wear_merged!" do it "sets formatter to NilFormatter" do ::SimpleCov.should_receive(:start).with 'rails' silence do subject.wear_merged! 'rails' do add_filter "/spec/" end end ::SimpleCov.formatter.should be Coveralls::NilFormatter end end describe "#push!" do it "sends existing test results", :if => RUBY_VERSION >= "1.9" do result = false silence do result = subject.push! end result.should be_truthy end end describe "#setup!" do it "sets SimpleCov adapter" do SimpleCovTmp = SimpleCov Object.send :remove_const, :SimpleCov silence { subject.setup! } SimpleCov = SimpleCovTmp end end after(:all) do setup_formatter end end coveralls-0.8.22/spec/coveralls/configuration_spec.rb0000644000004100000410000003502713320556542022773 0ustar www-datawww-datarequire 'spec_helper' describe Coveralls::Configuration do before do ENV.stub(:[]).and_return(nil) end describe '.configuration' do it "returns a hash with the default keys" do config = Coveralls::Configuration.configuration config.should be_a(Hash) config.keys.should include(:environment) config.keys.should include(:git) end context 'yaml_config' do let(:repo_token) { SecureRandom.hex(4) } let(:repo_secret_token) { SecureRandom.hex(4) } let(:yaml_config) { { 'repo_token' => repo_token, 'repo_secret_token' => repo_secret_token } } before do Coveralls::Configuration.stub(:yaml_config).and_return(yaml_config) end it 'sets the Yaml config and associated variables if present' do config = Coveralls::Configuration.configuration config[:configuration].should eq(yaml_config) config[:repo_token].should eq(repo_token) end it 'uses the repo_secret_token if the repo_token is not set' do yaml_config.delete('repo_token') config = Coveralls::Configuration.configuration config[:configuration].should eq(yaml_config) config[:repo_token].should eq(repo_secret_token) end end context 'repo_token in environment' do let(:repo_token) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('COVERALLS_REPO_TOKEN').and_return(repo_token) end it 'pulls the repo token from the environment if set' do config = Coveralls::Configuration.configuration config[:repo_token].should eq(repo_token) end end context 'flag_name in environment' do let(:flag_name) { 'Test Flag' } before do ENV.stub(:[]).with('COVERALLS_FLAG_NAME').and_return(flag_name) end it 'pulls the flag name from the environment if set' do config = Coveralls::Configuration.configuration config[:flag_name].should eq(flag_name) end end context 'Services' do context 'with env based service name' do let(:service_name) { 'travis-enterprise' } before do ENV.stub(:[]).with('TRAVIS').and_return('1') ENV.stub(:[]).with('COVERALLS_SERVICE_NAME').and_return(service_name) end it 'pulls the service name from the environment if set' do config = Coveralls::Configuration.configuration config[:service_name].should eq(service_name) end end context 'on Travis' do before do ENV.stub(:[]).with('TRAVIS').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_receive(:set_service_params_for_travis).with(anything, anything) Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci) Coveralls::Configuration.configuration end end context 'on CircleCI' do before do ENV.stub(:[]).with('CIRCLECI').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_not_receive(:set_service_params_for_travis) Coveralls::Configuration.should_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci) Coveralls::Configuration.configuration end end context 'on Semaphore' do before do ENV.stub(:[]).with('SEMAPHORE').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_not_receive(:set_service_params_for_travis) Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci) Coveralls::Configuration.configuration end end context 'when using Jenkins' do before do ENV.stub(:[]).with('JENKINS_URL').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_not_receive(:set_service_params_for_travis) Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci) Coveralls::Configuration.configuration end end context 'when running Coveralls locally' do before do ENV.stub(:[]).with('COVERALLS_RUN_LOCALLY').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_not_receive(:set_service_params_for_travis) Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci) Coveralls::Configuration.configuration end end context 'for generic CI' do before do ENV.stub(:[]).with('CI_NAME').and_return('1') end it 'should set service parameters for this service and no other' do Coveralls::Configuration.should_not_receive(:set_service_params_for_travis) Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci) Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore) Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins) Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local) Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci).with(anything) Coveralls::Configuration.configuration end end end end describe '.set_service_params_for_travis' do let(:travis_job_id) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('TRAVIS_JOB_ID').and_return(travis_job_id) end it 'should set the service_job_id' do config = {} Coveralls::Configuration.set_service_params_for_travis(config, nil) config[:service_job_id].should eq(travis_job_id) end it 'should set the service_name to travis-ci by default' do config = {} Coveralls::Configuration.set_service_params_for_travis(config, nil) config[:service_name].should eq('travis-ci') end it 'should set the service_name to a value if one is passed in' do config = {} random_name = SecureRandom.hex(4) Coveralls::Configuration.set_service_params_for_travis(config, random_name) config[:service_name].should eq(random_name) end end describe '.set_service_params_for_circleci' do let(:circle_build_num) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('CIRCLE_BUILD_NUM').and_return(circle_build_num) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_circleci(config) config[:service_name].should eq('circleci') config[:service_number].should eq(circle_build_num) end end describe '.set_service_params_for_gitlab' do let(:commit_sha) { SecureRandom.hex(32) } let(:service_job_number) { "spec:one" } let(:service_job_id) { 1234 } let(:service_branch) { "feature" } before do ENV.stub(:[]).with('CI_BUILD_NAME').and_return(service_job_number) ENV.stub(:[]).with('CI_BUILD_ID').and_return(service_job_id) ENV.stub(:[]).with('CI_BUILD_REF_NAME').and_return(service_branch) ENV.stub(:[]).with('CI_BUILD_REF').and_return(commit_sha) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_gitlab(config) config[:service_name].should eq('gitlab-ci') config[:service_job_number].should eq(service_job_number) config[:service_job_id].should eq(service_job_id) config[:service_branch].should eq(service_branch) config[:commit_sha].should eq(commit_sha) end end describe '.set_service_params_for_semaphore' do let(:semaphore_build_num) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('SEMAPHORE_BUILD_NUMBER').and_return(semaphore_build_num) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_semaphore(config) config[:service_name].should eq('semaphore') config[:service_number].should eq(semaphore_build_num) end end describe '.set_service_params_for_jenkins' do let(:service_pull_request) { '1234' } let(:build_num) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('CI_PULL_REQUEST').and_return(service_pull_request) ENV.stub(:[]).with('BUILD_NUMBER').and_return(build_num) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_jenkins(config) Coveralls::Configuration.set_standard_service_params_for_generic_ci(config) config[:service_name].should eq('jenkins') config[:service_number].should eq(build_num) config[:service_pull_request].should eq(service_pull_request) end end describe '.set_service_params_for_coveralls_local' do it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_coveralls_local(config) config[:service_name].should eq('coveralls-ruby') config[:service_job_id].should be_nil config[:service_event_type].should eq('manual') end end describe '.set_service_params_for_generic_ci' do let(:service_name) { SecureRandom.hex(4) } let(:service_number) { SecureRandom.hex(4) } let(:service_build_url) { SecureRandom.hex(4) } let(:service_branch) { SecureRandom.hex(4) } let(:service_pull_request) { '1234' } before do ENV.stub(:[]).with('CI_NAME').and_return(service_name) ENV.stub(:[]).with('CI_BUILD_NUMBER').and_return(service_number) ENV.stub(:[]).with('CI_BUILD_URL').and_return(service_build_url) ENV.stub(:[]).with('CI_BRANCH').and_return(service_branch) ENV.stub(:[]).with('CI_PULL_REQUEST').and_return(service_pull_request) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_standard_service_params_for_generic_ci(config) config[:service_name].should eq(service_name) config[:service_number].should eq(service_number) config[:service_build_url].should eq(service_build_url) config[:service_branch].should eq(service_branch) config[:service_pull_request].should eq(service_pull_request) end end describe '.set_service_params_for_appveyor' do let(:service_number) { SecureRandom.hex(4) } let(:service_branch) { SecureRandom.hex(4) } let(:commit_sha) { SecureRandom.hex(4) } let(:repo_name) { SecureRandom.hex(4) } before do ENV.stub(:[]).with('APPVEYOR_BUILD_VERSION').and_return(service_number) ENV.stub(:[]).with('APPVEYOR_REPO_BRANCH').and_return(service_branch) ENV.stub(:[]).with('APPVEYOR_REPO_COMMIT').and_return(commit_sha) ENV.stub(:[]).with('APPVEYOR_REPO_NAME').and_return(repo_name) end it 'should set the expected parameters' do config = {} Coveralls::Configuration.set_service_params_for_appveyor(config) config[:service_name].should eq('appveyor') config[:service_number].should eq(service_number) config[:service_branch].should eq(service_branch) config[:commit_sha].should eq(commit_sha) config[:service_build_url].should eq('https://ci.appveyor.com/project/%s/build/%s' % [repo_name, service_number]) end end describe '.git' do let(:git_id) { SecureRandom.hex(2) } let(:author_name) { SecureRandom.hex(4) } let(:author_email) { SecureRandom.hex(4) } let(:committer_name) { SecureRandom.hex(4) } let(:committer_email) { SecureRandom.hex(4) } let(:message) { SecureRandom.hex(4) } let(:branch) { SecureRandom.hex(4) } before do allow(ENV).to receive(:fetch).with('GIT_ID', anything).and_return(git_id) allow(ENV).to receive(:fetch).with('GIT_AUTHOR_NAME', anything).and_return(author_name) allow(ENV).to receive(:fetch).with('GIT_AUTHOR_EMAIL', anything).and_return(author_email) allow(ENV).to receive(:fetch).with('GIT_COMMITTER_NAME', anything).and_return(committer_name) allow(ENV).to receive(:fetch).with('GIT_COMMITTER_EMAIL', anything).and_return(committer_email) allow(ENV).to receive(:fetch).with('GIT_MESSAGE', anything).and_return(message) allow(ENV).to receive(:fetch).with('GIT_BRANCH', anything).and_return(branch) end it 'uses ENV vars' do config = Coveralls::Configuration.git config[:head][:id].should eq(git_id) config[:head][:author_name].should eq(author_name) config[:head][:author_email].should eq(author_email) config[:head][:committer_name].should eq(committer_name) config[:head][:committer_email].should eq(committer_email) config[:head][:message].should eq(message) config[:branch].should eq(branch) end end end coveralls-0.8.22/spec/coveralls/simplecov_spec.rb0000644000004100000410000000464313320556542022125 0ustar www-datawww-datarequire 'spec_helper' describe Coveralls::SimpleCov::Formatter do before do stub_api_post end def source_fixture(filename) File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) ) end let(:result) { SimpleCov::Result.new({ source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil], source_fixture( 'app/models/user.rb' ) => [nil, 1, 1, 1, 1, 0, 1, 0, nil, nil], source_fixture( 'app/models/robot.rb' ) => [1, 1, 1, 1, nil, nil, 1, 0, nil, nil], source_fixture( 'app/models/house.rb' ) => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], source_fixture( 'app/models/airplane.rb' ) => [0, 0, 0, 0, 0], source_fixture( 'app/models/dog.rb' ) => [1, 1, 1, 1, 1], source_fixture( 'app/controllers/sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil] }) } describe "#format" do context "should run" do before do Coveralls.testing = true Coveralls.noisy = false end it "posts json", :if => RUBY_VERSION >= "1.9" do result.files.should_not be_empty silence do Coveralls::SimpleCov::Formatter.new.format(result).should be_truthy end end end context "should not run, noisy" do it "only displays result" do silence do Coveralls::SimpleCov::Formatter.new.display_result(result).should be_truthy end end end context "no files" do let(:result) { SimpleCov::Result.new({}) } it "shows note that no files have been covered" do Coveralls.noisy = true Coveralls.testing = false silence do expect do Coveralls::SimpleCov::Formatter.new.format(result) end.not_to raise_error end end end context "with api error" do it "rescues" do e = SocketError.new silence do Coveralls::SimpleCov::Formatter.new.display_error(e).should be_falsy end end end context "#get_source_files" do let(:source_files) { Coveralls::SimpleCov::Formatter.new.get_source_files(result) } it "nils the skipped lines" do source_file = source_files.first source_file[:coverage].should_not eq result.files.first.coverage source_file[:coverage].should eq [nil, 1, 1, 1, nil, 0, nil, nil, nil, nil, nil] end end end end coveralls-0.8.22/spec/spec_helper.rb0000644000004100000410000000333213320556542017403 0ustar www-datawww-datarequire 'simplecov' require 'webmock' require 'vcr' require 'pry' if RUBY_VERSION > "1.8.7" class InceptionFormatter def format(result) Coveralls::SimpleCov::Formatter.new.format(result) end end def setup_formatter SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN'] InceptionFormatter else SimpleCov::Formatter::HTMLFormatter end # SimpleCov.start 'test_frameworks' SimpleCov.start do add_filter do |source_file| source_file.filename =~ /spec/ && !(source_file.filename =~ /fixture/) end end end setup_formatter require 'coveralls' VCR.configure do |c| c.cassette_library_dir = 'fixtures/vcr_cassettes' c.hook_into :webmock end RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.include WebMock::API config.expect_with :rspec do |c| c.syntax = [:should, :expect] end config.mock_with :rspec do |c| c.syntax = [:should, :expect] end config.after(:suite) do WebMock.disable! end end def stub_api_post body = "{\"message\":\"\",\"url\":\"\"}" stub_request(:post, Coveralls::API::API_BASE+"/jobs").with( :headers => { 'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Content-Length'=>/.+/, 'Content-Type'=>/.+/, 'User-Agent'=>'Ruby' } ).to_return(:status => 200, :body => body, :headers => {}) end def silence return yield if ENV['silence'] == 'false' silence_stream(STDOUT) do yield end end module Kernel def silence_stream(stream) old_stream = stream.dup stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') stream.sync = true yield ensure stream.reopen(old_stream) end end coveralls-0.8.22/CHANGELOG.md0000644000004100000410000000104013320556542015436 0ustar www-datawww-data# Changelog ### Please see Github Releases section for current releases. ## 0.7.0 (September 18, 2013) [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0) Added: * output silencing (Thanks @elizabrock) * ruby warning fixes (Thanks @steveklabnik and @Nucc) ## 0.6.4 (April 2, 2013) [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4) Enhancements: * Support [Jenkins CI](http://jenkins-ci.org/) * Support VCR versions <= 2 * Add SimpleCov filter 'vendor' by default. coveralls-0.8.22/coveralls-ruby.gemspec0000644000004100000410000000212213320556542020145 0ustar www-datawww-datalib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'coveralls/version' Gem::Specification.new do |gem| gem.authors = ["Nick Merwin", "Wil Gieseler"] gem.email = ["nick@lemurheavy.com", "supapuerco@gmail.com"] gem.description = "A Ruby implementation of the Coveralls API." gem.summary = "A Ruby implementation of the Coveralls API." gem.homepage = "https://coveralls.io" gem.license = "MIT" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "coveralls" gem.require_paths = ["lib"] gem.version = Coveralls::VERSION gem.required_ruby_version = '>= 1.8.7' gem.add_dependency 'json', '>= 1.8', '< 3' gem.add_dependency 'simplecov', '~> 0.16.1' gem.add_dependency 'tins', '~> 1.6' gem.add_dependency 'term-ansicolor', '~> 1.3' gem.add_dependency 'thor', '~> 0.19.4' gem.add_development_dependency 'bundler', '~> 1.7' end coveralls-0.8.22/.gitignore0000644000004100000410000000025613320556542015625 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp .DS_Store /vendor/ coveralls-0.8.22/LICENSE0000644000004100000410000000205413320556542014640 0ustar www-datawww-dataCopyright (c) 2012 Wil Gieseler MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.coveralls-0.8.22/Rakefile0000644000004100000410000000033613320556542015301 0ustar www-datawww-data#!/usr/bin/env rake require "bundler/gem_tasks" # Travis! require 'rubygems' require 'rake' require 'rspec/core/rake_task' desc "Run RSpec" RSpec::Core::RakeTask.new do |t| t.verbose = false end task :default => :speccoveralls-0.8.22/lib/0000755000004100000410000000000013320556542014400 5ustar www-datawww-datacoveralls-0.8.22/lib/coveralls/0000755000004100000410000000000013320556542016372 5ustar www-datawww-datacoveralls-0.8.22/lib/coveralls/output.rb0000644000004100000410000000575713320556542020275 0ustar www-datawww-datamodule Coveralls # # Public: Methods for formatting strings with Term::ANSIColor. # Does not utilize monkey-patching and should play nicely when # included with other libraries. # # All methods are module methods and should be called on # the Coveralls::Output module. # # Examples # # Coveralls::Output.format("Hello World", :color => "cyan") # # => "\e[36mHello World\e[0m" # # Coveralls::Output.print("Hello World") # # Hello World => nil # # Coveralls::Output.puts("Hello World", :color => "underline") # # Hello World # # => nil # # To silence output completely: # # Coveralls::Output.silent = true # # or set this environment variable: # # COVERALLS_SILENT # # To disable color completely: # # Coveralls::Output.no_color = true module Output attr_accessor :silent, :no_color attr_writer :output extend self def output (defined?(@output) && @output) || $stdout end def no_color? (defined?(@no_color)) && @no_color end # Public: Formats the given string with the specified color # through Term::ANSIColor # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # Examples # # Coveralls::Output.format("Hello World!", :color => "cyan") # # => "\e[36mHello World\e[0m" # # Returns the formatted string. def format(string, options = {}) unless no_color? require 'term/ansicolor' if options[:color] options[:color].split(/\s/).reverse_each do |color| if Term::ANSIColor.respond_to?(color.to_sym) string = Term::ANSIColor.send(color.to_sym, string) end end end end string end # Public: Passes .format to Kernel#puts # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # # Example # # Coveralls::Output.puts("Hello World", :color => "cyan") # # Returns nil. def puts(string, options = {}) return if silent? (options[:output] || output).puts self.format(string, options) end # Public: Passes .format to Kernel#print # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # Example # # Coveralls::Output.print("Hello World!", :color => "underline") # # Returns nil. def print(string, options = {}) return if silent? (options[:output] || output).print self.format(string, options) end def silent? ENV["COVERALLS_SILENT"] || (defined?(@silent) && @silent) end end end coveralls-0.8.22/lib/coveralls/version.rb0000644000004100000410000000005113320556542020400 0ustar www-datawww-datamodule Coveralls VERSION = "0.8.22" end coveralls-0.8.22/lib/coveralls/configuration.rb0000644000004100000410000001671113320556542021574 0ustar www-datawww-datarequire 'yaml' require 'securerandom' module Coveralls module Configuration def self.configuration config = { :environment => self.relevant_env, :git => git } yml = self.yaml_config if yml config[:configuration] = yml config[:repo_token] = yml['repo_token'] || yml['repo_secret_token'] end if ENV['COVERALLS_REPO_TOKEN'] config[:repo_token] = ENV['COVERALLS_REPO_TOKEN'] end if ENV['COVERALLS_PARALLEL'] && ENV['COVERALLS_PARALLEL'] != "false" config[:parallel] = true end if ENV['COVERALLS_FLAG_NAME'] config[:flag_name] = ENV['COVERALLS_FLAG_NAME'] end if ENV['TRAVIS'] set_service_params_for_travis(config, yml ? yml['service_name'] : nil) elsif ENV['CIRCLECI'] set_service_params_for_circleci(config) elsif ENV['SEMAPHORE'] set_service_params_for_semaphore(config) elsif ENV['JENKINS_URL'] || ENV['JENKINS_HOME'] set_service_params_for_jenkins(config) elsif ENV['APPVEYOR'] set_service_params_for_appveyor(config) elsif ENV['TDDIUM'] set_service_params_for_tddium(config) elsif ENV['GITLAB_CI'] set_service_params_for_gitlab(config) elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing set_service_params_for_coveralls_local(config) end # standardized env vars set_standard_service_params_for_generic_ci(config) if service_name = ENV['COVERALLS_SERVICE_NAME'] config[:service_name] = service_name end config end def self.set_service_params_for_travis(config, service_name) config[:service_job_id] = ENV['TRAVIS_JOB_ID'] config[:service_pull_request] = ENV['TRAVIS_PULL_REQUEST'] unless ENV['TRAVIS_PULL_REQUEST'] == 'false' config[:service_name] = service_name || 'travis-ci' config[:service_branch] = ENV['TRAVIS_BRANCH'] end def self.set_service_params_for_circleci(config) config[:service_name] = 'circleci' config[:service_number] = ENV['CIRCLE_BUILD_NUM'] config[:service_pull_request] = (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1] config[:parallel] = ENV['CIRCLE_NODE_TOTAL'].to_i > 1 config[:service_job_number] = ENV['CIRCLE_NODE_INDEX'] end def self.set_service_params_for_semaphore(config) config[:service_name] = 'semaphore' config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER'] config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER'] end def self.set_service_params_for_jenkins(config) config[:service_name] = 'jenkins' config[:service_number] = ENV['BUILD_NUMBER'] config[:service_branch] = ENV['BRANCH_NAME'] config[:service_pull_request] = ENV['ghprbPullId'] end def self.set_service_params_for_appveyor(config) config[:service_name] = 'appveyor' config[:service_number] = ENV['APPVEYOR_BUILD_VERSION'] config[:service_branch] = ENV['APPVEYOR_REPO_BRANCH'] config[:commit_sha] = ENV['APPVEYOR_REPO_COMMIT'] repo_name = ENV['APPVEYOR_REPO_NAME'] config[:service_build_url] = 'https://ci.appveyor.com/project/%s/build/%s' % [repo_name, config[:service_number]] end def self.set_service_params_for_tddium(config) config[:service_name] = 'tddium' config[:service_number] = ENV['TDDIUM_SESSION_ID'] config[:service_job_number] = ENV['TDDIUM_TID'] config[:service_pull_request] = ENV['TDDIUM_PR_ID'] config[:service_branch] = ENV['TDDIUM_CURRENT_BRANCH'] config[:service_build_url] = "https://ci.solanolabs.com/reports/#{ENV['TDDIUM_SESSION_ID']}" end def self.set_service_params_for_gitlab(config) config[:service_name] = 'gitlab-ci' config[:service_job_number] = ENV['CI_BUILD_NAME'] config[:service_job_id] = ENV['CI_BUILD_ID'] config[:service_branch] = ENV['CI_BUILD_REF_NAME'] config[:commit_sha] = ENV['CI_BUILD_REF'] end def self.set_service_params_for_coveralls_local(config) config[:service_job_id] = nil config[:service_name] = 'coveralls-ruby' config[:service_event_type] = 'manual' end def self.set_standard_service_params_for_generic_ci(config) config[:service_name] ||= ENV['CI_NAME'] config[:service_number] ||= ENV['CI_BUILD_NUMBER'] config[:service_job_id] ||= ENV['CI_JOB_ID'] config[:service_build_url] ||= ENV['CI_BUILD_URL'] config[:service_branch] ||= ENV['CI_BRANCH'] config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1] end def self.yaml_config if self.configuration_path && File.exist?(self.configuration_path) YAML::load_file(self.configuration_path) end end def self.configuration_path File.expand_path(File.join(self.root, ".coveralls.yml")) if self.root end def self.root pwd end def self.pwd Dir.pwd end def self.simplecov_root if defined?(::SimpleCov) ::SimpleCov.root end end def self.rails_root Rails.root.to_s rescue nil end def self.git hash = {} Dir.chdir(root) do hash[:head] = { :id => ENV.fetch("GIT_ID", `git log -1 --pretty=format:'%H'`), :author_name => ENV.fetch("GIT_AUTHOR_NAME", `git log -1 --pretty=format:'%aN'`), :author_email => ENV.fetch("GIT_AUTHOR_EMAIL", `git log -1 --pretty=format:'%ae'`), :committer_name => ENV.fetch("GIT_COMMITTER_NAME", `git log -1 --pretty=format:'%cN'`), :committer_email => ENV.fetch("GIT_COMMITTER_EMAIL", `git log -1 --pretty=format:'%ce'`), :message => ENV.fetch("GIT_MESSAGE", `git log -1 --pretty=format:'%s'`) } # Branch hash[:branch] = ENV.fetch("GIT_BRANCH", `git rev-parse --abbrev-ref HEAD`) # Remotes remotes = nil begin remotes = `git remote -v`.split(/\n/).map do |remote| splits = remote.split(" ").compact {:name => splits[0], :url => splits[1]} end.uniq rescue end hash[:remotes] = remotes end hash rescue Exception => e Coveralls::Output.puts "Coveralls git error:", :color => "red" Coveralls::Output.puts e.to_s, :color => "red" nil end def self.relevant_env hash = { :pwd => self.pwd, :rails_root => self.rails_root, :simplecov_root => simplecov_root, :gem_version => VERSION } hash.merge! begin if ENV['TRAVIS'] { :travis_job_id => ENV['TRAVIS_JOB_ID'], :travis_pull_request => ENV['TRAVIS_PULL_REQUEST'], :branch => ENV['TRAVIS_BRANCH'] } elsif ENV['CIRCLECI'] { :circleci_build_num => ENV['CIRCLE_BUILD_NUM'], :branch => ENV['CIRCLE_BRANCH'], :commit_sha => ENV['CIRCLE_SHA1'] } elsif ENV['JENKINS_URL'] { :jenkins_build_num => ENV['BUILD_NUMBER'], :jenkins_build_url => ENV['BUILD_URL'], :branch => ENV['GIT_BRANCH'], :commit_sha => ENV['GIT_COMMIT'] } elsif ENV['SEMAPHORE'] { :branch => ENV['BRANCH_NAME'], :commit_sha => ENV['REVISION'] } else {} end end hash end end end coveralls-0.8.22/lib/coveralls/api.rb0000644000004100000410000000727313320556542017501 0ustar www-datawww-datarequire 'json' require 'net/https' require 'tempfile' module Coveralls class API if ENV['COVERALLS_ENDPOINT'] API_HOST = ENV['COVERALLS_ENDPOINT'] API_DOMAIN = ENV['COVERALLS_ENDPOINT'] else API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io" API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https" API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}" end API_BASE = "#{API_DOMAIN}/api/v1" def self.post_json(endpoint, hash) disable_net_blockers! uri = endpoint_to_uri(endpoint) Coveralls::Output.puts("#{ JSON.pretty_generate(hash) }", :color => "green") if ENV['COVERALLS_DEBUG'] Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan") client = build_client(uri) request = build_request(uri.path, hash) response = client.request(request) response_hash = JSON.load(response.body.to_str) if response_hash['message'] Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan") end if response_hash['url'] Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan") end case response when Net::HTTPServiceUnavailable Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red") when Net::HTTPInternalServerError Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red") end end private def self.disable_net_blockers! begin require 'webmock' allow = WebMock::Config.instance.allow || [] WebMock::Config.instance.allow = [*allow].push API_HOST rescue LoadError end begin require 'vcr' VCR.send(VCR.version.major < 2 ? :config : :configure) do |c| c.ignore_hosts API_HOST end rescue LoadError end end def self.endpoint_to_uri(endpoint) URI.parse("#{API_BASE}/#{endpoint}") end def self.build_client(uri) client = Net::HTTP.new(uri.host, uri.port) client.use_ssl = true if uri.port == 443 client.verify_mode = OpenSSL::SSL::VERIFY_NONE unless client.respond_to?(:ssl_version=) Net::HTTP.ssl_context_accessor("ssl_version") end client.ssl_version = 'TLSv1' client end def self.build_request(path, hash) request = Net::HTTP::Post.new(path) boundary = rand(1_000_000).to_s request.body = build_request_body(hash, boundary) request.content_type = "multipart/form-data, boundary=#{boundary}" request end def self.build_request_body(hash, boundary) hash = apified_hash(hash) file = hash_to_file(hash) "--#{boundary}\r\n" \ "Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \ "Content-Type: text/plain\r\n\r\n" + File.read(file.path) + "\r\n--#{boundary}--\r\n" end def self.hash_to_file(hash) file = nil Tempfile.open(['coveralls-upload', 'json']) do |f| f.write(JSON.dump hash) file = f end File.new(file.path, 'rb') end def self.apified_hash hash config = Coveralls::Configuration.configuration if ENV['COVERALLS_DEBUG'] || Coveralls.testing Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow" output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/,'"repo_token": "[secure]"') Coveralls::Output.puts output, :color => "yellow" end hash.merge(config) end end end coveralls-0.8.22/lib/coveralls/command.rb0000644000004100000410000000366713320556542020351 0ustar www-datawww-datarequire "thor" module Coveralls class CommandLine < Thor desc "push", "Runs your test suite and pushes the coverage results to Coveralls." def push return unless ensure_can_run_locally! ENV["COVERALLS_RUN_LOCALLY"] = "true" cmds = "bundle exec rake" if File.exist?('.travis.yml') cmds = YAML.load_file('.travis.yml')["script"] || cmds rescue cmds end cmds.each { |cmd| system cmd } ENV["COVERALLS_RUN_LOCALLY"] = nil end desc "report", "Runs your test suite locally and displays coverage statistics." def report ENV["COVERALLS_NOISY"] = "true" exec "bundle exec rake" ENV["COVERALLS_NOISY"] = nil end desc "open", "View this repository on Coveralls." def open open_token_based_url "https://coveralls.io/repos/%@" end desc "service", "View this repository on your CI service's website." def service open_token_based_url "https://coveralls.io/repos/%@/service" end desc "last", "View the last build for this repository on Coveralls." def last open_token_based_url "https://coveralls.io/repos/%@/last_build" end desc "version", "See version" def version Coveralls::Output.puts Coveralls::VERSION end private def open_token_based_url url config = Coveralls::Configuration.configuration if config[:repo_token] url = url.gsub("%@", config[:repo_token]) `open #{url}` else Coveralls::Output.puts "No repo_token configured." end end def ensure_can_run_locally! config = Coveralls::Configuration.configuration if config[:repo_token].nil? Coveralls::Output.puts "Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml", :color => "red" Coveralls::Output.puts "Please try again when you get your act together.", :color => "red" return false end true end end end coveralls-0.8.22/lib/coveralls/rake/0000755000004100000410000000000013320556542017314 5ustar www-datawww-datacoveralls-0.8.22/lib/coveralls/rake/task.rb0000644000004100000410000000064313320556542020606 0ustar www-datawww-datarequire 'rake' require 'rake/tasklib' module Coveralls class RakeTask < ::Rake::TaskLib include ::Rake::DSL if defined?(::Rake::DSL) def initialize(*args, &task_block) namespace :coveralls do desc "Push latest coverage results to Coveralls.io" task :push do require 'coveralls' Coveralls.push! end end end # initialize end # class end # module coveralls-0.8.22/lib/coveralls/simplecov.rb0000644000004100000410000000572413320556542020730 0ustar www-datawww-datamodule Coveralls module SimpleCov class Formatter def display_result(result) # Log which files would be submitted. if result.files.length > 0 Coveralls::Output.puts "[Coveralls] Some handy coverage stats:" else Coveralls::Output.puts "[Coveralls] There are no covered files.", :color => "yellow" end result.files.each do |f| Coveralls::Output.print " * " Coveralls::Output.print short_filename(f.filename).to_s, :color => "cyan" Coveralls::Output.print " => ", :color => "white" cov = "#{f.covered_percent.round}%" if f.covered_percent > 90 Coveralls::Output.print cov, :color => "green" elsif f.covered_percent > 80 Coveralls::Output.print cov, :color => "yellow" else Coveralls::Output.print cov, :color => "red" end Coveralls::Output.puts "" end true end def get_source_files(result) # Gather the source files. source_files = [] result.files.each do |file| properties = {} # Get Source properties[:source] = File.open(file.filename, "rb:utf-8").read # Get the root-relative filename properties[:name] = short_filename(file.filename) # Get the coverage properties[:coverage] = file.coverage.dup # Skip nocov lines file.lines.each_with_index do |line, i| properties[:coverage][i] = nil if line.skipped? end source_files << properties end source_files end def format(result) unless Coveralls.should_run? if Coveralls.noisy? display_result result end return end # Post to Coveralls. API.post_json "jobs", :source_files => get_source_files(result), :test_framework => result.command_name.downcase, :run_at => result.created_at Coveralls::Output.puts output_message result true rescue Exception => e display_error e end def display_error(e) Coveralls::Output.puts "Coveralls encountered an exception:", :color => "red" Coveralls::Output.puts e.class.to_s, :color => "red" Coveralls::Output.puts e.message, :color => "red" e.backtrace.each do |line| Coveralls::Output.puts line, :color => "red" end if e.backtrace if e.respond_to?(:response) && e.response Coveralls::Output.puts e.response.to_s, :color => "red" end false end def output_message(result) "Coverage is at #{result.covered_percent.round(2) rescue result.covered_percent.round}%.\nCoverage report sent to Coveralls." end def short_filename(filename) filename = filename.gsub(::SimpleCov.root, '.').gsub(/^\.\//, '') if ::SimpleCov.root filename end end end end coveralls-0.8.22/lib/coveralls.rb0000644000004100000410000000533613320556542016726 0ustar www-datawww-datarequire "coveralls/version" require "coveralls/configuration" require "coveralls/api" require "coveralls/output" require "coveralls/simplecov" module Coveralls extend self class NilFormatter def format(result) end end attr_accessor :testing, :noisy, :run_locally def wear!(simplecov_setting=nil, &block) setup! start! simplecov_setting, &block end def wear_merged!(simplecov_setting=nil, &block) require 'simplecov' @@adapter = :simplecov ::SimpleCov.formatter = NilFormatter start! simplecov_setting, &block end def push! require 'simplecov' result = ::SimpleCov::ResultMerger.merged_result Coveralls::SimpleCov::Formatter.new.format result end def setup! # Try to load up SimpleCov. @@adapter = nil if defined?(::SimpleCov) @@adapter = :simplecov else begin require 'simplecov' @@adapter = :simplecov if defined?(::SimpleCov) rescue end end # Load the appropriate adapter. if @@adapter == :simplecov ::SimpleCov.formatter = Coveralls::SimpleCov::Formatter Coveralls::Output.puts("[Coveralls] Set up the SimpleCov formatter.", :color => "green") else Coveralls::Output.puts("[Coveralls] Couldn't find an appropriate adapter.", :color => "red") end end def start!(simplecov_setting = 'test_frameworks', &block) if @@adapter == :simplecov ::SimpleCov.add_filter 'vendor' if simplecov_setting Coveralls::Output.puts("[Coveralls] Using SimpleCov's '#{simplecov_setting}' settings.", :color => "green") if block_given? ::SimpleCov.start(simplecov_setting) { instance_eval(&block)} else ::SimpleCov.start(simplecov_setting) end elsif block Coveralls::Output.puts("[Coveralls] Using SimpleCov settings defined in block.", :color => "green") ::SimpleCov.start { instance_eval(&block) } else Coveralls::Output.puts("[Coveralls] Using SimpleCov's default settings.", :color => "green") ::SimpleCov.start end end end def should_run? # Fail early if we're not on a CI unless will_run? Coveralls::Output.puts("[Coveralls] Outside the CI environment, not sending data.", :color => "yellow") return false end if ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@run_locally) && @run_locally) Coveralls::Output.puts("[Coveralls] Creating a new job on Coveralls from local coverage results.", :color => "cyan") end true end def will_run? ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] || ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@testing) && @testing) end def noisy? ENV["COVERALLS_NOISY"] || (defined?(@noisy) && @noisy) end end coveralls-0.8.22/Gemfile0000644000004100000410000000147213320556542015131 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in coveralls-ruby.gemspec gemspec gem 'rake', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 10.3' : '>= 10.3' gem 'rspec', '>= 3.2' gem 'simplecov', :require => false gem 'truthy', '>= 1' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9') gem 'vcr', '~> 2.9' gem 'webmock', '~> 1.20' else gem 'vcr', '>= 2.9' gem 'webmock', '>= 1.20' end platforms :ruby_18 do gem 'addressable', '~> 2.3.8', :group => :test gem 'mime-types', '~> 1.25' end platforms :ruby_18, :ruby_19 do gem 'json', '~> 1.8' gem 'term-ansicolor', '~> 1.3.0' gem 'tins', '~> 1.6.0' end platforms :jruby do gem 'jruby-openssl' end platform :rbx do gem 'rubysl', '~> 2.0' gem 'rubinius-developer_tools' end group :test do gem 'pry' end coveralls-0.8.22/.ruby-version0000644000004100000410000000000613320556542016273 0ustar www-datawww-data2.3.3