Class: Dependabot::Python::FileUpdater::PipfilePreparer
- Inherits:
-
Object
- Object
- Dependabot::Python::FileUpdater::PipfilePreparer
- Extended by:
- T::Sig
- 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
- #update_ssl_requirement(parsed_file) ⇒ Object
Constructor Details
#initialize(pipfile_content:) ⇒ PipfilePreparer
19 20 21 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 19 def initialize(pipfile_content:) @pipfile_content = pipfile_content end |
Instance Method Details
#replace_sources(credentials) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 24 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
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 35 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 |
#update_ssl_requirement(parsed_file) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dependabot/python/file_updater/pipfile_preparer.rb', line 49 def update_ssl_requirement(parsed_file) pipfile_object = TomlRB.parse(pipfile_content) parsed_object = TomlRB.parse(parsed_file) raise DependencyFileNotResolvable, "Unable to resolve pipfile." unless parsed_object["source"] # we parse the verify_ssl value from manifest if it exists verify_ssl = parsed_object["source"].map { |x| x["verify_ssl"] }.first # provide a default "true" value to file generator in case no value is provided in manifest file pipfile_object["source"].each do |key| key["verify_ssl"] = verify_ssl.nil? || verify_ssl end TomlRB.dump(pipfile_object) end |