Class: Zypper::Upgraderepo::RepositoryList
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::RepositoryList
- Defined in:
- lib/zypper/upgraderepo/repository.rb
Overview
Handle the repository collection.
Constant Summary collapse
- REPOSITORY_PATH =
"/etc/zypp/repos.d"
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#max_col ⇒ Object
readonly
Returns the value of attribute max_col.
Instance Method Summary collapse
- #each_with_number(options = {}) ⇒ Object
-
#initialize(options, variables) ⇒ RepositoryList
constructor
A new instance of RepositoryList.
- #only_enabled? ⇒ Boolean
- #save ⇒ Object
- #upgrade!(version) ⇒ Object
Constructor Details
#initialize(options, variables) ⇒ RepositoryList
Returns a new instance of RepositoryList.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zypper/upgraderepo/repository.rb', line 48 def initialize(, variables) @alias = .alias @name = .name @only_repo = .only_repo @only_enabled = .only_enabled @only_invalid = .only_invalid @only_protocols = .only_protocols @overrides = .overrides @upgrade_options = { alias: .alias, name: .name } @list = [] @variables = variables Dir.glob(File.join(self.class::REPOSITORY_PATH, "*.repo")).each do |i| r = Request.build(Repository.new(i, @variables), .timeout) @list << r end @max_col = @list.max_by { |r| r.name.length }.name.length @list = @list.sort_by(&:alias).map.with_index(1) { |r, i| { num: i, repo: r } } @list.sort_by! { |x| x[:repo].send(.sorting_by) } if .sorting_by != :alias @only_repo = select_repos(@only_repo) unless @only_repo.nil? load_overrides(.overrides_filename) if .overrides_filename end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
46 47 48 |
# File 'lib/zypper/upgraderepo/repository.rb', line 46 def list @list end |
#max_col ⇒ Object (readonly)
Returns the value of attribute max_col.
46 47 48 |
# File 'lib/zypper/upgraderepo/repository.rb', line 46 def max_col @max_col end |
Instance Method Details
#each_with_number(options = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/zypper/upgraderepo/repository.rb', line 86 def each_with_number( = {}) only_repo = [:only_repo].nil? ? @only_repo : [:only_repo] only_enabled = [:only_enabled].nil? ? @only_enabled : [:only_enabled] only_invalid = [:only_invalid].nil? ? @only_invalid : [:only_invalid] only_protocols = [:only_protocols].nil? ? @only_protocols : [:only_protocols] @list.each do |x| next if only_repo && !only_repo.include?(x[:num]) next if only_enabled && !x[:repo].enabled? next if only_invalid && x[:repo].available? next if only_protocols && !only_protocols.include?(x[:repo].protocol) yield x[:repo], x[:num] if block_given? end end |
#only_enabled? ⇒ Boolean
75 76 77 |
# File 'lib/zypper/upgraderepo/repository.rb', line 75 def only_enabled? @only_enabled end |
#save ⇒ Object
102 103 104 105 106 |
# File 'lib/zypper/upgraderepo/repository.rb', line 102 def save @list.each do |i| i[:repo].save end end |
#upgrade!(version) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/zypper/upgraderepo/repository.rb', line 79 def upgrade!(version) each_with_number(only_invalid: false) do |repo, num| repo.upgrade! version, @upgrade_options.merge(url_override: @overrides[num]) repo.cache! end end |