2017-09-10 17:25:29 +05:30
|
|
|
module Gitlab
|
|
|
|
module DependencyLinker
|
|
|
|
class GemfileLinker < MethodLinker
|
|
|
|
self.file_type = :gemfile
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def link_dependencies
|
|
|
|
link_urls
|
|
|
|
link_packages
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_urls
|
|
|
|
# Link `github: "user/repo"` to https://github.com/user/repo
|
|
|
|
link_regex(/(github:|:github\s*=>)\s*['"](?<name>[^'"]+)['"]/, &method(:github_url))
|
|
|
|
|
|
|
|
# Link `git: "https://gitlab.example.com/user/repo"` to https://gitlab.example.com/user/repo
|
2018-03-17 18:26:18 +05:30
|
|
|
link_regex(/(git:|:git\s*=>)\s*['"](?<name>#{URL_REGEX})['"]/, &:itself)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
# Link `source "https://rubygems.org"` to https://rubygems.org
|
|
|
|
link_method_call('source', URL_REGEX, &:itself)
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_packages
|
|
|
|
# Link `gem "package_name"` to https://rubygems.org/gems/package_name
|
|
|
|
link_method_call('gem') do |name|
|
|
|
|
"https://rubygems.org/gems/#{name}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|