zypper-upgraderepo 1.8.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d116f5a4bc48c8b1da11927d247371609f1e4c8677f28639b1c116443291c572
4
- data.tar.gz: 9e2453092548ec2c01d07470ccbc7f0a25e6453dff4562f01875c84cab88372c
3
+ metadata.gz: 32ebc8e9633b6f8316573b56759c1044bd9db702cd4a2289508665420935e054
4
+ data.tar.gz: 89effc0e8a22e7f1019a2ac29337e5882b518f1c0de9dc7844b72cac0fa36608
5
5
  SHA512:
6
- metadata.gz: e4ffc00d5bea5c8db5c08462484e05828cb39a8bd872c968aa4df94f2d090d54002819e263b1a073727d0ac72c9a8f07c8c7c155eedbb0776ba601affa7ea1c0
7
- data.tar.gz: cf3c277471a5f2e90ff213cc0bd0017da3a766d22b6e9ba9b0dcfaf0decc7154fa13697111219bf24a7211b7e70e7a1974c578903037f1254470ad75479b5d3e
6
+ metadata.gz: 36dcbddb43e6ec7ede6aace2f03f2ed2be72c0e870c54252cbeec70c0715daf91d88bd3868e9936b3f60d77ced08df655987428fcc13bb15d3fc094913e8ee47
7
+ data.tar.gz: 10bb399234182d2705e9e498891d67c3727a5f4de68ef40166451e3e9dfd4275cb3fe788fa83254917172f18baf7921d5909c7331a659c9d7e4104ed066f6ebf
data/.rubocop.yml ADDED
@@ -0,0 +1,80 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Style/ClassVars:
7
+ Enabled: false
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ Enabled: true
15
+ EnforcedStyle: double_quotes
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+
20
+ Naming/FileName:
21
+ Enabled: false
22
+
23
+ Metrics/MethodLength:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Enabled: false
28
+
29
+ Lint/DuplicateBranch:
30
+ Enabled: false
31
+
32
+ Metrics/ClassLength:
33
+ Enabled: true
34
+ Exclude:
35
+ - './lib/**/cli.rb'
36
+ - './lib/**/repository.rb'
37
+ - './lib/**/upgraderepo.rb'
38
+
39
+ Metrics/BlockLength:
40
+ Enabled: true
41
+ Exclude:
42
+ - '*.gemspec'
43
+ - './lib/**/cli.rb'
44
+ - './lib/**/repository.rb'
45
+ - './spec/**/*'
46
+
47
+ Metrics/PerceivedComplexity:
48
+ Enabled: true
49
+ Exclude:
50
+ - './lib/**/upgraderepo.rb'
51
+ - './lib/**/repository.rb'
52
+ - './lib/**/view.rb'
53
+ - './lib/**/traversable.rb'
54
+
55
+ Metrics/CyclomaticComplexity:
56
+ Enabled: true
57
+ Exclude:
58
+ - './lib/**/upgraderepo.rb'
59
+ - './lib/**/repository.rb'
60
+ - './lib/**/view.rb'
61
+ - './lib/**/traversable.rb'
62
+
63
+ Lint/UriEscapeUnescape:
64
+ Enabled: false
65
+
66
+ Lint/UnusedMethodArgument:
67
+ Enabled: true
68
+ Exclude:
69
+ - './lib/**/local.rb'
70
+
71
+ Style/MixinUsage:
72
+ Enabled: true
73
+ Exclude:
74
+ - './spec/**/*'
75
+
76
+ Style/FrozenStringLiteralComment:
77
+ Enabled: true
78
+ Exclude:
79
+ - './bin/*'
80
+ - './exe/*'
data/Gemfile CHANGED
@@ -1,6 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in zypper-upgraderepo.gemspec
6
8
  gemspec
9
+
10
+ gem "rake", "~> 13.0"
11
+
12
+ gem "rspec", "~> 3.0"
13
+
14
+ gem "rubocop", "~> 1.21"
15
+
16
+ gem "rubocop-rake", "~> 0.6.0"
17
+
18
+ gem "rubocop-rspec", "~> 2.18"
data/Gemfile.lock CHANGED
@@ -1,30 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zypper-upgraderepo (1.8.0)
4
+ zypper-upgraderepo (1.10.0)
5
5
  iniparse
