Class: BlobViewer::GoMod

Inherits:
DependencyManager show all
Includes:
ServerSide, Gitlab::Utils::StrongMemoize
Defined in:
app/models/blob_viewer/go_mod.rb

Constant Summary collapse

MODULE_REGEX =
%r{
  \A (?# beginning of file)
  module\s+ (?# module directive)
  (?<name>.*?) (?# module name)
  \s*(?://.*)? (?# comment)
  (?:\n|\z) (?# newline or end of file)
}x

Constants inherited from Base

Base::PARTIAL_PATH_PREFIX

Instance Attribute Summary

Attributes inherited from Base

#blob

Instance Method Summary collapse

Methods included from ServerSide

#prepare!, #render_error

Methods included from Auxiliary

#visible_to?

Methods included from Gitlab::Allowable

#can?

Methods inherited from Base

auxiliary?, binary?, #binary_detected_after_load?, can_render?, #collapsed?, #initialize, load_async?, loading_partial_path, partial_path, #prepare!, #render_error, rich?, simple?, text?, #too_large?

Constructor Details

This class inherits a constructor from BlobViewer::Base

Instance Method Details

#manager_nameObject



18
19
20
# File 'app/models/blob_viewer/go_mod.rb', line 18

def manager_name
  'Go Modules'
end

#manager_urlObject



22
23
24
# File 'app/models/blob_viewer/go_mod.rb', line 22

def manager_url
  'https://golang.org/ref/mod'
end

#package_nameObject



30
31
32
33
34
35
36
37
# File 'app/models/blob_viewer/go_mod.rb', line 30

def package_name
  strong_memoize(:package_name) do
    next if blob.name != 'go.mod'
    next unless match = MODULE_REGEX.match(blob.data)

    match[:name]
  end
end

#package_typeObject



26
27
28
# File 'app/models/blob_viewer/go_mod.rb', line 26

def package_type
  'go'
end

#package_urlObject



39
40
41
# File 'app/models/blob_viewer/go_mod.rb', line 39

def package_url
  Gitlab::Golang.package_url(package_name)
end