blob: da3c6b0e76f6b2217d39c566e39a56ab2de6c454 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
require 'forwardable'
require_relative 'suggestor'
module Tooling
module Danger
# A basic suggestion.
#
# A subclass needs to define the following constants:
# * MATCH (Regexp) - A Regexp to match file lines
# * REPLACEMENT (String) - A suggestion replacement text
# * SUGGESTION (String) - A suggestion text
#
# @see Suggestor
class Suggestion
extend Forwardable
include ::Tooling::Danger::Suggestor
def_delegators :@context, :helper, :project_helper, :markdown
attr_reader :filename
def initialize(filename, context:)
@filename = filename
@context = context
end
def suggest
add_suggestion(
filename: filename,
regex: self.class::MATCH,
replacement: self.class::REPLACEMENT,
comment_text: self.class::SUGGESTION
)
end
end
end
end
|