kanrisuru 0.15.0 → 0.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/kanrisuru.gemspec +7 -3
  4. data/lib/kanrisuru/command.rb +6 -3
  5. data/lib/kanrisuru/core/disk/commands/lsblk.rb +6 -11
  6. data/lib/kanrisuru/core/disk/constants.rb +9 -0
  7. data/lib/kanrisuru/core/disk/parser.rb +1 -0
  8. data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
  9. data/lib/kanrisuru/core/disk.rb +1 -0
  10. data/lib/kanrisuru/core/dmi/commands/dmi.rb +1 -1
  11. data/lib/kanrisuru/core/file/commands/chmod.rb +1 -1
  12. data/lib/kanrisuru/core/file/commands/copy.rb +1 -3
  13. data/lib/kanrisuru/core/file/commands/mkdir.rb +11 -6
  14. data/lib/kanrisuru/core/file/commands/rm.rb +4 -1
  15. data/lib/kanrisuru/core/file/commands/touch.rb +2 -1
  16. data/lib/kanrisuru/core/system/commands/kill.rb +1 -1
  17. data/lib/kanrisuru/core/user/commands/create_user.rb +9 -17
  18. data/lib/kanrisuru/core/user/commands/delete_user.rb +1 -1
  19. data/lib/kanrisuru/core/user/commands/update_user.rb +14 -23
  20. data/lib/kanrisuru/core/zypper/commands/add_repo.rb +1 -8
  21. data/lib/kanrisuru/core/zypper/commands/add_service.rb +4 -2
  22. data/lib/kanrisuru/core/zypper/commands/info.rb +1 -2
  23. data/lib/kanrisuru/core/zypper/commands/install.rb +2 -3
  24. data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +1 -7
  25. data/lib/kanrisuru/core/zypper/commands/modify_service.rb +3 -1
  26. data/lib/kanrisuru/core/zypper/commands/remove.rb +1 -2
  27. data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +3 -3
  28. data/lib/kanrisuru/core/zypper/commands/remove_service.rb +6 -1
  29. data/lib/kanrisuru/core/zypper/commands/search.rb +1 -3
  30. data/lib/kanrisuru/core/zypper/commands/source_install.rb +2 -0
  31. data/lib/kanrisuru/core/zypper/commands.rb +10 -1
  32. data/lib/kanrisuru/mode/permission.rb +103 -0
  33. data/lib/kanrisuru/mode.rb +2 -98
  34. data/lib/kanrisuru/os_package.rb +2 -0
  35. data/lib/kanrisuru/remote/host.rb +1 -3
  36. data/lib/kanrisuru/result.rb +15 -0
  37. data/lib/kanrisuru/version.rb +1 -1
  38. data/spec/functional/core/archive_spec.rb +1 -1
  39. data/spec/functional/core/disk_spec.rb +77 -0
  40. data/spec/functional/core/dmi_spec.rb +78 -0
  41. data/spec/functional/core/file_spec.rb +284 -0
  42. data/spec/functional/core/group_spec.rb +62 -0
  43. data/spec/functional/core/{ip/ip_address_label_spec.rb → ip_address_label_spec.rb} +0 -0
  44. data/spec/functional/core/{ip/ip_address_spec.rb → ip_address_spec.rb} +0 -0
  45. data/spec/functional/core/{ip/ip_link_spec.rb → ip_link_spec.rb} +0 -0
  46. data/spec/functional/core/{ip/ip_maddress_spec.rb → ip_maddress_spec.rb} +0 -0
  47. data/spec/functional/core/{ip/ip_neighbour_spec.rb → ip_neighbour_spec.rb} +0 -0
  48. data/spec/functional/core/{ip/ip_route_spec.rb → ip_route_spec.rb} +0 -0
  49. data/spec/functional/core/{ip/ip_rule_spec.rb → ip_rule_spec.rb} +0 -0
  50. data/spec/functional/core/{ip/ip_spec.rb → ip_spec.rb} +0 -0
  51. data/spec/functional/core/system_spec.rb +135 -0
  52. data/spec/functional/core/user_spec.rb +97 -0
  53. data/spec/functional/core/zypper_spec.rb +708 -0
  54. data/spec/functional/result_spec.rb +91 -44
  55. data/spec/helper/stub_network.rb +7 -3
  56. data/spec/unit/command_spec.rb +2 -0
  57. data/spec/unit/core/ip_spec.rb +12 -0
  58. metadata +23 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e77a2eee0eb08495f947f9dc3b130a7c47cd713ab2f970dcc8fd17b7b52cd8b3
