Class: Gitlab::Triage::EntityBuilders::IssueBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/triage/entity_builders/issue_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, action:, resource:, network:, policy_spec: {}, separator: "\n") ⇒ IssueBuilder

Returns a new instance of IssueBuilder.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 11

def initialize(
  type:, action:, resource:, network:,
  policy_spec: {}, separator: "\n")
  @type = type
  @policy_spec = policy_spec
  @item_template = action[:item]
  @title_template = action[:title]
  @description_template = action[:description]
  @destination = action[:destination]
  @redact_confidentials =
    action[:redact_confidential_resources] != false
  @resource = resource
  @network = network
  @separator = separator
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



9
10
11
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 9

def destination
  @destination
end

Instance Method Details

#build_text(template) ⇒ Object (private)



41
42
43
44
45
46
47
48
49
50
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 41

def build_text(template)
  return '' unless template

  CommandBuilders::TextContentBuilder.new(
    template,
    resource: @resource,
    network: @network,
    redact_confidentials: @redact_confidentials)
    .build_command.chomp
end

#descriptionObject



31
32
33
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 31

def description
  @description ||= build_text(@description_template)
end

#titleObject



27
28
29
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 27

def title
  @title ||= build_text(@title_template)
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gitlab/triage/entity_builders/issue_builder.rb', line 35

def valid?
  title =~ /\S+/
end