Class: Dependabot::PreCommit::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/pre_commit/file_parser.rb,
lib/dependabot/pre_commit/file_parser/hook_language_fetcher.rb

Defined Under Namespace

Classes: HookLanguageFetcher

Constant Summary collapse

CONFIG_FILE_PATTERN =
/\.pre-commit(-config)?\.ya?ml$/i
ECOSYSTEM =
"pre_commit"
LANGUAGE_PARSERS =
T.let(
  {
    "python" => ->(dep_string) { Dependabot::Python::RequirementParser.parse(dep_string) },
    "node" => ->(dep_string) { Dependabot::NpmAndYarn::Requirement.parse_dep_string(dep_string) },
    "rust" => ->(dep_string) { Dependabot::Cargo::Requirement.parse_dep_string(dep_string) },
    "golang" => ->(dep_string) { Dependabot::GoModules::RequirementParser.parse(dep_string) },
    "ruby" => ->(dep_string) { Dependabot::Bundler::Requirement.parse_dep_string(dep_string) },
    "dart" => ->(dep_string) { Dependabot::Pub::Requirement.parse_dep_string(dep_string) }
  }.freeze,
  T::Hash[String, T.proc.params(dep_string: String).returns(T.nilable(T::Hash[Symbol, T.untyped]))]
)

Instance Method Summary collapse

Instance Method Details

#ecosystemObject



44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/pre_commit/file_parser.rb', line 44

def ecosystem
  @ecosystem ||= T.let(
    Ecosystem.new(
      name: ECOSYSTEM,
      package_manager: package_manager
    ),
    T.nilable(Ecosystem)
  )
end

#parseObject



55
56
57
58
59
60
61
62
63
# File 'lib/dependabot/pre_commit/file_parser.rb', line 55

def parse
  dependency_set = DependencySet.new

  pre_commit_config_files.each do |file|
    dependency_set += parse_config_file(file)
  end

  dependency_set.dependencies
end