Class: Dependabot::Gradle::FileFetcher::SettingsFileParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/gradle/file_fetcher/settings_file_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings_file:) ⇒ SettingsFileParser

Returns a new instance of SettingsFileParser.



15
16
17
# File 'lib/dependabot/gradle/file_fetcher/settings_file_parser.rb', line 15

def initialize(settings_file:)
  @settings_file = settings_file
end

Instance Method Details

#included_build_pathsObject



20
21
22
23
24
25
26
27
# File 'lib/dependabot/gradle/file_fetcher/settings_file_parser.rb', line 20

def included_build_paths
  paths = []
  comment_free_content&.scan(function_regex("includeBuild")) do
    arg = T.must(Regexp.last_match).named_captures.fetch("args")
    paths << T.must(arg).gsub(/["']/, "").strip
  end
  paths.uniq
end

#subproject_path_to_name_mapObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dependabot/gradle/file_fetcher/settings_file_parser.rb', line 40

def subproject_path_to_name_map
  subprojects = T.let([], T::Array[String])
  process_include_functions(subprojects)
  subprojects.uniq.each_with_object(T.let({}, T::Hash[String, String])) do |name, map|
    path = process_subproject_name(name)
    next unless path

    # Normalise name to Gradle colon-separated project path (e.g. ':app', ':sub:module')
    map[path] = ":#{name.sub(/^:/, '')}"
  end
end

#subproject_pathsObject



30
31
32
33
34
# File 'lib/dependabot/gradle/file_fetcher/settings_file_parser.rb', line 30

def subproject_paths
  subprojects = T.let([], T::Array[String])
  process_include_functions(subprojects)
  subprojects.uniq.map { |name| process_subproject_name(name) }
end