Module: Katello::SyncManagementHelper::RepoMethods

Included in:
ProvidersHelper, Katello::SyncManagementController
Defined in:
app/helpers/katello/sync_management_helper.rb

Instance Method Summary collapse

Instance Method Details

#arches(arch_repos) ⇒ Object

returns all archs in hash representation



55
56
57
58
59
# File 'app/helpers/katello/sync_management_helper.rb', line 55

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>]}


78
79
80
# File 'app/helpers/katello/sync_management_helper.rb', line 78

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>]]


68
69
70
71
72
# File 'app/helpers/katello/sync_management_helper.rb', line 68

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



37
38
39
40
41
42
43
44
45
# File 'app/helpers/katello/sync_management_helper.rb', line 37

def collect_repos(products, env, include_feedless = true)
  Glue::Pulp::Repos.prepopulate! products, env, []

  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



48
49
50
51
52
# File 'app/helpers/katello/sync_management_helper.rb', line 48

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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/helpers/katello/sync_management_helper.rb', line 83

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