Class: Fig::FigRC
- Inherits:
-
Object
- Object
- Fig::FigRC
- Defined in:
- lib/fig/figrc.rb
Overview
Parse multiple figrc files and assemble them into a single ApplicationConfiguration object.
Constant Summary collapse
- REPOSITORY_CONFIGURATION =
"#{Fig::Repository::METADATA_SUBDIRECTORY}/figrc"
Class Method Summary collapse
Class Method Details
.find(override_path, download_repository_url, upload_repository_url, operating_system, fig_home, disable_figrc = false, disable_remote_figrc = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fig/figrc.rb', line 18 def self.find( override_path, download_repository_url, upload_repository_url, , fig_home, disable_figrc = false, disable_remote_figrc = false ) configuration = Fig::ApplicationConfiguration.new() handle_override_configuration(configuration, override_path) handle_figrc(configuration) if not disable_figrc # Check for legacy environment variable usage download_url = derive_repository_url(download_repository_url, 'DOWNLOAD', configuration) upload_url = derive_repository_url(upload_repository_url, 'UPLOAD', configuration) remote_url = ENV['FIG_REMOTE_URL'] has_download = !download_url.nil? && !download_url.strip.empty? has_upload = !upload_url.nil? && !upload_url.strip.empty? has_remote = !remote_url.nil? && !remote_url.strip.empty? # Error case: FIG_REMOTE_URL exists but one or both new URLs missing if has_remote && (!has_download || !has_upload) raise Fig::UserInputError.new( 'FIG_REMOTE_URL is set but FIG_DOWNLOAD_URL and/or FIG_UPLOAD_URL are missing. ' + 'Please set both FIG_DOWNLOAD_URL and FIG_UPLOAD_URL instead of FIG_REMOTE_URL.' ) end # Warning case: All three variables exist if has_remote && has_download && has_upload $stderr.puts "WARNING: FIG_REMOTE_URL is set but will be ignored. Using FIG_DOWNLOAD_URL and FIG_UPLOAD_URL instead." end # Set the new URL attributes configuration.remote_download_url = download_url configuration.remote_upload_url = upload_url # For backward compatibility with code expecting whitelisted URLs url_for_whitelist = has_download ? download_url : nil configuration.base_whitelisted_url = url_for_whitelist # Handle repository configuration if enabled if !disable_remote_figrc && has_download handle_repository_configuration( configuration, download_url, , fig_home ) end return configuration end |