Class: Dependabot::Conda::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::Conda::FileFetcher
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/conda/file_fetcher.rb
Constant Summary collapse
- ENVIRONMENT_FILE_NAMES =
T.let( %w( environment.yml environment.yaml ).freeze, T::Array[String] )
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
23 24 25 |
# File 'lib/dependabot/conda/file_fetcher.rb', line 23 def self.required_files_in?(filenames) filenames.any? { |filename| ENVIRONMENT_FILE_NAMES.include?(filename) } end |
.required_files_message ⇒ Object
28 29 30 |
# File 'lib/dependabot/conda/file_fetcher.rb', line 28 def self. "Repo must contain an environment.yml or environment.yaml file." end |
Instance Method Details
#fetch_files ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dependabot/conda/file_fetcher.rb', line 33 def fetch_files fetched_files = [] # Try to fetch environment.yml first, then environment.yaml environment_file = fetch_file_if_present("environment.yml") || fetch_file_if_present("environment.yaml") if environment_file # Validate it's a proper conda environment file validation = validate_conda_environment(environment_file) unless validation[:valid] raise( Dependabot::DependencyFileNotFound.new( File.join(directory, environment_file.name), (validation[:reason]) ) ) end fetched_files << environment_file end return fetched_files if fetched_files.any? raise( Dependabot::DependencyFileNotFound, File.join(directory, "environment.yml") ) end |