Sha256: 00c3554ecb783894b87fd51609e13c76fbfa4e245c9aa2be33bf39936ae1adef

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'colorize'

require "coveralls/version"
require "coveralls/configuration"
require "coveralls/api"
require "coveralls/simplecov"

module Coveralls

  def self.wear!(*args)
    setup!
    start!(*args)
  end

  def self.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
      puts "[Coveralls] Set up the SimpleCov formatter.".green
    else
      puts "[Coveralls] Couldn't find an appropriate adapter.".red
    end

  end

  def self.start!(simplecov_setting = 'test_frameworks')
    if @@adapter == :simplecov
      if simplecov_setting
        puts "[Coveralls] Using SimpleCov's '#{simplecov_setting}' settings.".green
        ::SimpleCov.start(simplecov_setting)
      else
        puts "[Coveralls] Using SimpleCov's default settings.".green
        ::SimpleCov.start
      end
    end
  end

  def self.should_run?

    # Fail early if we're not on Travis
    unless ENV["TRAVIS"] || ENV["COVERALLS_RUN_LOCALLY"]
      puts "[Coveralls] Outside the Travis environment, not sending data.".yellow
      return false
    end

    if ENV["COVERALLS_RUN_LOCALLY"]
      puts "[Coveralls] Creating a new job on Coveralls from local coverage results.".cyan
    end

    true
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coveralls-0.6.0 lib/coveralls.rb
coveralls-0.5.9 lib/coveralls.rb
coveralls-0.5.8 lib/coveralls.rb