4
- data.tar.gz: 76d3ec684fe307aafce2f3be2c594f47a38c50f2b0bb394998c1c83c06d8a47b
3
+ metadata.gz: af1a581f630e30f0d4e45864f8adba335b5a4c39ba77ca81c3de97e62d1b63bc
4
+ data.tar.gz: b34344cd94480bac72c5c78db9fe2b331884366a68c30d81b001c4f6d2d648c8
5
5
  SHA512:
6
- metadata.gz: cdd8b0d400e2557525fca889bbd3ef8b8eef67774f0143ea925fa9c5ac091acabe2986de25d0f69a7005185425cf94edcd873b19cacbe56aa823c9c64fa607b3
7
- data.tar.gz: c1d802b26491e276ffbcdc3e3dd4e4272c9b48ab63a5e6b7283fb5e5f7b706ce64d5216728946aa3783f88396a0ec9a0582c045571cd78de050f42496479a392
6
+ metadata.gz: 437e92131a90f509f116067b7f0f5fb311c7ddc835d554732479d3895d1ce23b63fec937df6dc6d2ecb048deaaff1411c0c9956019c4d2f26b10e0cfeb781d86
7
+ data.tar.gz: 100a3f6f404a6665cf56ab0b6159724f775f8e25c76ab103ba491764916a067d4ce55a4043db671f58251dfed7ba25d09fa5c6b63efee7ae5d9a8facfc612248
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## Kanrisuru 0.16.3 (December 25, 2021) ##
2
+ * Refactor `Kanrisuru::Mode::Permission` class into separate file.
3
+
4
+ ## Kanrisuru 0.16.2 (December 19, 2021) ##
5
+ * Organize functional ip specs
6
+ * Log in realtime, debug output the stdout from the remote server, as opposed to waiting until after the command is done.
7
+ * Fix the `opensuse_leap` for the stubnetwork rspec helper.
8
+ * Refactor and cleanup the `append_array` method for the `Kanrisuru::Command` instance
9
+ * Move `gpg_opts` for `zypper` command into re-usable method
10
+ * Add functional test cases for `zypper` command.
11
+
12
+ ## Kanrisuru 0.16.1 (December 16, 2021) ##
13
+ * Fix require class for `os_package`.
14
+
15
+ ## Kanrisuru 0.16.0 (December 14, 2021) ##
16
+ * Fix `append_array` for the `Kanrisuru::Command` class with negated check on Array type.
17
+ * Add `to_f` method for `Kanrisuru::Command` and `Kanrisuru::Result` with unit test cases.
18
+ * Refactor `lsblk_version` into seperate command namespace with it's own parser.
19
+ * Add functional test cases for several core modules.
20
+ * Add `return_value` option to `stub_command!` method for non-result return methods. These are few and far between, but need to be tested appropriately.
21
+ * Refactor several core modules with use of `command` calls for legibility.
22
+ * Fix several issues with `create_user`, `update_user`, and `delete_user`.
23
+
1
24
  ## Kanrisuru 0.15.0 (December 13, 2021) ##
2
25
  * Add opts for `ip` command.
3
26
  * Refactor `ip` object commands into smaller methods. Refactor `version` for consistent use and stub ability in funcitonal test cases.
data/kanrisuru.gemspec CHANGED
@@ -8,9 +8,12 @@ Gem::Specification.new do |gem|
8
8
  gem.author = 'Ryan Mammina'
9
9
  gem.email = 'ryan@avamia.com'
10
10
  gem.license = 'MIT'
11
- gem.summary = 'Manage remote servers over ssh with ruby.'
12
- gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready.'
13
11
  gem.homepage = 'https://github.com/avamia/kanrisuru'
