Module: Katello::SyncManagementHelper::RepoMethods
- Included in:
- Katello::SyncManagementController
- Defined in:
- app/helpers/katello/sync_management_helper.rb
Instance Method Summary collapse
-
#arches(arch_repos) ⇒ Object
returns all archs in hash representation.
-
#collect_arches(repos) ⇒ Object
converts array of repositories to hash using architecture as key.
-
#collect_minor(repos) ⇒ Object
converts array of repositories to hash using minor as key.
-
#collect_repos(products, env, include_feedless = true) ⇒ Object
returns all repos in hash representation with minors and arch children included.
-
#minors(minor_repos) ⇒ Object
returns all minors in hash representation with arch children included.
-
#pprint_collection(coll) ⇒ Object
Used for debugging collect_repos output.
Instance Method Details
#arches(arch_repos) ⇒ Object
returns all archs in hash representation
49 50 51 52 53 |
# File 'app/helpers/katello/sync_management_helper.rb', line 49 def arches(arch_repos) collect_arches(arch_repos).map do |arch, repos| { :name => arch, :id => arch, :type => "arch", :children => [], :repos => repos } end end |
#collect_arches(repos) ⇒ Object
converts array of repositories to hash using architecture as key
collect_arches [<#repo1 arch:i386>, <#repo2 arch:i386>, <#repo3 arch:x86_64>] # =>
{'i386' => [<#repo1>, <#repo2>], 'x86_64' => [#<repo3>]}
72 73 74 |
# File 'app/helpers/katello/sync_management_helper.rb', line 72 def collect_arches(repos) repos.group_by(&:arch) end |
#collect_minor(repos) ⇒ Object
converts array of repositories to hash using minor as key
repositories having nil minor are returned as a second variable, if none such is present, empty array is returned
collect_arches [<#repo1 minor:1>, <#repo2 minor:2>, <#repo3 minor:nil>] # =>
[{'1' => [<#repo1>], '2' => <#repo2>]}, [#<repo3>]]
62 63 64 65 66 |
# File 'app/helpers/katello/sync_management_helper.rb', line 62 def collect_minor(repos) result = repos.group_by(&:minor) result_without_minor = result.delete(nil) [result, result_without_minor || []] end |
#collect_repos(products, env, include_feedless = true) ⇒ Object
returns all repos in hash representation with minors and arch children included
33 34 35 36 37 38 39 |
# File 'app/helpers/katello/sync_management_helper.rb', line 33 def collect_repos(products, env, include_feedless = true) products.map do |prod| minor_repos, repos_without_minor = collect_minor(prod.repos(env, nil, include_feedless)) { :name => prod.name, :object => prod, :id => prod.id, :type => "product", :repos => repos_without_minor, :children => minors(minor_repos), :organization => prod.organization.name } end end |
#minors(minor_repos) ⇒ Object
returns all minors in hash representation with arch children included
42 43 44 45 46 |
# File 'app/helpers/katello/sync_management_helper.rb', line 42 def minors(minor_repos) minor_repos.map do |minor, repos| { :name => minor, :id => minor, :type => "minor", :children => arches(repos), :repos => [] } end end |
#pprint_collection(coll) ⇒ Object
Used for debugging collect_repos output
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/katello/sync_management_helper.rb', line 77 def pprint_collection(coll) coll.each do |prod| Rails.logger.error prod[:name] prod[:children].each do |major| Rails.logger.error major[:name] major[:children].each do |minor| Rails.logger.error minor[:name] minor[:children].each do |arch| Rails.logger.error arch[:repos].length end end end end end |