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

gemfile_linker.rb « dependency_linker « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d034ea67387d8572dc5bd140cfa2d9a890d4988d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
        link_regex(%r{(git:|:git\s*=>)\s*['"](?<name>#{URL_REGEX})['"]}, &:itself)

        # 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