Class: Dependabot::Gradle::FileUpdater::PropertyValueUpdater
- Inherits:
-
Object
- Object
- Dependabot::Gradle::FileUpdater::PropertyValueUpdater
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/gradle/file_updater/property_value_updater.rb
Instance Method Summary collapse
-
#initialize(dependency_files:) ⇒ PropertyValueUpdater
constructor
A new instance of PropertyValueUpdater.
- #update_files_for_property_change(property_name:, callsite_buildfile:, previous_value:, updated_value:) ⇒ Object
Constructor Details
#initialize(dependency_files:) ⇒ PropertyValueUpdater
Returns a new instance of PropertyValueUpdater.
16 17 18 19 |
# File 'lib/dependabot/gradle/file_updater/property_value_updater.rb', line 16 def initialize(dependency_files:) @dependency_files = dependency_files @property_value_finder = T.let(nil, T.nilable(Gradle::FileParser::PropertyValueFinder)) end |
Instance Method Details
#update_files_for_property_change(property_name:, callsite_buildfile:, previous_value:, updated_value:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dependabot/gradle/file_updater/property_value_updater.rb', line 30 def update_files_for_property_change( property_name:, callsite_buildfile:, previous_value:, updated_value: ) declaration_details = T.must( property_value_finder.property_details( property_name: property_name, callsite_buildfile: callsite_buildfile ) ) declaration_string = declaration_details.fetch(:declaration_string) filename = declaration_details.fetch(:file) file_to_update = T.must(dependency_files.find { |f| f.name == filename }) updated_content = T.must(file_to_update.content).sub( declaration_string, declaration_string.sub( previous_value_regex(previous_value), updated_value ) ) updated_files = dependency_files.dup updated_files[T.must(updated_files.index(file_to_update))] = update_file(file: file_to_update, content: updated_content) updated_files end |