Sha256: 91d3dd2524090b4624460bb720bcd93b112f0d826e642f9eb53090e38a7558d0

Contents?: true

Size: 1.45 KB

Versions: 12

Compression:

Stored size: 1.45 KB

Contents

module CodeClimate
  module TestReporter

    def self.start
      if run?
        require "simplecov"
        ::SimpleCov.add_filter 'vendor'
        ::SimpleCov.formatter = Formatter
        ::SimpleCov.start(configuration.profile) do
          skip_token CodeClimate::TestReporter.configuration.skip_token
        end
      end
    end

    def self.run?
      environment_variable_set? && run_on_current_branch?
    end

    def self.environment_variable_set?
      return @environment_variable_set if defined?(@environment_variable_set)

      @environment_variable_set = !!ENV["CODECLIMATE_REPO_TOKEN"]
      unless @environment_variable_set
        logger.info("Not reporting to Code Climate because ENV['CODECLIMATE_REPO_TOKEN'] is not set.")
      end

      @environment_variable_set
    end

    def self.run_on_current_branch?
      return @run_on_current_branch if defined?(@run_on_current_branch)

      @run_on_current_branch = true if configured_branch.nil?
      @run_on_current_branch ||= !!(current_branch =~ /#{configured_branch}/i)

      unless @run_on_current_branch
        logger.info("Not reporting to Code Climate because #{configured_branch} is set as the reporting branch.")
      end

      @run_on_current_branch
    end

    def self.configured_branch
      configuration.branch
    end

    def self.current_branch
      Git.branch_from_git_or_ci
    end

    def self.logger
      CodeClimate::TestReporter.configuration.logger
    end

  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
construi-0.6.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/lib/code_climate/test_reporter.rb
construi-0.5.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/lib/code_climate/test_reporter.rb
construi-0.4.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/lib/code_climate/test_reporter.rb
construi-0.2.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/lib/code_climate/test_reporter.rb
construi-0.1.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.7 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.6 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.5 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.4 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.3 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.2 lib/code_climate/test_reporter.rb
codeclimate-test-reporter-0.4.1 lib/code_climate/test_reporter.rb