Class: Dependabot::Python::FileUpdater::PipfilePreparer
- Inherits:
-
Object
- Object
- Dependabot::Python::FileUpdater::PipfilePreparer
- Defined in:
- lib/dependabot/python/file_updater/pipfile_preparer.rb
Instance Method Summary collapse
-
#initialize(pipfile_content:) ⇒ PipfilePreparer
constructor
A new instance of PipfilePreparer.
- #replace_sources(credentials) ⇒ Object
- #update_python_requirement(requirement) ⇒ Object
Constructor Details
#initialize(pipfile_content:) ⇒ PipfilePreparer
Returns a new instance of PipfilePreparer.
15 16 17 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 15 def initialize(pipfile_content:) @pipfile_content = pipfile_content end |
Instance Method Details
#replace_sources(credentials) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 19 def replace_sources(credentials) pipfile_object = TomlRB.parse(pipfile_content) pipfile_object["source"] = pipfile_sources.filter_map { |h| sub_auth_url(h, credentials) } + config_variable_sources(credentials) TomlRB.dump(pipfile_object) end |
#update_python_requirement(requirement) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 29 def update_python_requirement(requirement) pipfile_object = TomlRB.parse(pipfile_content) pipfile_object["requires"] ||= {} if pipfile_object.dig("requires", "python_full_version") && pipfile_object.dig("requires", "python_version") pipfile_object["requires"].delete("python_full_version") elsif pipfile_object.dig("requires", "python_full_version") pipfile_object["requires"].delete("python_full_version") pipfile_object["requires"]["python_version"] = requirement end TomlRB.dump(pipfile_object) end |