12
+ gem.summary = 'Manage remote servers over ssh with ruby.'
13
+ gem.description = <<-EOF
14
+ Kanrisuru helps manage remote servers with objected oriented ruby.#{' '}
15
+ Results come back as structured data, parsed, prepared and ready.
16
+ EOF
14
17
 
15
18
  gem.required_ruby_version = '>= 2.5.0'
16
19
 
@@ -30,6 +33,7 @@ Gem::Specification.new do |gem|
30
33
 
31
34
  gem.metadata = {
32
35
  'source_code_uri' => 'https://github.com/avamia/kanrisuru/',
33
- 'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md'
36
+ 'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md',
37
+ 'rubygems_mfa_required' => 'true'
34
38
  }
35
39
  end
@@ -23,6 +23,10 @@ module Kanrisuru
23
23
  to_a.join.to_i
24
24
  end
25
25
 
26
+ def to_f
27
+ to_a.join.to_f
28
+ end
29
+
26
30
  def to_s
27
31
  to_a.join(' ')
28
32
  end
@@ -84,11 +88,10 @@ module Kanrisuru
84
88
  append_value("| #{value}")
85
89
  end
86
90
 
87
- def append_array(value)
91
+ def append_array(value, separator = ' ')
88
92
  return unless Kanrisuru::Util.present?(value)
89
93
 
90
- value = [value] if value.instance_of?(String)
91
- append_value(value.join(' '))
94
+ append_value(Kanrisuru::Util.array_join_string(value, separator))
92
95
  end
93
96
 
94
97
  def append_value(value)
@@ -10,12 +10,12 @@ module Kanrisuru
10
10
 
11
11
  command = Kanrisuru::Command.new('lsblk')
12
12
 
13
- version = lsblk_version
13
+ version = lsblk_version.to_f
14
14
 
15
15
  ## lsblk after version 2.26 handles json parsing.
16
16
  ## TODO: parse nested children for earlier version of lsblk
17
- if version >= 2.27
18
- command.append_flag('--json') if version >= 2.27
17
+ if version >= LSBK_VERSION
18
+ command.append_flag('--json') if version >= LSBK_VERSION
19
19
  else
20
20
  command.append_flag('-i')
21
21
  command.append_flag('-P')
@@ -40,14 +40,9 @@ module Kanrisuru
40
40
  command = Kanrisuru::Command.new('lsblk --version')
41
41
  execute(command)
42
42
 
43
- version = 0.00
44
- regex = Regexp.new(/\d+(?:[,.]\d+)?/)
45
-
46
- raise 'lsblk command not found' if command.failure?
47
-
48
- version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
49
-
50
- version
43
+ Kanrisuru::Result.new(command) do |cmd|
44
+ Parser::LsblkVersion.parse(cmd)
45
+ end
51
46
  end
52
47
  end
53
48
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanrisuru
4
+ module Core
5
+ module Disk
6
+ LSBK_VERSION = 2.27
7
+ end
8
+ end
9
+ end
@@ -3,4 +3,5 @@
3
3
  require_relative 'parsers/blkid'
4
4
  require_relative 'parsers/df'
5
5
  require_relative 'parsers/du'
6
+ require_relative 'parsers/lsblk_version'
6
7
  require_relative 'parsers/lsblk'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanrisuru
4
+ module Core
5
+ module Disk
6
+ module Parser
7
+ class LsblkVersion
8
+ def self.parse(command)
9
+ version = 0.00
10
+ regex = Regexp.new(/\d+(?:[,.]\d+)?/)
11
+
12
+ raise 'lsblk command not found' if command.failure?
13
+
14
+ version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
15
+ version
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
 
5
+ require_relative 'disk/constants'
5
6
  require_relative 'disk/types'
6
7
  require_relative 'disk/parser'
7
8
  require_relative 'disk/commands'
@@ -20,7 +20,7 @@ module Kanrisuru
20
20
  return unless Kanrisuru::Util.present?(opts[:types])
21
21
 
22
22
  types = opts[:types]
