Class: CircleCIReporter::Configuration

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#artifacts_dirString

Returns:

  • (String)


37
38
39
# File 'lib/circleci_reporter/configuration.rb', line 37

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

#base_revisionString

Returns:

  • (String)


42
43
44
# File 'lib/circleci_reporter/configuration.rb', line 42

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

#circleci_tokenObject

Returns the value of attribute circleci_token.



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

def circleci_token
  @circleci_token
end

#current_build_numberInteger

Returns:

  • (Integer)


47
48
49
# File 'lib/circleci_reporter/configuration.rb', line 47

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

#current_revisionString

Returns:

  • (String)


52
53
54
# File 'lib/circleci_reporter/configuration.rb', line 52

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

#previous_build_numberInteger?

Returns:

  • (Integer, nil)


57
58
59
# File 'lib/circleci_reporter/configuration.rb', line 57

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

#reportersArray<Reporters::Base>

Returns:



27
28
29
# File 'lib/circleci_reporter/configuration.rb', line 27

def reporters
  @reporters ||= DEFAULT_REPORTERS.dup
end

#repository_nameString

Returns:

  • (String)


62
63
64
# File 'lib/circleci_reporter/configuration.rb', line 62

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.



17
18
19
# File 'lib/circleci_reporter/configuration.rb', line 17

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.



17
18
19
# File 'lib/circleci_reporter/configuration.rb', line 17

def template_safe_mode=(value)
  @template_safe_mode = value
end

#user_nameString

Returns:

  • (String)


67
68
69
# File 'lib/circleci_reporter/configuration.rb', line 67

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

#vcs_tokenObject

Returns the value of attribute vcs_token.



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

def vcs_token
  @vcs_token
end

#vcs_typeString

Returns:

  • (String)


32
33
34
# File 'lib/circleci_reporter/configuration.rb', line 32

def vcs_type
  @vcs_type ||= DEFAULT_VCS_TYPE
end

Instance Method Details

#dumpvoid

This method returns an undefined value.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/circleci_reporter/configuration.rb', line 72

def dump
  puts <<~CONFIGURATION
    Configuration         | Value
    ----------------------|----------------------------------------------------------------------------
    artifacts_dir         | #{artifacts_dir.inspect}
    base_revision         | #{base_revision.inspect}
    circleci_token        | #{circleci_token[-4..].rjust(40, '*').inspect if circleci_token}
    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..].rjust(40, '*').inspect if vcs_token}
    vcs_type              | #{vcs_type.inspect}
  CONFIGURATION
end

#projectString

Returns:

  • (String)


22
23
24
# File 'lib/circleci_reporter/configuration.rb', line 22

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