diff options
| author | Mike McQuaid | 2016-08-18 12:52:25 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-08-18 15:04:51 +0100 |
| commit | 55ba22e2965a364d17a82796158357b2c6ee6ff2 (patch) | |
| tree | 331c88455c8a8f879c5fb459dc0de495623ba612 /Library/Homebrew/formula_versions.rb | |
| parent | cc2a90ec8d4dc8b26a7658f4424cf6949d0bf4cb (diff) | |
| download | brew-55ba22e2965a364d17a82796158357b2c6ee6ff2.tar.bz2 | |
formula_versions: add version_attributes_map.
This allows querying multiple attributes in the same way as
`revision_map` did but without duplicating code or repeatedly traversing
history.
Diffstat (limited to 'Library/Homebrew/formula_versions.rb')
| -rw-r--r-- | Library/Homebrew/formula_versions.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 13cb8ac8c..2c5aae8f5 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -60,14 +60,22 @@ class FormulaVersions map end - def revision_map(branch) - map = Hash.new { |h, k| h[k] = [] } + def version_attributes_map(attributes, branch) + attributes_map = {} + return attributes_map if attributes.empty? + attributes.each do |attribute| + attributes_map[attribute] = Hash.new { |h, k| h[k] = [] } + end + rev_list(branch) do |rev| formula_at_revision(rev) do |f| - map[f.stable.version] << f.revision if f.stable - map[f.devel.version] << f.revision if f.devel + attributes.each do |attribute| + map = attributes_map[attribute] + map[f.stable.version] << f.send(attribute) if f.stable + map[f.devel.version] << f.send(attribute) if f.devel + end end end - map + attributes_map end end |