23
- types = [types] if types.instance_of?(String)
23
+ types = [types] unless types.instance_of?(Array)
24
24
 
25
25
  types.each do |type|
26
26
  type = get_dmi_type(type)
@@ -7,7 +7,7 @@ module Kanrisuru
7
7
  recursive = opts[:recursive]
8
8
 
9
9
  command =
10
- if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
10
+ if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode)) && mode.length < 10
11
11
  Kanrisuru::Command.new("chmod #{mode} #{path}")
12
12
  elsif mode.instance_of?(Kanrisuru::Mode)
13
13
  Kanrisuru::Command.new("chmod #{mode.numeric} #{path}")
@@ -29,9 +29,7 @@ module Kanrisuru
29
29
  if opts[:preserve].instance_of?(TrueClass)
30
30
  command.append_flag('-p')
31
31
  elsif Kanrisuru::Util.present?(opts[:preserve])
32
- preserve =
33
- (opts[:preserve].join(',') if opts[:preserve].instance_of?(Array))
34
-
32
+ preserve = Kanrisuru::Util.array_join_string(opts[:preserve], ',')
35
33
  command << "--preserve=#{preserve}"
36
34
  end
37
35
 
@@ -8,16 +8,21 @@ module Kanrisuru
8
8
  group = opts[:group]
9
9
  recursive = opts[:recursive]
10
10
 
11
- command = Kanrisuru::Command.new("mkdir #{path}")
11
+ command = Kanrisuru::Command.new('mkdir')
12
+
13
+ command.append_array(path)
12
14
  command.append_flag('-p', opts[:silent])
13
15
 
14
16
  if Kanrisuru::Util.present?(opts[:mode])
15
17
  mode = opts[:mode]
16
- if mode.instance_of?(Kanrisuru::Mode)
17
- mode = mode.numeric
18
- elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
19
- mode = Kanrisuru::Mode.new(mode).numeric
20
- end
18
+
19
+ mode = if mode.instance_of?(Kanrisuru::Mode)
20
+ mode.numeric
21
+ elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
22
+ mode
23
+ else
24
+ Kanrisuru::Mode.new(mode).numeric
25
+ end
21
26
 
22
27
  command.append_arg('-m', mode)
23
28
  end
@@ -10,7 +10,10 @@ module Kanrisuru
10
10
  raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
11
11
  end
12
12
 
13
- command = Kanrisuru::Command.new("rm #{paths.join(' ')} --preserve-root")
13
+ command = Kanrisuru::Command.new('rm')
14
+ command.append_array(paths)
15
+
16
+ command.append_flag('--preserve-root')
14
17
  command.append_flag('-f', opts[:force])
15
18
  command.append_flag('-r', opts[:recursive])
16
19
 
@@ -7,7 +7,8 @@ module Kanrisuru
7
7
  date = opts[:date]
8
8
 
9
9
  paths = [paths] if paths.instance_of?(String)
10
- command = Kanrisuru::Command.new("touch #{paths.join(' ')}")
10
+ command = Kanrisuru::Command.new('touch')
11
+ command.append_array(paths)
11
12
 
12
13
  command.append_flag('-a', opts[:atime])
13
14
  command.append_flag('-m', opts[:mtime])
@@ -11,7 +11,7 @@ module Kanrisuru
11
11
 
12
12
  command = Kanrisuru::Command.new('kill')
13
13
  command << "-#{signal}"
14
- command << (pids.instance_of?(Array) ? pids.join(' ') : pids)
14
+ command.append_array(pids)
15
15
 
16
16
  execute_shell(command)
17
17
 
@@ -4,33 +4,25 @@ module Kanrisuru
4
4
  module Core
5
5
  module User
6
6
  def create_user(user, opts = {})
7
- uid = opts[:uid]
8
7
  group = opts[:group]
9
8
  groups = opts[:groups]
10
- home = opts[:home]
11
9
  shell = opts[:shell] || '/bin/false'
12
- createhome = opts[:createhome]
13
- system_opt = opts[:system]
14
- skeleton = opts[:skeleton]
15
- non_unique = opts[:non_unique]
16
- password = opts[:password]
17
- expires = opts[:expires] ## YYYY-MM-DD
18
10
 
