Class: Dependabot::Elm::FileUpdater::ElmJsonUpdater
- Inherits:
-
Object
- Object
- Dependabot::Elm::FileUpdater::ElmJsonUpdater
- Defined in:
- lib/dependabot/elm/file_updater/elm_json_updater.rb
Instance Method Summary collapse
-
#initialize(elm_json_file:, dependencies:) ⇒ ElmJsonUpdater
constructor
A new instance of ElmJsonUpdater.
- #updated_content ⇒ Object
Constructor Details
#initialize(elm_json_file:, dependencies:) ⇒ ElmJsonUpdater
Returns a new instance of ElmJsonUpdater.
10 11 12 13 |
# File 'lib/dependabot/elm/file_updater/elm_json_updater.rb', line 10 def initialize(elm_json_file:, dependencies:) @elm_json_file = elm_json_file @dependencies = dependencies end |
Instance Method Details
#updated_content ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dependabot/elm/file_updater/elm_json_updater.rb', line 15 def updated_content dependencies .select { |dep| requirement_changed?(elm_json_file, dep) } .reduce(elm_json_file.content.dup) do |content, dep| updated_content = content updated_content = update_requirement( content: updated_content, filename: elm_json_file.name, dependency: dep ) next updated_content unless content == updated_content raise "Expected content to change!" end end |