6
6
  minitar
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- diff-lcs (1.5.0)
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.1)
12
13
  iniparse (1.5.0)
14
+ json (2.7.2)
13
15
  minitar (0.9)
14
- rake (13.0.6)
15
- rspec (3.12.0)
16
- rspec-core (~> 3.12.0)
17
- rspec-expectations (~> 3.12.0)
18
- rspec-mocks (~> 3.12.0)
19
- rspec-core (3.12.0)
20
- rspec-support (~> 3.12.0)
21
- rspec-expectations (3.12.2)
16
+ parallel (1.24.0)
17
+ parser (3.3.2.0)
18
+ ast (~> 2.4.1)
19
+ racc
20
+ racc (1.8.0)
21
+ rainbow (3.1.1)
22
+ rake (13.2.1)
23
+ regexp_parser (2.9.2)
24
+ rexml (3.3.0)
25
+ strscan
26
+ rspec (3.13.0)
27
+ rspec-core (~> 3.13.0)
28
+ rspec-expectations (~> 3.13.0)
29
+ rspec-mocks (~> 3.13.0)
30
+ rspec-core (3.13.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-expectations (3.13.0)
22
33
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.12.0)
24
- rspec-mocks (3.12.3)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-mocks (3.13.1)
25
36
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.12.0)
27
- rspec-support (3.12.0)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-support (3.13.1)
39
+ rubocop (1.50.2)
40
+ json (~> 2.3)
41
+ parallel (~> 1.10)
42
+ parser (>= 3.2.0.0)
43
+ rainbow (>= 2.2.2, < 4.0)
44
+ regexp_parser (>= 1.8, < 3.0)
45
+ rexml (>= 3.2.5, < 4.0)
46
+ rubocop-ast (>= 1.28.0, < 2.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 2.4.0, < 3.0)
49
+ rubocop-ast (1.30.0)
50
+ parser (>= 3.2.1.0)
51
+ rubocop-capybara (2.18.0)
52
+ rubocop (~> 1.41)
53
+ rubocop-rake (0.6.0)
54
+ rubocop (~> 1.0)
55
+ rubocop-rspec (2.20.0)
56
+ rubocop (~> 1.33)
57
+ rubocop-capybara (~> 2.17)
58
+ ruby-progressbar (1.13.0)
59
+ strscan (3.1.0)
60
+ unicode-display_width (2.5.0)
28
61
 
29
62
  PLATFORMS
30
63
  ruby
@@ -33,6 +66,9 @@ DEPENDENCIES
33
66
  bundler (~> 2.0)
34
67
  rake (~> 13.0)
35
68
  rspec (~> 3.0)
69
+ rubocop (~> 1.21)
70
+ rubocop-rake (~> 0.6.0)
71
+ rubocop-rspec (~> 2.18)
36
72
  zypper-upgraderepo!
37
73
 
38
74
  BUNDLED WITH
data/README.md CHANGED
@@ -6,6 +6,9 @@ when possible.
6
6
 
7
7
  It can be also be installed as Zypper plugin using the [Zypper Upgraderepo Plugin][zypper_upgraderepo_plugin].
8
8
 