19
11
  command = Kanrisuru::Command.new("useradd #{user}")
20
12
 
21
- if Kanrisuru::Util.present?(uid)
22
- command.append_arg('-u', uid)
23
- command.append_flag('-o', non_unique)
13
+ if Kanrisuru::Util.present?(opts[:uid])
14
+ command.append_arg('-u', opts[:uid])
15
+ command.append_flag('-o', opts[:non_unique])
24
16
  end
25
17
 
26
- command.append_flag('-r', system_opt)
18
+ command.append_flag('-r', opts[:system])
27
19
  command.append_arg('-s', shell)
28
- command.append_arg('-d', home)
20
+ command.append_arg('-d', opts[:home])
29
21
 
30
- case createhome
22
+ case opts[:createhome]
31
23
  when true
32
24
  command.append_flag('-m')
33
- command.append_arg('-k', skeleton)
25
+ command.append_arg('-k', opts[:skeleton])
34
26
  when false
35
27
  command.append_flag('-M')
36
28
  end
@@ -43,8 +35,8 @@ module Kanrisuru
43
35
 
44
36
  command.append_arg('-G', groups.join(',')) if Kanrisuru::Util.present?(groups)
45
37
 
46
- command.append_arg('-p', password)
47
- command.append_arg('-e', expires)
38
+ command.append_arg('-p', opts[:password])
39
+ command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
48
40
 
49
41
  execute_shell(command)
50
42
 
@@ -6,7 +6,7 @@ module Kanrisuru
6
6
  def delete_user(user, opts = {})
7
7
  force = opts[:force]
8
8
 
9
- return false unless get_uid(user)
9
+ return false if get_uid(user).failure?
10
10
 
11
11
  command = Kanrisuru::Command.new("userdel #{user}")
12
12
  command.append_flag('-f', force)
@@ -4,52 +4,43 @@ module Kanrisuru
4
4
  module Core
5
5
  module User
6
6
  def update_user(user, opts = {})
7
- uid = opts[:uid]
8
7
  group = opts[:group]
9
8
  groups = opts[:groups]
10
- append = opts[:append]
11
- home = opts[:home]
12
- move_home = opts[:move_home]
13
- shell = opts[:shell] || '/bin/false'
14
- non_unique = opts[:non_unique]
15
- password = opts[:password]
16
- expires = opts[:expires] ## YYYY-MM-DD
17
- locked = opts[:locked]
18
9
 
19
10
  command = Kanrisuru::Command.new("usermod #{user}")
20
11
 
21
- if Kanrisuru::Util.present?(home)
22
- command.append_arg('-d', home)
23
- command.append_flag('-m', move_home)
12
+ if Kanrisuru::Util.present?(opts[:home])
13
+ command.append_arg('-d', opts[:home])
14
+ command.append_flag('-m', opts[:move_home])
24
15
  end
25
16
 
26
- command.append_arg('-s', shell)
17
+ command.append_arg('-s', opts[:shell])
27
18
 
28
- if Kanrisuru::Util.present?(uid)
29
- command.append_arg('-u', uid)
30
- command.append_flag('-o', non_unique)
19
+ if Kanrisuru::Util.present?(opts[:uid])
20
+ command.append_arg('-u', opts[:uid])
21
+ command.append_flag('-o', opts[:non_unique])
31
22
  end
32
23
 
33
- command.append_arg('-g', group) if Kanrisuru::Util.present?(group) && group_exists?(group)
24
+ command.append_arg('-g', group) if Kanrisuru::Util.present?(group) && group?(group)
34
25
 
35
26
  if Kanrisuru::Util.present?(groups)
36
- command.append_arg('-G', groups.join(','))
37
- command.append_flag('-a', append)
27
+ command.append_arg('-G', Kanrisuru::Util.array_join_string(groups, ','))
28
+ command.append_flag('-a', opts[:append])
38
29
  end
39
30
 
40
- case locked
31
+ case opts[:locked]
41
32
  when true
42
33
  command.append_flag('-L')
43
34
  command.append_arg('-e', 1)
