Class: Dependabot::Gradle::FileUpdater::DependencySetUpdater
- Inherits:
-
Object
- Object
- Dependabot::Gradle::FileUpdater::DependencySetUpdater
- Defined in:
- lib/dependabot/gradle/file_updater/dependency_set_updater.rb
Instance Method Summary collapse
-
#initialize(dependency_files:) ⇒ DependencySetUpdater
constructor
A new instance of DependencySetUpdater.
- #update_files_for_dep_set_change(dependency_set:, buildfile:, previous_requirement:, updated_requirement:) ⇒ Object
Constructor Details
#initialize(dependency_files:) ⇒ DependencySetUpdater
Returns a new instance of DependencySetUpdater.
10 11 12 |
# File 'lib/dependabot/gradle/file_updater/dependency_set_updater.rb', line 10 def initialize(dependency_files:) @dependency_files = dependency_files end |
Instance Method Details
#update_files_for_dep_set_change(dependency_set:, buildfile:, previous_requirement:, updated_requirement:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/gradle/file_updater/dependency_set_updater.rb', line 14 def update_files_for_dep_set_change(dependency_set:, buildfile:, previous_requirement:, updated_requirement:) declaration_string = original_declaration_string(dependency_set, buildfile) return dependency_files unless declaration_string updated_content = buildfile.content.sub( declaration_string, declaration_string.sub( previous_requirement, updated_requirement ) ) updated_files = dependency_files.dup updated_files[updated_files.index(buildfile)] = update_file(file: buildfile, content: updated_content) updated_files end |