module Omnibus::Overrides
Constants
- DEFAULT_OVERRIDE_FILE_NAME
Public Class Methods
overrides()
click to toggle source
Return a hash of override information. If no such information can be found, the hash will be empty
@return [Hash]
# File lib/omnibus/overrides.rb, line 54 def self.overrides file = resolve_override_file overrides = parse_file(file) if overrides puts "********************************************************************************" puts "Using Overrides from #{Omnibus::Overrides.resolve_override_file}" pp overrides puts "********************************************************************************" end overrides || {} end
parse_file(file)
click to toggle source
Parses a file of override information into a Hash.
Each line of the file must be of the form
<package_name> <version>
where the two pieces of data are separated by whitespace.
@param file [String] the path to an overrides file @return [Hash, nil]
# File lib/omnibus/overrides.rb, line 19 def self.parse_file(file) if file File.readlines(file).inject({}) do |acc, line| info = line.split unless info.count == 2 raise ArgumentError, "Invalid overrides line: '#{line.chomp}'" end package, version = info if acc[package] raise ArgumentError, "Multiple overrides present for '#{package}' in overrides file #{file}!" end acc[package] = version acc end else nil end end
resolve_override_file()
click to toggle source
Return the full path to an overrides file, or nil
if no such file exists.
# File lib/omnibus/overrides.rb, line 44 def self.resolve_override_file file = ENV['OMNIBUS_OVERRIDE_FILE'] || DEFAULT_OVERRIDE_FILE_NAME path = File.expand_path(file) File.exist?(path) ? path : nil end