zypper-upgraderepo 1.8.0 → 1.9.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: 3a50f5e64f656b77d574d69068ef2663d9387e9607b1a8f4fa54e4428caf980d
4
- data.tar.gz: e0d52912c451b2d3fca3e230cbd601f1dde2ec8830ca2e7ebbee451b4f425844
3
+ metadata.gz: 7ceec1a1b9750d49b3c32863595d7b83c615dc140458a65a55dc93b115d5e3f3
4
+ data.tar.gz: 857477ddec8c0457e0082583a98a68de4ee62ebca1e4972a578fceb6ba74ca57
5
5
  SHA512:
6
- metadata.gz: 46fab3ffa2117323ca0fc13bf51dd6f699a7af3b949abfef30ebd57323c54659760846fd1e3ae33b711171e8fd6b8d9c2db970631c401b97031486c8c45e718f
7
- data.tar.gz: 576992e8186033757a0b5d6fc2cba6a9ac061c0862ceac78f9a799e7a7ab0135229dfd09f55334485a2bc919dd98d83bfe91d5936571e0daff0d152385deda68
6
+ metadata.gz: 490758a8241038010a130c18b97d926744e289d6fe82462647b2d7fe149143e2efbb78dafd1b50cf769cdcde3a3d31099da87743ac77990d4be8aa8017113e4f
7
+ data.tar.gz: 51731e28707401f36a825e34d06ecce3753bfd96fa03a14c35997a6113b1c62ddfd142b54df6d27d8f81863afb560964209a42f020e6ff2b693c1f201adc3d90
data/.rubocop.yml ADDED
@@ -0,0 +1,79 @@
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
+
38
+ Metrics/BlockLength:
39
+ Enabled: true
40
+ Exclude:
41
+ - '*.gemspec'
42
+ - './lib/**/cli.rb'
43
+ - './lib/**/repository.rb'
44
+ - './spec/**/*'
45
+
46
+ Metrics/PerceivedComplexity:
47
+ Enabled: true
48
+ Exclude:
49
+ - './lib/**/upgraderepo.rb'
50
+ - './lib/**/repository.rb'
51
+ - './lib/**/view.rb'
52
+ - './lib/**/traversable.rb'
53
+
54
+ Metrics/CyclomaticComplexity:
55
+ Enabled: true
56
+ Exclude:
57
+ - './lib/**/upgraderepo.rb'
58
+ - './lib/**/repository.rb'
59
+ - './lib/**/view.rb'
60
+ - './lib/**/traversable.rb'
61
+
62
+ Lint/UriEscapeUnescape:
63
+ Enabled: false
64
+
65
+ Lint/UnusedMethodArgument:
66
+ Enabled: true
67
+ Exclude:
68
+ - './lib/**/local.rb'
69
+
70
+ Style/MixinUsage:
71
+ Enabled: true
72
+ Exclude:
73
+ - './spec/**/*'
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: true
77
+ Exclude:
78
+ - './bin/*'
79
+ - './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.7.1)
4
+ zypper-upgraderepo (1.9.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,9 +6,12 @@ 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
- There are several options to install the service menus listed in this repository.
14
+ There are a couple of options to install this application.
12
15
 
13
16
  ### Rubygem
14
17
 
@@ -25,7 +28,7 @@ as a common RPM package:
25
28
  - install the package from Yast or Zypper.
26
29
 
27
30
  Being the repository URL slightly changing from a version to another, I included all the steps
28
- in the related [project page][project_page] on my blog.
31
+ in the related [project page][project_page] at my blog.
29
32
 
30
33
  ## Usage
31
34
 
@@ -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,189 @@ 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
47
+ opt.separator ""
48
+ opt.separator "Operations:"
39
49
 
40
- opt.separator ''
41
- opt.separator 'Operations:'
42
-
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.separator ""
99
+ opt.separator "Options:"
93
100
 
94
- opt.on('--allow-unstable', 'Consider the unstable version as a valid release version') do |o|
101
+ opt.on("--allow-unstable", "Consider the unstable version as a valid release version") do |_o|
95
102
  options.allow_unstable = true
96
103
  end
97
104
 
98
- opt.on('--no-name', 'Don\'t upgrade the name') do |o|
105
+ opt.on("--no-name", "Don't upgrade the name") do |_o|
99
106
  options.name = false
100
107
  end
101
108
 
102
- opt.on('--no-alias', 'Don\'t upgrade the alias') do |o|
109
+ opt.on("--no-alias", "Don't upgrade the alias") do |_o|
103
110
  options.alias = false
104
111
  end
105
112
 
106
- opt.on('--no-hint', 'Don\'t find a working URL when the current is invalid') do |o|
113
+ opt.on("--no-hint", "Don't find a working URL when the current is invalid") do |_o|
107
114
  options.hint = false
108
115
  end
109
116
 
110
- opt.on('--override-url <NUMBER>,<URL>', Array, 'Overwrite the repository NUMBER with URL') do |r|
117
+ opt.on("--override-url <NUMBER>,<URL>", Array, "Overwrite the repository NUMBER with URL") do |r|
111
118
  options.overrides[r[0].to_i] = r[1]
112
119
  end
113
120
 
114
- opt.on('--load-overrides <FILENAME>', 'Check the URLs in the exported FILENAME') do |f|
121
+ opt.on("--load-overrides <FILENAME>", "Check the URLs in the exported FILENAME") do |f|
115
122
  options.overrides_filename = f
116
123
  end
117
124
 
118
- opt.on('--exit-on-fail', 'Exit with error when a repository upgrade check fails') do |o|
125
+ opt.on("--exit-on-fail", "Exit with error when a repository upgrade check fails") do |_o|
119
126
  options.exit_on_fail = true
120
127
  end
121
128
 
122
- opt.on('--timeout <SECONDS>', "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{options.timeout})") do |o|
129
+ opt.on("--timeout <SECONDS>",
130
+ "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{options.timeout})") do |o|
123
131
  options.timeout = o.to_f
124
132
  end
125
133
 
126
- opt.separator ''
127
- opt.separator 'Filter options:'
134
+ opt.separator ""
135
+ opt.separator "Filter options:"
128
136
 
129
- opt.on('--only-enabled', 'Include only the enabled repositories') do |o|
137
+ opt.on("--only-enabled", "Include only the enabled repositories") do |_o|
130
138
  options.only_enabled = true
131
139
  end
132
140
 
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(',')
141
+ opt.on("--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]",
142
+ "Include only the repositories specified by a NUMBER or a string matching the NAME, " \
143
+ "@ALIAS, #URL, or &ANY of them") do |o|
144
+ options.only_repo = o.split(",")
135
145
  end
136
146
 
137
- opt.on('--only-invalid', 'Show only invalid repositories') do |o|
147
+ opt.on("--only-invalid", "Show only invalid repositories") do |_o|
138
148
  options.only_invalid = true
139
149
  end
140
150
 
141
- opt.on('--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]', Array, "Show only from protocols (supported: #{Request.protocols.join(',')})") do |o|
151
+ opt.on("--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]", Array,
152
+ "Show only from protocols (supported: #{Request.protocols.join(",")})") do |o|
142
153
  options.only_protocols = o
143
154
  end
144
155
 
145
- opt.separator ''
146
- opt.separator 'View options:'
156
+ opt.separator ""
157
+ opt.separator "View options:"
147
158
 
148
- opt.on('--sort-by-alias', 'Sort repositories by alias (Default)') do |o|
149
- options.sort_by = :alias
159
+ opt.on("--sort-by-alias", "Sort repositories by alias (Default)") do |_o|
160
+ options.sorting_by = :alias
150
161
  end
151
162
 
152
- opt.on('--sort-by-name', 'Sort repositories by name') do |o|
153
- options.sort_by = :name
163
+ opt.on("--sort-by-name", "Sort repositories by name") do |_o|
164
+ options.sorting_by = :name
154
165
  end
155
166
 
156
- opt.on('--sort-by-priority', 'Sort repositories by priority') do |o|
157
- options.sort_by = :priority
167
+ opt.on("--sort-by-priority", "Sort repositories by priority") do |_o|
168
+ options.sorting_by = :priority
158
169
  end
159
170
 
160
- opt.on('--ini', 'Output the result as INI format') do |o|
171
+ opt.on("--ini", "Output the result as INI format") do |_o|
161
172
  options.view = :ini
162
173
  end
163
174
 
164
- opt.on('--quiet', 'Quiet mode, show only error messages') do |o|
175
+ opt.on("--quiet", "Quiet mode, show only error messages") do |_o|
165
176
  options.view = :quiet
166
177
  end
167
178
 
168
- opt.on('--report', 'View the data as report') do |o|
179
+ opt.on("--report", "View the data as report") do |_o|
169
180
  options.view = :report
170
181
  end
171
182
 
172
- opt.on('--solved', 'Output as INI with the suggestions for the invalid repositories applied') do |o|
183
+ opt.on("--solved", "Output as INI with the suggestions for the invalid repositories applied") do |_o|
173
184
  options.view = :solved
174
185
  end
175
186
 
176
- unless ENV['ZYPPER_UPGRADEREPO']
177
- opt.separator ''
178
- opt.separator 'Other:'
187
+ unless ENV["ZYPPER_UPGRADEREPO"]
188
+ opt.separator ""
189
+ opt.separator "Other:"
179
190
 
180
- opt.on_tail('-h', '--help', 'Show this message') do |o|
191
+ opt.on_tail("-h", "--help", "Show this message") do |_o|
181
192
  puts opt
182
193
  exit
183
194
  end
184
195
 
185
- opt.on_tail('-v', '--version', 'Show version') do |o|
196
+ opt.on_tail("-v", "--version", "Show version") do |_o|
186
197
  puts VERSION
187
198
  exit
188
199
  end
189
200
  end
190
-
191
201
  end
192
202
 
193
203
  if ARGV.empty?
194
- puts opt_parser; exit
204
+ puts opt_parser
205
+ exit
195
206
  else
196
207
  opt_parser.parse!(ARGV)
197
208
  end
198
209
 
199
210
  options
200
211
  end
201
-
202
212
  end
203
213
 
204
-
214
+ #
215
+ # Interface class to run the application.
216
+ #
205
217
  class CLI
206
218
  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
219
+ options = OptParseMain.parse(ARGV)
220
+ Upgraderepo::Builder.new(options).send(options.operation)
221
+ rescue StandardError => e
222
+ Messages.error e
223
+ exit e.error_code
214
224
  end
215
225
  end
216
226
  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']
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.5'
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