Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-17 03:59:55 +0300
committerDouwe Maan <douwe@selenight.nl>2016-08-18 01:54:24 +0300
commit8b8a4626c601a13683599fd1a127e2c502af38a3 (patch)
tree5478e3356c4ab3a02923cb48c8271a97273959fa /lib/gitlab/slash_commands
parente07c27fee427195d8d89f6278d0fc12dfeec3588 (diff)
Fix specs and implement fixes based on failing specs
Diffstat (limited to 'lib/gitlab/slash_commands')
-rw-r--r--lib/gitlab/slash_commands/command_definition.rb8
-rw-r--r--lib/gitlab/slash_commands/dsl.rb18
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/gitlab/slash_commands/command_definition.rb b/lib/gitlab/slash_commands/command_definition.rb
index 187c1c9489f..641c92e77da 100644
--- a/lib/gitlab/slash_commands/command_definition.rb
+++ b/lib/gitlab/slash_commands/command_definition.rb
@@ -3,8 +3,14 @@ module Gitlab
class CommandDefinition
attr_accessor :name, :aliases, :description, :params, :condition_block, :action_block
- def initialize(name)
+ def initialize(name, attributes = {})
@name = name
+
+ @aliases = attributes[:aliases] || []
+ @description = attributes[:description] || ''
+ @params = attributes[:params] || []
+ @condition_block = attributes[:condition_block]
+ @action_block = attributes[:action_block]
end
def all_names
diff --git a/lib/gitlab/slash_commands/dsl.rb b/lib/gitlab/slash_commands/dsl.rb
index 7b1a094a7e6..50b0937d267 100644
--- a/lib/gitlab/slash_commands/dsl.rb
+++ b/lib/gitlab/slash_commands/dsl.rb
@@ -17,7 +17,7 @@ module Gitlab
# Allows to give a description to the next slash command.
# This description is shown in the autocomplete menu.
# It accepts a block that will be evaluated with the context given to
- # `.command_definitions` or `.command_names`.
+ # `CommandDefintion#to_h`.
#
# Example:
#
@@ -47,7 +47,7 @@ module Gitlab
# Allows to define conditions that must be met in order for the command
# to be returned by `.command_names` & `.command_definitions`.
# It accepts a block that will be evaluated with the context given to
- # `.command_definitions`, `.command_names`, and the actual command method.
+ # `CommandDefintion#to_h`.
#
# Example:
#
@@ -73,12 +73,14 @@ module Gitlab
def command(*command_names, &block)
name, *aliases = command_names
- definition = CommandDefinition.new(name)
- definition.aliases = aliases
- definition.description = @description || ''
- definition.params = @params || []
- definition.condition_block = @condition_block
- definition.action_block = block
+ definition = CommandDefinition.new(
+ name,
+ aliases: aliases,
+ description: @description,
+ params: @params,
+ condition_block: @condition_block,
+ action_block: block
+ )
self.command_definitions << definition