Class: Dependabot::FileUpdaters::Elixir::Hex::MixfileUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/file_updaters/elixir/hex/mixfile_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(mixfile:, dependencies:) ⇒ MixfileUpdater

Returns a new instance of MixfileUpdater.



12
13
14
15
# File 'lib/dependabot/file_updaters/elixir/hex/mixfile_updater.rb', line 12

def initialize(mixfile:, dependencies:)
  @mixfile = mixfile
  @dependencies = dependencies
end

Instance Method Details

#updated_mixfile_contentObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dependabot/file_updaters/elixir/hex/mixfile_updater.rb', line 17

def updated_mixfile_content
  dependencies.
    select { |dep| requirement_changed?(mixfile, dep) }.
    reduce(mixfile.content.dup) do |content, dep|
      updated_content = content

      updated_content = update_requirement(
        content: updated_content,
        filename: mixfile.name,
        dependency: dep
      )

      updated_content = update_git_pin(
        content: updated_content,
        filename: mixfile.name,
        dependency: dep
      )

      if content == updated_content
        raise "Expected content to change!"
      end

      updated_content
    end
end