Class: GitlabDanger

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

Constant Summary collapse

MESSAGE_PREFIX =
'==>'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gitlab_danger_helper) ⇒ GitlabDanger

Returns a new instance of GitlabDanger.


33
34
35
# File 'lib/gitlab_danger.rb', line 33

def initialize(gitlab_danger_helper)
  @gitlab_danger_helper = gitlab_danger_helper
end

Instance Attribute Details

#gitlab_danger_helperObject (readonly)

Returns the value of attribute gitlab_danger_helper


31
32
33
# File 'lib/gitlab_danger.rb', line 31

def gitlab_danger_helper
  @gitlab_danger_helper
end

Class Method Details

.local_warning_messageObject


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

def self.local_warning_message
  "#{MESSAGE_PREFIX} Only the following Danger rules can be run locally: #{LOCAL_RULES.join(', ')}"
end

.success_messageObject


41
42
43
# File 'lib/gitlab_danger.rb', line 41

def self.success_message
  "#{MESSAGE_PREFIX} No Danger rule violations!"
end

Instance Method Details

#ci?Boolean

Returns:

  • (Boolean)

53
54
55
# File 'lib/gitlab_danger.rb', line 53

def ci?
  !gitlab_danger_helper.nil?
end

49
50
51
# File 'lib/gitlab_danger.rb', line 49

def html_link(str)
  self.ci? ? gitlab_danger_helper.html_link(str) : str
end

#rule_namesObject


45
46
47
# File 'lib/gitlab_danger.rb', line 45

def rule_names
  ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
end