2016-07-10 17:13:06 -04:00
|
|
|
module Gitlab
|
|
|
|
module DependencyLinker
|
2017-05-16 16:25:57 -04:00
|
|
|
class GemfileLinker < MethodLinker
|
2017-05-12 15:31:05 -04:00
|
|
|
self.file_type = :gemfile
|
2016-07-10 17:13:06 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def link_dependencies
|
2017-05-16 16:25:57 -04:00
|
|
|
link_urls
|
|
|
|
link_packages
|
|
|
|
end
|
2016-07-10 17:13:06 -04:00
|
|
|
|
2017-05-16 16:25:57 -04:00
|
|
|
def link_urls
|
2016-07-10 17:13:06 -04:00
|
|
|
# Link `github: "user/repo"` to https://github.com/user/repo
|
2017-05-16 16:25:57 -04:00
|
|
|
link_regex(/(github:|:github\s*=>)\s*['"](?<name>[^'"]+)['"]/, &method(:github_url))
|
2016-07-10 17:13:06 -04:00
|
|
|
|
2017-05-12 11:29:25 -04:00
|
|
|
# Link `git: "https://gitlab.example.com/user/repo"` to https://gitlab.example.com/user/repo
|
2017-05-16 16:25:57 -04:00
|
|
|
link_regex(%r{(git:|:git\s*=>)\s*['"](?<name>#{URL_REGEX})['"]}, &:itself)
|
2017-05-12 11:29:25 -04:00
|
|
|
|
2016-07-10 17:13:06 -04:00
|
|
|
# Link `source "https://rubygems.org"` to https://rubygems.org
|
2017-05-16 16:25:57 -04:00
|
|
|
link_method_call('source', URL_REGEX, &:itself)
|
2016-07-10 17:13:06 -04:00
|
|
|
end
|
|
|
|
|
2017-05-16 16:25:57 -04:00
|
|
|
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
|
2016-07-10 17:13:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|