9
+ [![Ruby](https://github.com/fabiomux/zypper-upgraderepo/actions/workflows/main.yml/badge.svg)][wf_main]
10
+ [![Gem Version](https://badge.fury.io/rb/zypper-upgraderepo.svg)][gem_version]
11
+
9
12
  ## Installation
10
13
 
11
14
  There are a couple of options to install this application.
@@ -69,3 +72,5 @@ More info is available at:
69
72
  [project_page]: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html "Zypper-Upgraderepo project page"
70
73
  [zypper_upgraderepo_wiki]: https://github.com/fabiomux/zypper-upgraderepo/wiki "Zypper-Upgraderepo wiki page on GitHub"
71
74
  [upgrading_with_zypper]: https://freeaptitude.altervista.org/articles/upgrading-opensuse-with-zypper.html "Upgrading openSUSE with Zypper"
75
+ [wf_main]: https://github.com/fabiomux/zypper-upgraderepo/actions/workflows/main.yml
76
+ [gem_version]: https://badge.fury.io/rb/zypper-upgraderepo
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -1,25 +1,33 @@
1
- require 'optparse'
2
- require 'ostruct'
3
- require 'zypper/upgraderepo'
4
- require 'zypper/upgraderepo/version'
1
+ # frozen_string_literal: true
5
2
 
6
- module Zypper
3
+ require "optparse"
4
+ require "zypper/upgraderepo"
5
+ require "zypper/upgraderepo/version"
7
6
 
7
+ module Zypper
8
8
  module Upgraderepo
9
-
9
+ CliOptions = Struct.new(
10
+ :operation, :backup_path, :only_enabled, :alias, :name, :hint,
11
+ :overrides, :version, :sorting_by, :view, :only_repo, :timeout,
12
+ :exit_on_fail, :overrides_filename, :only_invalid, :only_protocols,
13
+ :allow_unstable
14
+ )
15
+
16
+ #
17
+ # Parsing the input data.
18
+ #
10
19
  class OptParseMain
11
-
12
- def self.parse(args)
13
- options = OpenStruct.new
20
+ def self.parse(_args)
21
+ options = CliOptions.new
14
22
  options.operation = :check_current
15
- options.backup_path = ENV['HOME']
23
+ options.backup_path = Dir.home
16
24
  options.only_enabled = false
17
25
  options.alias = true
18
26
  options.name = true
19
27
  options.hint = true
20
28
  options.overrides = {}
21
29
  options.version = nil
22
- options.sort_by = :alias
30
+ options.sorting_by = :alias
23
31
  options.view = :table
24
32
  options.only_repo = nil
25
33
  options.timeout = 10.0
@@ -30,187 +38,197 @@ module Zypper
30
38
  options.allow_unstable = false
31
39
 
32
40
  opt_parser = OptionParser.new do |opt|
41
+ opt.banner = if ENV["ZYPPER_UPGRADEREPO"]
42
+ "Usage: zypper upgraderepo [OPTIONS] [OPERATION]"
43
+ else
44
+ "Usage: upgraderepo [OPTIONS] [OPERATION]"
45
+ end
33
46
 
34
- if ENV['ZYPPER_UPGRADEREPO']
35
- opt.banner = 'Usage: zypper upgraderepo [OPTIONS] [OPERATION]'
36
- else
37
- opt.banner = 'Usage: upgraderepo [OPTIONS] [OPERATION]'
38
- end
39
-
40
- opt.separator ''
41
- opt.separator 'Operations:'
47
+ opt.separator ""
48
+ opt.separator "Operations:"
42
49
 
43
- opt.on('-b', '--backup <PATH>', 'Create a Tar backup of all the repositories under PATH') do |o|
50
+ opt.on("-b", "--backup <PATH>", "Create a Tar backup of all the repositories under PATH") do |o|
44
51
  options.operation = :backup
45
52
  options.only_enabled = false
46
53
  options.backup_path = o
47
54
  end
48
55
 
49
- opt.on('-c', '--check-current', 'Check the repositories for the current version (Default)') do |o|
56
+ opt.on("-c", "--check-current", "Check the repositories for the current version (Default)") do |_o|
50
57
  options.operation = :check_current
51
58
  end
52
59
 
53
- opt.on('-n', '--check-next', 'Check the repositories for the next version') do |o|
60
+ opt.on("-n", "--check-next", "Check the repositories for the next version") do |_o|
54
61
  options.operation = :check_next
55
62
  end
56
63
 
57
- opt.on('-C', '--check-for <VERSION>', 'Check for a custom VERSION') do |v|
64
+ opt.on("-C", "--check-for <VERSION>", "Check for a custom VERSION") do |v|
58
65
  options.version = v
59
66
  options.operation = :check_for
60
67
  end
61
68
 
62
- opt.on('-l', '--check-last', 'Check the repositories for the last version') do |o|
69
+ opt.on("-l", "--check-last", "Check the repositories for the last version") do |_o|
63
70
  options.operation = :check_last
64
71
  end
65
72
 
66
- opt.on('-R', '--reset', 'Reset the repositories to the current OS version.') do |v|
73
+ opt.on("-R", "--reset", "Reset the repositories to the current OS version.") do |_v|
67
74
  options.operation = :reset
68
75
  end
69
76
 
70
- opt.on('-t', '--update', 'Update the repositories to the current OS version') do |v|
77
+ opt.on("-t", "--update", "Update the repositories to the current OS version") do |_v|
71
78
  options.operation = :update
72
79
  end
73
80
 
74
- opt.on('-u', '--upgrade', 'Upgrade to the next version available') do |o|
81
+ opt.on("-u", "--upgrade", "Upgrade to the next version available") do |_o|
75
82
  options.operation = :upgrade_to_next
76
83
  end
77
84
 
78
- opt.on('-U', '--upgrade-to <VERSION>', 'Upgrade to a specific VERSION') do |v|
85
+ opt.on("-U", "--upgrade-to <VERSION>", "Upgrade to a specific VERSION") do |v|
79
86
  options.version = v
80
87
  options.operation = :upgrade_to
81
88
  end
82
89
 
83
- opt.on('-L', '--upgrade-to-last', 'Upgrade to the last version available') do |o|
90
+ opt.on("-L", "--upgrade-to-last", "Upgrade to the last version available") do |_o|
84
91
  options.operation = :upgrade_to_last
85
92
  end
86
93
 
87
- opt.on('-s', '--status', 'Prints the version status of the current and available releases') do |o|
94
+ opt.on("-s", "--status", "Prints the version status of the current and available releases") do |_o|
88
95
  options.operation = :status
89
96
  end
90
97
 
91
- opt.separator ''
92
- opt.separator 'Options:'
98
+ opt.on("-d", "--duplicates", "Detect the duplicates comparing the URL addresses") do |_o|
99
+ options.operation = :duplicates
100
+ end
93
101
 
94
- opt.on('--allow-unstable', 'Consider the unstable version as a valid release version') do |o|
102
+ opt.on("-z", "--unused", "Prints the unused repositories with zero packages installed") do |_o|
103
+ options.operation = :unused
104
+ end
105
+
106
+ opt.separator ""
107
+ opt.separator "Options:"
108
+
109
+ opt.on("--allow-unstable", "Consider the unstable version as a valid release version") do |_o|
95
110
  options.allow_unstable = true
96
111
  end
97
112
 
98
- opt.on('--no-name', 'Don\'t upgrade the name') do |o|
113
+ opt.on("--no-name", "Don't upgrade the name") do |_o|
99
114
  options.name = false
100
115
  end
101
116
 
102
- opt.on('--no-alias', 'Don\'t upgrade the alias') do |o|
117
+ opt.on("--no-alias", "Don't upgrade the alias") do |_o|
103
118
  options.alias = false
104
119
  end
105
120
 
106
- opt.on('--no-hint', 'Don\'t find a working URL when the current is invalid') do |o|
121
+ opt.on("--no-hint", "Don't find a working URL when the current is not valid") do |_o|
107
122
  options.hint = false
108
123
  end
109
124
 
110
- opt.on('--override-url <NUMBER>,<URL>', Array, 'Overwrite the repository NUMBER with URL') do |r|
125
+ opt.on("--override-url <NUMBER>,<URL>", Array, "Overwrite the repository NUMBER with URL") do |r|
111
126
  options.overrides[r[0].to_i] = r[1]
112
127
  end
113
128
 
114
- opt.on('--load-overrides <FILENAME>', 'Check the URLs in the exported FILENAME') do |f|
129
+ opt.on("--load-overrides <FILENAME>", "Load the repositories' overrides from FILENAME") do |f|
115
130
  options.overrides_filename = f
116
131
  end
117
132
 
118
- opt.on('--exit-on-fail', 'Exit with error when a repository upgrade check fails') do |o|
133
+ opt.on("--exit-on-fail", "Exit with error when a repository upgrade check fails") do |_o|
119
134
  options.exit_on_fail = true
120
135
  end
121
136
 
122
- opt.on('--timeout <SECONDS>', "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{options.timeout})") do |o|
137
+ opt.on("--timeout <SECONDS>",
138
+ "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{options.timeout})") do |o|
123
139
  options.timeout = o.to_f
124
140
  end
125
141
 
126
- opt.separator ''
127
- opt.separator 'Filter options:'
142
+ opt.separator ""
143
+ opt.separator "Filter options:"
128
144
 
129
- opt.on('--only-enabled', 'Include only the enabled repositories') do |o|
145
+ opt.on("--only-enabled", "Include only the enabled repositories") do |_o|
130
146
  options.only_enabled = true
131
147
  end
132
148
 
133
- opt.on('--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]', 'Include only the repositories specified by a NUMBER or a string matching the NAME, @ALIAS, #URL, or &ANY of them') do |o|
134
- options.only_repo = o.split(',')
149
+ opt.on("--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]",
150
+ "Include only the repositories specified by a NUMBER or a string matching the NAME, " \
151
+ "@ALIAS, #URL, or &ANY of them") do |o|
152
+ options.only_repo = o.split(",")
135
153
  end
136
154
 
137
- opt.on('--only-invalid', 'Show only invalid repositories') do |o|
155
+ opt.on("--only-invalid", "Show only invalid repositories") do |_o|
138
156
  options.only_invalid = true
139
157
  end
140
158
 
141
- opt.on('--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]', Array, "Show only from protocols (supported: #{Request.protocols.join(',')})") do |o|
159
+ opt.on("--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]", Array,
160
+ "Show only from protocols (supported: #{Request.protocols.join(",")})") do |o|
142
161
  options.only_protocols = o
143
162
  end
144
163
 
145
- opt.separator ''
146
- opt.separator 'View options:'
164
+ opt.separator ""
165
+ opt.separator "View options:"
147
166
 
148
- opt.on('--sort-by-alias', 'Sort repositories by alias (Default)') do |o|
149
- options.sort_by = :alias
167
+ opt.on("--sort-by-alias", "Sort the repositories by alias (Default)") do |_o|
168
+ options.sorting_by = :alias
150
169
  end
151
170
 
152
- opt.on('--sort-by-name', 'Sort repositories by name') do |o|
153
- options.sort_by = :name
171
+ opt.on("--sort-by-name", "Sort the repositories by name") do |_o|
172
+ options.sorting_by = :name
154
173
  end
155
174
 
156
- opt.on('--sort-by-priority', 'Sort repositories by priority') do |o|
157
- options.sort_by = :priority
175
+ opt.on("--sort-by-priority", "Sort the repositories by priority") do |_o|
176
+ options.sorting_by = :priority
158
177
  end
159
178
 
160
- opt.on('--ini', 'Output the result as INI format') do |o|
179
+ opt.on("--ini", "Output the result in the INI format") do |_o|
161
180
  options.view = :ini
162
181
  end
163
182
 
164
- opt.on('--quiet', 'Quiet mode, show only error messages') do |o|
183
+ opt.on("--quiet", "Quiet mode, show only error messages") do |_o|
165
184
  options.view = :quiet
166
185
  end
167
186
 
168
- opt.on('--report', 'View the data as report') do |o|
187
+ opt.on("--report", "View the data as a report") do |_o|
169
188
  options.view = :report
170
189
  end
171
190
 
172
- opt.on('--solved', 'Output as INI with the suggestions for the invalid repositories applied') do |o|
191
+ opt.on("--solved", "Output as INI and the URLs' suggestions applied") do |_o|
173
192
  options.view = :solved
174
193
  end
175
194
 
176
- unless ENV['ZYPPER_UPGRADEREPO']
177
- opt.separator ''
178
- opt.separator 'Other:'
195
+ unless ENV["ZYPPER_UPGRADEREPO"]
196
+ opt.separator ""
197
+ opt.separator "Other:"
179
198
 
180
- opt.on_tail('-h', '--help', 'Show this message') do |o|
199
+ opt.on_tail("-h", "--help", "Show this message") do |_o|
181
200
  puts opt
182
201
  exit
183
202
  end
184
203
 
185
- opt.on_tail('-v', '--version', 'Show version') do |o|
204
+ opt.on_tail("-v", "--version", "Show the version") do |_o|
186
205
  puts VERSION
187
206
  exit
188
207
  end
189
208
  end
190
-
191
209
  end
192
210
 
193
211
  if ARGV.empty?
194
- puts opt_parser; exit
212
+ puts opt_parser
213
+ exit
195
214
  else
196
215
  opt_parser.parse!(ARGV)
197
216
  end
198
217
 
199
218
  options
200
219
  end
201
-
202
220
  end
203
221
 
204
-
222
+ #
223
+ # Interface class to run the application.
224
+ #
205
225
  class CLI
206
226
  def self.start
207
- begin
208
- options = OptParseMain.parse(ARGV)
209
- Upgraderepo::Builder.new(options).send(options.operation)
210
- rescue => e
211
- Messages.error e
212
- exit e.error_code
213
- end
227
+ options = OptParseMain.parse(ARGV)
228
+ Upgraderepo::Builder.new(options).send(options.operation)
229
+ rescue StandardError => e
230
+ Messages.error e
231
+ exit e.error_code
214
232
  end
215
233
  end
216
234
  end
@@ -1,25 +1,29 @@
1
- require 'iniparse'
1
+ # frozen_string_literal: true
2
+
3
+ require "iniparse"
2
4
 
3
5
  module Zypper
4
6
  module Upgraderepo
5
-
6
-
7
+ #
8
+ # Detect the current and next release.
9
+ #
7
10
  class OsRelease
8
-
9
11
  attr_reader :custom, :unstable
10
12
 
11
- OS_VERSIONS = ['13.1', '13.2', '42.1', '42.2', '42.3', '15.0', '15.1', '15.2', '15.3', '15.4', '15.5']
13
+ OS_VERSIONS = ["13.1", "13.2",
14
+ "42.1", "42.2", "42.3",
15
+ "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6"].freeze
12
16
 
13
- UNSTABLE_VERSION = '15.6'
17
+ UNSTABLE_VERSION = "16.0"
14
18
 
15
- OS_RELEASE_FILE = '/etc/os-release'
19
+ OS_RELEASE_FILE = "/etc/os-release"
16
20
 
17
- SUSE_RELEASE_FILE = '/etc/SuSE-release'
21
+ SUSE_RELEASE_FILE = "/etc/SuSE-release"
18
22
 
19
23
  def initialize(options)
20
-
21
24
  if options.allow_unstable
22
25
  raise NoUnstableVersionAvailable if UNSTABLE_VERSION.empty?
26
+
23
27
  OS_VERSIONS << UNSTABLE_VERSION
24
28
  @unstable = true
25
29
  end
@@ -32,12 +36,12 @@ module Zypper
32
36
  raise ReleaseFileNotFound
33
37
  end
34
38
  @release = IniParse.parse(File.read(fname))
35
- @current_idx = OS_VERSIONS.index(@release['__anonymous__']['VERSION'].delete('"'))
39
+ @current_idx = OS_VERSIONS.index(@release["__anonymous__"]["VERSION"].delete('"'))
36
40
 
37
- if options.version
38
- raise InvalidVersion, options.version unless OS_VERSIONS.include?(options.version)
39
- @custom = options.version
40
- end
41
+ return unless options.version
42
+ raise InvalidVersion, options.version unless OS_VERSIONS.include?(options.version)
43
+
44
+ @custom = options.version
41
45
  end
42
46
 
43
47
  def current
@@ -49,23 +53,19 @@ module Zypper
49
53
  end
50
54
 
51
55
  def next
52
- unless last?
53
- OS_VERSIONS[@current_idx.next]
54
- else
55
- nil
56
- end
56
+ return if last?
57
+
58
+ OS_VERSIONS[@current_idx.next]
57
59
  end
58
60
 
59
61
  def previous
60
- unless first?
61
- OS_VERSIONS[@current_idx.pred]
62
- else
63
- nil
64
- end
62
+ return if first?
63
+
64
+ OS_VERSIONS[@current_idx.pred]
65
65
  end
66
66
 
67
67
  def fullname
68
- @release['__anonymous__']['PRETTY_NAME'].gsub(/"/, '')
68
+ @release["__anonymous__"]["PRETTY_NAME"].gsub(/"/, "")
69
69
  end
70
70
 
71
71
  def seniority
@@ -73,7 +73,7 @@ module Zypper
73
73
  end
74
74
 
75
75
  def newer
76
- if seniority > 0
76
+ if seniority.positive?
77
77
  OS_VERSIONS[@current_idx.next..-1]
78
78
  else
79
79
  []
@@ -85,7 +85,7 @@ module Zypper
85
85
  end
86
86
 
87
87
  def first?
88
- @current_idx == 0
88
+ @current_idx.zero?
89
89
  end
90
90
 
91
91
  def valid?(version)
@@ -96,7 +96,5 @@ module Zypper
96
96
  OS_VERSIONS.index(version) == @current_idx
97
97
  end
98
98
  end
99
-
100
-
101
99
  end
102
100
  end