44
35
  when false
45
- command.append_arg('-U')
36
+ command.append_flag('-U')
46
37
  command.append_arg('-e', 99_999)
47
38
  else
48
39
  ## Ensure expires isn't added twice.
49
- command.append_arg('-e', expires)
40
+ command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
50
41
 
51
42
  ## Can't use password with lock / unlock flag.
52
- command.append_arg('-p', password)
43
+ command.append_arg('-p', opts[:password])
53
44
  end
54
45
 
55
46
  execute_shell(command)
@@ -17,16 +17,9 @@ module Kanrisuru
17
17
  command.append_flag('--no-refresh', opts[:no_refresh])
18
18
  command.append_flag('--keep-packages', opts[:keep_packages])
19
19
  command.append_flag('--no-keep-packages', opts[:no_keep_packages])
20
- command.append_flag('--gpgcheck', opts[:gpgcheck])
21
- command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
22
- command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
23
- command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
24
- command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
25
- command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
26
- command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
27
-
28
20
  command.append_arg('--priority', opts[:priority])
29
21
 
22
+ zypper_gpg_opts(command, opts)
30
23
  zypper_repos_opt(command, opts)
31
24
 
32
25
  execute_shell(command)
@@ -8,14 +8,16 @@ module Kanrisuru
8
8
  zypper_global_opts(command, opts)
9
9
  command << 'addservice'
10
10
 
11
- command.append_arg('--name', opts[:name])
11
+ name = ("'#{opts[:name]}'" if Kanrisuru::Util.present?(opts[:name]))
12
12
 
13
+ command.append_arg('--name', name)
13
14
  command.append_flag('--enable', opts[:enable])
14
15
  command.append_flag('--disable', opts[:disable])
15
16
  command.append_flag('--refresh', opts[:refresh])
16
17
  command.append_flag('--no-refresh', opts[:no_refresh])
17
18
 
18
- command.append_array(opts[:services])
19
+ command << opts[:service]
20
+ command << opts[:alias]
19
21
 
20
22
  execute_shell(command)
21
23
 
@@ -11,8 +11,7 @@ module Kanrisuru
11
11
  zypper_repos_opt(command, opts)
12
12
  zypper_package_type_opt(command, opts)
13
13
 
14
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
15
- command << packages
14
+ command.append_array(opts[:packages])
16
15
 
17
16
  execute_shell(command)
18
17
 
@@ -12,7 +12,7 @@ module Kanrisuru
12
12
  zypper_package_type_opt(command, opts)
13
13
 
14
14
  command.append_arg('-n', opts[:name])
15
- command.append_arg('-f', opts[:force])
15
+ command.append_flag('-f', opts[:force])
16
16
  command.append_flag('--oldpackage', opts[:oldpackage])
17
17
  command.append_arg('--from', opts[:from])
18
18
  command.append_arg('--capability', opts[:capability])
@@ -27,8 +27,7 @@ module Kanrisuru
27
27
  zypper_download_and_install_opts(command, opts)
28
28
  zypper_expert_opts(command, opts)
29
29
 
30
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
31
- command << packages
30
+ command.append_array(opts[:packages])
32
31
 
33
32
  execute_shell(command)
34
33
 
@@ -19,13 +19,7 @@ module Kanrisuru
19
19
  command.append_flag('--keep-packages', opts[:keep_packages])
20
20
  command.append_flag('--no-keep-packages', opts[:no_keep_packages])
21
21
 
22
- command.append_flag('--gpgcheck', opts[:gpgcheck])
23
- command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
24
- command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
25
- command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
26
- command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
27
- command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
28
- command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
22
+ zypper_gpg_opts(command, opts)
29
23
 
30
24
  command.append_flag('--all', opts[:all])
31
25
  command.append_flag('--local', opts[:local])
@@ -8,8 +8,8 @@ module Kanrisuru
8
8
  zypper_global_opts(command, opts)
9
9
 
10
10
  command << 'modifyservice'
11
- command.append_arg('--name', opts[:name])
12
11
 
12
+ command.append_arg('--name', opts[:name])
13
13
  command.append_flag('--enable', opts[:enable])
