Class: Gitlab::QuickActions::SubstitutionDefinition

Inherits:
CommandDefinition show all
Defined in:
lib/gitlab/quick_actions/substitution_definition.rb

Constant Summary

Constants inherited from CommandDefinition

CommandDefinition::ParseError

Instance Attribute Summary

Attributes inherited from CommandDefinition

#action_block, #aliases, #condition_block, #description, #execution_message, #explanation, #icon, #name, #params, #parse_params_block, #types, #warning

Instance Method Summary collapse

Methods inherited from CommandDefinition

#all_names, #available?, #execute, #execute_message, #explain, #initialize, #to_h

Constructor Details

This class inherits a constructor from Gitlab::QuickActions::CommandDefinition

Instance Method Details

#noop?Boolean

noop?=>true means these won't get extracted or removed by Gitlab::QuickActions::Extractor#extract_commands QuickActions::InterpretService#perform_substitutions handles them separately

Returns:

  • (Boolean)

8
9
10
# File 'lib/gitlab/quick_actions/substitution_definition.rb', line 8

def noop?
  true
end

#perform_substitution(context, content) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/quick_actions/substitution_definition.rb', line 12

def perform_substitution(context, content)
  return unless content

  all_names.each do |a_name|
    content = content.sub(%r{/#{a_name}(?!\S) ?(.*)$}i, execute_block(action_block, context, '\1'))
  end

  content
end