Module: Coveralls

Extended by:
Coveralls
Included in:
Coveralls
Defined in:
lib/coveralls.rb,
lib/coveralls/api.rb,
lib/coveralls/output.rb,
lib/coveralls/command.rb,
lib/coveralls/version.rb,
lib/coveralls/rake/task.rb,
lib/coveralls/simplecov.rb,
lib/coveralls/configuration.rb

Defined Under Namespace

Modules: Configuration, Output, SimpleCov Classes: API, CommandLine, NilFormatter, RakeTask

Constant Summary collapse

VERSION =
"0.8.21"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#noisyObject

Returns the value of attribute noisy.



15
16
17
# File 'lib/coveralls.rb', line 15

def noisy
  @noisy
end

#run_locallyObject

Returns the value of attribute run_locally.



15
16
17
# File 'lib/coveralls.rb', line 15

def run_locally
  @run_locally
end

#testingObject

Returns the value of attribute testing.



15
16
17
# File 'lib/coveralls.rb', line 15

def testing
  @testing
end

Instance Method Details

#noisy?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/coveralls.rb', line 98

def noisy?
  ENV["COVERALLS_NOISY"] || (defined?(@noisy) && @noisy)
end

#push!Object



29
30
31
32
33
# File 'lib/coveralls.rb', line 29

def push!
  require 'simplecov'
  result = ::SimpleCov::ResultMerger.merged_result
  Coveralls::SimpleCov::Formatter.new.format result
end

#setup!Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/coveralls.rb', line 35

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

#should_run?Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/coveralls.rb', line 79

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

#start!(simplecov_setting = 'test_frameworks', &block) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/coveralls.rb', line 58

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

#wear!(simplecov_setting = nil, &block) ⇒ Object



17
18
19
20
# File 'lib/coveralls.rb', line 17

def wear!(simplecov_setting=nil, &block)
  setup!
  start! simplecov_setting, &block
end

#wear_merged!(simplecov_setting = nil, &block) ⇒ Object



22
23
24
25
26
27
# File 'lib/coveralls.rb', line 22

def wear_merged!(simplecov_setting=nil, &block)
  require 'simplecov'
  @@adapter = :simplecov
  ::SimpleCov.formatter = NilFormatter
  start! simplecov_setting, &block
end

#will_run?Boolean

Returns:

  • (Boolean)


93
94
95
96
# File 'lib/coveralls.rb', line 93

def will_run?
  ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] ||
    ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@testing) && @testing)
end