Class: CircleCI::CoverageReporter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/circleci/coverage_reporter/configuration.rb

Constant Summary collapse

DEFAULT_REPORTERS =
[
  Reporters::SimpleCov.new,
  Reporters::Flow.new,
  Reporters::RubyCritic.new
].freeze
DEFAULT_VCS_TYPE =
'github'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#artifacts_dirString

Returns:

  • (String)


35
36
37
# File 'lib/circleci/coverage_reporter/configuration.rb', line 35

def artifacts_dir
  @artifacts_dir ||= ENV['CIRCLE_ARTIFACTS']
end

#base_revisionString

Returns:

  • (String)


40
41
42
# File 'lib/circleci/coverage_reporter/configuration.rb', line 40

def base_revision
  @base_revision ||= `git merge-base origin/master HEAD`.strip
end

#circleci_tokenObject

Returns the value of attribute circleci_token.



15
16
17
# File 'lib/circleci/coverage_reporter/configuration.rb', line 15

def circleci_token
  @circleci_token
end

#current_build_numberInteger

Returns:

  • (Integer)


45
46
47
# File 'lib/circleci/coverage_reporter/configuration.rb', line 45

def current_build_number
  @current_build_number ||= ENV['CIRCLE_BUILD_NUM']
end

#current_revisionString

Returns:

  • (String)


50
51
52
# File 'lib/circleci/coverage_reporter/configuration.rb', line 50

def current_revision
  @current_revision ||= ENV['CIRCLE_SHA1']
end

#previous_build_numberInteger?

Returns:

  • (Integer, nil)


55
56
57
# File 'lib/circleci/coverage_reporter/configuration.rb', line 55

def previous_build_number
  @previous_build_number ||= ENV['CIRCLE_PREVIOUS_BUILD_NUM'] && ENV['CIRCLE_PREVIOUS_BUILD_NUM'].to_i
end

#reportersArray<Reporters::Base>

Returns:



25
26
27
# File 'lib/circleci/coverage_reporter/configuration.rb', line 25

def reporters
  @reporters ||= DEFAULT_REPORTERS.dup
end

#repository_nameString

Returns:

  • (String)


60
61
62
# File 'lib/circleci/coverage_reporter/configuration.rb', line 60

def repository_name
  @repository_name ||= ENV['CIRCLE_PROJECT_REPONAME']
end

#template=(value) ⇒ Object (writeonly)

Sets the attribute template

Parameters:

  • value

    the value to set the attribute template to.



16
17
18
# File 'lib/circleci/coverage_reporter/configuration.rb', line 16

def template=(value)
  @template = value
end

#template_safe_mode=(value) ⇒ Object (writeonly)

Sets the attribute template_safe_mode

Parameters:

  • value

    the value to set the attribute template_safe_mode to.



16
17
18
# File 'lib/circleci/coverage_reporter/configuration.rb', line 16

def template_safe_mode=(value)
  @template_safe_mode = value
end

#user_nameString

Returns:

  • (String)


65
66
67
# File 'lib/circleci/coverage_reporter/configuration.rb', line 65

def user_name
  @user_name ||= ENV['CIRCLE_PROJECT_USERNAME']
end

#vcs_tokenObject

Returns the value of attribute vcs_token.



15
16
17
# File 'lib/circleci/coverage_reporter/configuration.rb', line 15

def vcs_token
  @vcs_token
end

#vcs_typeString

Returns:

  • (String)


30
31
32
# File 'lib/circleci/coverage_reporter/configuration.rb', line 30

def vcs_type
  @vcs_type ||= DEFAULT_VCS_TYPE
end

Instance Method Details

#dumpvoid

This method returns an undefined value.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/circleci/coverage_reporter/configuration.rb', line 70

def dump # rubocop:disable AbcSize
  puts <<~EOF
    Configuration         | Value
    ----------------------|----------------------------------------------------------------------------
    artifacts_dir         | #{artifacts_dir.inspect}
    base_revision         | #{base_revision.inspect}
    circleci_token        | #{circleci_token[-4..-1].rjust(40, '*').inspect}
    current_build_number  | #{current_build_number.inspect}
    current_revision      | #{current_revision.inspect}
    previous_build_number | #{previous_build_number.inspect}
    reporters             | #{reporters.inspect}
    repository_name       | #{repository_name.inspect}
    user_name             | #{user_name.inspect}
    vcs_token             | #{vcs_token[-4..-1].rjust(40, '*').inspect}
    vcs_type              | #{vcs_type.inspect}
  EOF
end

#projectString

Returns:

  • (String)


20
21
22
# File 'lib/circleci/coverage_reporter/configuration.rb', line 20

def project
  "#{user_name}/#{repository_name}"
end