Class: Dependabot::FileUpdaters::Php::Composer

Inherits:
Base
  • Object
show all
Defined in:
lib/dependabot/file_updaters/php/composer.rb,
lib/dependabot/file_updaters/php/composer/lockfile_updater.rb,
lib/dependabot/file_updaters/php/composer/manifest_updater.rb

Defined Under Namespace

Classes: LockfileUpdater, ManifestUpdater

Instance Attribute Summary

Attributes inherited from Base

#credentials, #dependencies, #dependency_files

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dependabot::FileUpdaters::Base

Class Method Details

.updated_files_regexObject



15
16
17
18
19
20
# File 'lib/dependabot/file_updaters/php/composer.rb', line 15

def self.updated_files_regex
  [
    /^composer\.json$/,
    /^composer\.lock$/
  ]
end

Instance Method Details

#updated_dependency_filesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/file_updaters/php/composer.rb', line 22

def updated_dependency_files
  updated_files = []

  if file_changed?(composer_json)
    updated_files <<
      updated_file(
        file: composer_json,
        content: updated_composer_json_content
      )
  end

  if lockfile
    updated_files <<
      updated_file(file: lockfile, content: updated_lockfile_content)
  end

  if updated_files.none? ||
     updated_files.sort_by(&:name) == dependency_files.sort_by(&:name)
    raise "No files have changed!"
  end

  updated_files
end