14
14
  command.append_flag('--disable', opts[:disable])
15
15
  command.append_flag('--refresh', opts[:refresh])
@@ -31,6 +31,8 @@ module Kanrisuru
31
31
  command.append_arg('--medium-type', opts[:medium_type])
32
32
  end
33
33
 
34
+ command << opts[:service] if Kanrisuru::Util.present?(opts[:service])
35
+
34
36
  execute_shell(command)
35
37
 
36
38
  Kanrisuru::Result.new(command)
@@ -15,8 +15,7 @@ module Kanrisuru
15
15
  zypper_package_type_opt(command, opts)
16
16
  zypper_solver_opts(command, opts)
17
17
 
18
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
19
- command << packages
18
+ command.append_array(opts[:packages])
20
19
 
21
20
  execute_shell(command)
22
21
  Kanrisuru::Result.new(command)
@@ -15,10 +15,10 @@ module Kanrisuru
15
15
  command.append_flag('--local', opts[:local])
16
16
  command.append_flag('--remote', opts[:remote])
17
17
 
18
- if Kanrisuru::Util.present?(opts[:media_type])
19
- raise ArgumentError, 'Invalid media type' unless ZYPPER_MEDIA_TYPES.include?(opts[:media_type])
18
+ if Kanrisuru::Util.present?(opts[:medium_type])
19
+ raise ArgumentError, 'Invalid media type' unless MEDIUM_TYPES.include?(opts[:medium_type])
20
20
 
21
- command.append_arg('--media-type', opts[:media_type])
21
+ command.append_arg('--medium-type', opts[:medium_type])
22
22
  end
23
23
 
24
24
  command.append_array(opts[:repos])
@@ -4,13 +4,18 @@ module Kanrisuru
4
4
  module Core
5
5
  module Zypper
6
6
  def zypper_remove_service(opts)
7
+ service = opts[:service]
8
+
7
9
  command = Kanrisuru::Command.new('zypper')
8
10
  zypper_global_opts(command, opts)
9
11
 
10
12
  command << 'removeservice'
11
13
  command.append_flag('--loose-auth', opts[:loose_auth])
12
14
  command.append_flag('--loose-query', opts[:loose_query])
13
- command.append_array(opts[:services])
15
+
16
+ service = "'#{service}'" if service.match(/\s/)
17
+
18
+ command << service
14
19
 
15
20
  execute_shell(command)
16
21
 
@@ -37,9 +37,7 @@ module Kanrisuru
37
37
 
38
38
  zypper_repos_opt(command, opts)
39
39
  zypper_package_type_opt(command, opts)
40
-
41
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
42
- command << packages
40
+ command.append_array(opts[:packages])
43
41
 
44
42
  execute_shell(command)
45
43
 
@@ -13,6 +13,8 @@ module Kanrisuru
13
13
  command.append_flag('--no-build-deps', opts[:no_build_deps])
14
14
  command.append_flag('--download-only', opts[:download_only])
15
15
 
16
+ command.append_array(opts[:packages])
17
+
16
18
  execute_shell(command)
17
19
 
18
20
  Kanrisuru::Result.new(command)
@@ -76,6 +76,16 @@ module Kanrisuru
76
76
  command.append_flag('--no-allow-vendor-change', opts[:no_allow_vendor_change])
77
77
  end
78
78
 
79
+ def zypper_gpg_opts(command, opts)
80
+ command.append_flag('--gpgcheck', opts[:gpgcheck])
81
+ command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
82
+ command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
83
+ command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
84
+ command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
85
+ command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
86
+ command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
87
+ end
88
+
79
89
  def zypper_repos_opt(command, opts)
80
90
  zypper_array_opt(command, opts[:repos], '--repo')
81
91
  end
@@ -101,7 +111,6 @@ module Kanrisuru
101
111
 
102
112
  def zypper_package_type_opt(command, opts)
103
113
  type = opts[:type]
104
-
105
114
  command.append_arg('-t', type) if Kanrisuru::Util.present?(type) && PACKAGE_TYPES.include?(type)
106
115
  end
107
116
  end