Class: Dependabot::Nix::FileUpdater::FlakeRefBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nix/file_updater/flake_ref_builder.rb

Constant Summary collapse

ARCHIVE_TYPES =
%w(github gitlab sourcehut).freeze
ARCHIVE_PATH_KEYS =
%w(type owner repo ref rev).freeze
GIT_URL_KEYS =
%w(type url rev).freeze
LOCKED_ONLY_KEYS =
%w(lastModified narHash revCount).freeze
SCP_STYLE_URL =
/\A(?<user>[^@]+)@(?<host>[^:]+):(?<path>.+)\z/

Instance Method Summary collapse

Constructor Details

#initialize(source:, revision:) ⇒ FlakeRefBuilder

Returns a new instance of FlakeRefBuilder.



22
23
24
25
# File 'lib/dependabot/nix/file_updater/flake_ref_builder.rb', line 22

def initialize(source:, revision:)
  @source = source
  @revision = revision
end

Instance Method Details

#to_sObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/nix/file_updater/flake_ref_builder.rb', line 28

def to_s
  source_type = required_string("type")

  if ARCHIVE_TYPES.include?(source_type)
    archive_reference(source_type)
  elsif source_type == "git"
    git_reference
  else
    raise ArgumentError, "Nix flake source type #{source_type.inspect} is not supported"
  end
end