summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-12 14:31:05 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-12 19:09:30 -0500
commit38d84f83600d890f4227fc510a484554f009a1c0 (patch)
tree9e54ce6f304497bdfe9ff741b152f059f1d7f8b8 /lib
parent040fc99177eb620db41940f0c36b731ed612708b (diff)
downloadgitlab-ce-38d84f83600d890f4227fc510a484554f009a1c0.tar.gz
Select dependency linker based on file typedm-dependency-linker-file-type
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/dependency_linker/base_linker.rb10
-rw-r--r--lib/gitlab/dependency_linker/gemfile_linker.rb4
-rw-r--r--lib/gitlab/file_detector.rb1
3 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/dependency_linker/base_linker.rb b/lib/gitlab/dependency_linker/base_linker.rb
index 40a4ad11372..5f4027e7e81 100644
--- a/lib/gitlab/dependency_linker/base_linker.rb
+++ b/lib/gitlab/dependency_linker/base_linker.rb
@@ -1,8 +1,14 @@
module Gitlab
module DependencyLinker
class BaseLinker
- def self.link(plain_text, highlighted_text)
- new(plain_text, highlighted_text).link
+ class_attribute :file_type
+
+ def self.support?(blob_name)
+ Gitlab::FileDetector.type_of(blob_name) == file_type
+ end
+
+ def self.link(*args)
+ new(*args).link
end
attr_accessor :plain_text, :highlighted_text
diff --git a/lib/gitlab/dependency_linker/gemfile_linker.rb b/lib/gitlab/dependency_linker/gemfile_linker.rb
index 45be760d89e..9b82e126528 100644
--- a/lib/gitlab/dependency_linker/gemfile_linker.rb
+++ b/lib/gitlab/dependency_linker/gemfile_linker.rb
@@ -1,9 +1,7 @@
module Gitlab
module DependencyLinker
class GemfileLinker < BaseLinker
- def self.support?(blob_name)
- blob_name == 'Gemfile' || blob_name == 'gems.rb'
- end
+ self.file_type = :gemfile
private
diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb
index f8b3d0b4965..c6a89597b23 100644
--- a/lib/gitlab/file_detector.rb
+++ b/lib/gitlab/file_detector.rb
@@ -12,6 +12,7 @@ module Gitlab
version: 'version',
gitignore: '.gitignore',
koding: '.koding.yml',
+ gemfile: /\A(Gemfile|gems\.rb)\z/,
gitlab_ci: '.gitlab-ci.yml',
avatar: /\Alogo\.(png|jpg|gif)\z/,
route_map: 'route-map.yml'