zae 0.8.3 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7107716877c5697e0ad9e7d25ee266a8e22b8c6914b580398bbcca712c1a3f70
4
- data.tar.gz: fea4655d21aaf270a3a554f436ef430bb7d8f2121cc4412e5e03e53632365c64
3
+ metadata.gz: 106f2b8766bfad6808958e5a5bc5acebb6af97bbddb07d6457353bd07bcbd8ad
4
+ data.tar.gz: 94fc66fa4ad7031bf803dd1b9c4e24dbf62e3f6237d5a78b3fcbf2cf5ad9cb57
5
5
  SHA512:
6
- metadata.gz: ca8aa654b9a5e689640b1e5c14f919f6c12b6b8f7728516cc5bd8daba75f8a6a0b0372be967556dc76abf6b56717f248b4dac5bac5af4c207ef000f2e3937c2c
7
- data.tar.gz: b6002c33b403a78322abf47c57b30785b15ef2c6d9b3fbbfef92fec44cfb94518add7e506545c65530f088f955dbcc125e05953e638988732fa80990b95945bd
6
+ metadata.gz: 06badcad035690c456d41adf3f76da3b3c040b0f3c4ccd449d358f09c667b2990da2e12967af62bfc1c29de479463907ced531ae9cbf74efc674fee7b3a26006
7
+ data.tar.gz: 9e1415c9eadfe80df5f18698197065a4ae7eebd5f944b2758face0a43d6a73bd71241b43ab69e5679e63e47c4083b0b2b3e11cf3b92ea8816d8e6864a92b00bb
data/exe/zae CHANGED
@@ -1,113 +1,108 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+ # frozen_string_literal: true
3
+
4
+ # Zae is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # Zae is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ require_relative '../lib/zae/version'
3
18
  require_relative '../lib/zae'
4
19
 
5
20
  require 'gli'
6
21
 
7
22
  # Cli main parser
8
- class Cli
9
- extend GLI::App
10
-
11
- # cli options
12
- subcommand_option_handling :normal
13
- arguments :strict
14
-
15
- # information
16
- program_desc 'a handy runner of distributions packages manager commands. '
17
- version Zae::VERSION
18
-
19
- # commands base
20
- COMMANDS = Zae::Commands.new
21
-
22
- desc 'install package(s) from repositories'
23
- arg_name 'package(s) name'
24
- command :install do |c|
25
- c.arg 'arguments'
26
- c.action do |_, _, args|
27
- p COMMANDS.install args
23
+ module Zae
24
+ class Cli
25
+ extend GLI::App
26
+
27
+ # cli options
28
+ subcommand_option_handling :normal
29
+ arguments :strict
30
+
31
+ # information
32
+ program_desc 'One runner to handle them, package managers, all.'
33
+ version VERSION
34
+
35
+ # commands base
36
+ commands = Commands.new
37
+
38
+ desc 'install package(s) from repositories'
39
+ arg_name 'package(s) name'
40
+ command :install do |c|
41
+ c.arg 'arguments'
42
+ c.action { |_, _, args| commands.install args }
28
43
  end
29
- end
30
44
 
31
- desc 'remove one or more installed packages'
32
- arg_name 'package(s) name'
33
- command :remove do |c|
34
- c.action do |_, _, args|
35
- COMMANDS.remove args
45
+ desc 'remove one or more installed packages'
46
+ arg_name 'package(s) name'
47
+ command :remove do |c|
48
+ c.action { |_, _, args| commands.remove args }
36
49
  end
37
- end
38
50
 
39
- desc 'search for matching packages of term'
40
- arg_name 'package name'
41
- command :search do |c|
42
- c.action do |_, _, args|
43
- COMMANDS.search args
51
+ desc 'search for matching packages of term'
52
+ arg_name 'package name'
53
+ command :search do |c|
54
+ c.action { |_, _, args| commands.search args }
44
55
  end
45
- end
46
56
 
47
- desc 'update database'
48
- arg_name ''
49
- command :update do |c|
50
- c.action do
51
- COMMANDS.update
57
+ desc 'update database'
58
+ arg_name ''
59
+ command :update do |c|
60
+ c.action { commands.update }
52
61
  end
53
- end
54
62
 
55
- desc 'upgrade packages'
56
- arg_name ''
57
- command :upgrade do |c|
58
- c.arg 'arguments'
59
- c.action do
60
- COMMANDS.upgrade
63
+ desc 'upgrade packages'
64
+ arg_name ''
65
+ command :upgrade do |c|
66
+ c.arg 'arguments'
67
+ c.action { commands.upgrade }
61
68
  end
62
- end
63
69
 
64
- desc 'auto remove system residual packages dependencies'
65
- arg_name ''
66
- command :autoremove do |c|
67
- c.action do |_, _, args|
68
- COMMANDS.autoremove args
70
+ desc 'auto remove system residual packages dependencies'
71
+ arg_name ''
72
+ command :autoremove do |c|
73
+ c.action { |_, _, args| commands.autoremove args }
69
74
  end
70
- end
71
75
 
72
- desc 'download package binary'
73
- arg_name 'package name'
74
- command :download do |c|
75
- c.action do |_, _, args|
76
- COMMANDS.download args
76
+ desc 'download package binary'
77
+ arg_name 'package name'
78
+ command :download do |c|
79
+ c.action { |_, _, args| commands.download args }
77
80
  end
78
- end
79
81
 
80
- desc 'list installed packages'
81
- arg_name ''
82
- command :installed do |c|
83
- c.action do |_, _, args|
84
- COMMANDS.installed args
82
+ desc 'list installed packages'
83
+ arg_name ''
84
+ command :installed do |c|
85
+ c.action { |_, _, args| commands.installed args }
85
86
  end
86
- end
87
87
 
88
- desc 'view info about a specific package'
89
- arg_name 'package name'
90
- command :info do |c|
91
- c.action do |_, _, args|
92
- COMMANDS.info args
88
+ desc 'view info about a specific package'
89
+ arg_name 'package name'
90
+ command :info do |c|
91
+ c.action { |_, _, args| commands.info args }
93
92
  end
94
- end
95
93
 
96
- desc 'fix system package manager issues'
97
- arg_name 'packages'
98
- command :fix do |c|
99
- c.action do |_, _, args|
100
- COMMANDS.fix args
94
+ desc 'fix system package manager issues'
95
+ arg_name 'packages'
96
+ command :fix do |c|
97
+ c.action { |_, _, args| commands.fix args }
101
98
  end
102
- end
103
99
 
104
- desc 'package manager version'
105
- arg_name ''
106
- command :fix do |c|
107
- c.action do
108
- COMMANDS.version
100
+ desc 'package manager version'
101
+ arg_name ''
102
+ command :fix do |c|
103
+ c.action { commands.version }
109
104
  end
110
105
  end
111
106
  end
112
107
 
113
- exit Cli.run(ARGV)
108
+ exit Zae::Cli.run(ARGV)
data/lib/zae/commands.rb CHANGED
@@ -1,85 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
3
16
  module Zae
4
- # Feature requirement:
17
+ # All Commands available
5
18
  class Commands
6
- # update repository database
7
- def update
8
- exec :update
9
- end
10
-
11
- # upgrade system package(s)
12
- def upgrade
13
- exec :upgrade
14
- end
15
-
16
- def deps
17
- exec :deps
18
- end
19
-
20
- def autoremove(...)
21
- exec(:autoremove, ...)
22
- end
23
-
24
- def depends
25
- exec :depends
26
- end
27
-
28
- def install(...)
29
- exec(:install, ...)
30
- end
31
-
32
- def installed(...)
33
- exec(:installed, ...)
34
- end
35
-
36
- def remove(...)
37
- exec(:remove, ...)
38
- end
39
-
40
- def download(...)
41
- exec(:download, ...)
42
- end
43
-
44
- def fix(...)
45
- exec(:fix, ...)
46
- end
47
-
48
- # search for given package
49
- def search(...)
50
- exec(:search, ...)
19
+ def initialize
20
+ Commands.create_commands
51
21
  end
52
22
 
53
- # provide user with manual information
54
- def help
55
- exec :help
56
- end
57
-
58
- # show package information
59
- def show
60
- exec :show
61
- end
23
+ ACTIONS = %i[update upgrade deps autoremove depends install installed remove
24
+ fix search help show info version].freeze
62
25
 
63
- def info(...)
64
- exec(:info, ...)
26
+ # generate dynamically methods of every command
27
+ def self.create_commands
28
+ ACTIONS.each do |name|
29
+ define_method name do |arguments = []|
30
+ Commands.exec name, arguments
31
+ end
32
+ end
65
33
  end
66
34
 
67
- # packager current version
68
- def version
69
- exec :version
70
- end
71
-
72
- private
73
-
74
- def exec(...)
75
- print_run = lambda { |cmd|
76
- puts "command: #{cmd}"
77
- system cmd
78
- }
79
-
35
+ def self.exec(...)
80
36
  Translate.new(...)
81
- .to_str
82
- .yield_self(&print_run)
37
+ .to_s
38
+ .then(&lambda { |command|
39
+ puts "command: #{command}"
40
+ system command
41
+ })
83
42
  end
84
43
  end
85
44
  end
data/lib/zae/files.rb ADDED
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ module Zae
17
+ # grab all configuration files
18
+ class Files
19
+ def initialize
20
+ @config_folder = Settings.new.config_folder
21
+ end
22
+
23
+ # list all files found
24
+ def all
25
+ @config_folder.children
26
+ end
27
+
28
+ private
29
+
30
+ # is there any configuration available?
31
+ def any?
32
+ @config_folder.children.any?
33
+ end
34
+
35
+ # config folder do exist?
36
+ def folder?
37
+ @config_folder.exist?
38
+ end
39
+
40
+ # Once an executable is discovered create a new file w/ its path or name in
41
+ # $HOME so to avoid probing for it in every startup
42
+ def discovered_file
43
+ exec = @config_folder.join('.discovered').read.chop.to_sym if discovered?
44
+ all[exec] || nil
45
+ end
46
+
47
+ # Once an executable is discovered, it better creates a file
48
+ # indicating current system package manager executable
49
+ # to avoid probing for it everytime run
50
+ def discovered?
51
+ @config_folder.join('.discovered').exist?
52
+ end
53
+ end
54
+ end
data/lib/zae/parse.rb ADDED
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ require 'json'
17
+
18
+ module Zae
19
+ # Query for configuration files and returns matching ones
20
+ class Parse
21
+ attr_reader :found
22
+
23
+ def initialize
24
+ @files = Files.new.all
25
+ @found = found
26
+ end
27
+
28
+ def found
29
+ all[executable]
30
+ end
31
+
32
+ # Load and serialize configuration file
33
+ def one(file)
34
+ JSON.load_file(file, symbolize_names: true)
35
+ end
36
+
37
+ # List all configuration files
38
+ def all
39
+ raise ExceptionType, 'Not files found' if @files.nil?
40
+
41
+ {}.tap do |elem|
42
+ @files.each do |file|
43
+ name = file.sub_ext('').basename.to_s.to_sym
44
+ elem[name] = one(file)
45
+ end
46
+ end
47
+ end
48
+
49
+ # package manager's executable location
50
+ def executable
51
+ # return Pathname.new(discovered[:exec]).basename.to_path.to_sym if discovered?
52
+
53
+ # get all availables executables
54
+ exec = all.each_value.find { |config| Parse.executable?(config[:exec]) }
55
+ Pathname.new(exec[:exec]).basename.to_path.to_sym
56
+ end
57
+
58
+ # do executable exist?
59
+ def self.executable?(exec)
60
+ File.executable? exec.to_s
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ require 'pathname'
17
+
18
+ module Zae
19
+ # define how command should be run, either to become super user or not.
20
+ class Permission
21
+ BECOMERS = [Pathname.new('/usr/bin/sudo'), Pathname.new('/usr/bin/doas')].freeze
22
+
23
+ def initialize(action, configuration)
24
+ @action = action
25
+ @configuration = configuration
26
+ end
27
+
28
+ # needs to be super user to run?
29
+ def super?
30
+ @configuration[:super].key?(@action)
31
+ end
32
+
33
+ # find becomer program to use in system
34
+ def becomer
35
+ BECOMERS.first { |exe| return exe if exe.exist? }
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ require 'pathname'
17
+
18
+ module Zae
19
+ # User settings
20
+ class Settings
21
+ # user configuration folder location
22
+ attr_reader :config_folder
23
+
24
+ def initialize
25
+ @config_folder = xdg_config_folder || zae_config_folder
26
+ end
27
+
28
+ # default configuration location
29
+ def zae_config_folder
30
+ Pathname.new(File.join(Dir.home, '.config', 'zae'))
31
+ end
32
+
33
+ # XDG configuration localtion
34
+ def xdg_config_folder
35
+ Pathname.new(File.join(ENV['XDG_CONFIG_HOME'], 'zae')) if ENV['XDG_CONFIG_HOME']
36
+ end
37
+ end
38
+ end
data/lib/zae/translate.rb CHANGED
@@ -1,35 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
3
16
  module Zae
4
17
  # translate action to final command
5
18
  class Translate
6
- def initialize(action, args = [], config = Config.new.found,
7
- become: Become.new(action, config))
8
- @args = args
19
+ def initialize(action, arguments = [])
9
20
  @action = action
10
-
11
- @config = config
12
- @become = become
21
+ @arguments = arguments
22
+ @configuration = Parse.new.found
23
+ @permission = Permission.new(action, @configuration)
13
24
  end
14
25
 
15
- def to_str
16
- cmd = @become.need? ? @config[:become][@action] : @config[:user][@action]
17
- command cmd
26
+ # simple string representation
27
+ def to_s
28
+ command = @permission.super? ? @configuration[:super][@action] : @configuration[:user][@action]
29
+ compose command
18
30
  end
19
31
 
20
32
  private
21
33
 
22
- # TODO: raise 'command was not provided' and return if command.nil?
23
- # query for final command composition
24
- def command(action)
25
- executable = @config[:exec]
34
+ # compose final command
35
+ def compose(action)
36
+ # TODO: raise 'command was not provided' and return if command.nil?
37
+ executable = @configuration[:exec]
26
38
 
27
39
  [].tap do |el|
28
- el << @become.exec if @become.need?
40
+ el << @permission.becomer if @permission.super?
29
41
  el << executable
30
42
  el << action
31
43
  end
32
- .+(@args)
44
+ .+(@arguments)
33
45
  .join(' ')
34
46
  end
35
47
  end
data/lib/zae/version.rb CHANGED
@@ -1,5 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Zae is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Zae is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with Zae. If not, see <https://www.gnu.org/licenses/>.
15
+
3
16
  module Zae
4
- VERSION = '0.8.3'
17
+ VERSION = '0.8.5'
5
18
  end
data/lib/zae.rb CHANGED
@@ -1,10 +1,14 @@
1
- require_relative 'zae/become'
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative 'zae/commands'
3
- require_relative 'zae/config'
4
+ require_relative 'zae/permission'
4
5
  require_relative 'zae/translate'
5
- require_relative 'zae/version'
6
+ require_relative 'zae/files'
7
+ require_relative 'zae/parse'
8
+ require_relative 'zae/settings'
6
9
 
7
- # a handy runner of distributions packages manager commands.
10
+ # One runner to handle them, package managers, all.
8
11
  module Zae
9
- class Error < StandardError; end
12
+ class Error < StandardError
13
+ end
10
14
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
- - easbarba
8
- autorequire:
7
+ - EAS Barbosa
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.21'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -36,58 +50,84 @@ dependencies:
36
50
  requirements:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: 6.1.1
53
+ version: '6.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 6.1.4
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '6.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 6.1.4
67
+ - !ruby/object:Gem::Dependency
68
+ name: rexml
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.2'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.2.5
40
77
  type: :development
41
78
  prerelease: false
42
79
  version_requirements: !ruby/object:Gem::Requirement
43
80
  requirements:
44
81
  - - "~>"
45
82
  - !ruby/object:Gem::Version
46
- version: 6.1.1
83
+ version: '3.2'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.2.5
47
87
  - !ruby/object:Gem::Dependency
48
88
  name: rspec
49
89
  requirement: !ruby/object:Gem::Requirement
50
90
  requirements:
51
91
  - - "~>"
52
92
  - !ruby/object:Gem::Version
53
- version: '3.11'
93
+ version: '3.12'
54
94
  type: :development
55
95
  prerelease: false
56
96
  version_requirements: !ruby/object:Gem::Requirement
57
97
  requirements:
58
98
  - - "~>"
59
99
  - !ruby/object:Gem::Version
60
- version: '3.11'
100
+ version: '3.12'
61
101
  - !ruby/object:Gem::Dependency
62
- name: rufo
102
+ name: ruby-lsp
63
103
  requirement: !ruby/object:Gem::Requirement
64
104
  requirements:
65
105
  - - "~>"
66
106
  - !ruby/object:Gem::Version
67
- version: 0.13.0
107
+ version: 0.4.2
68
108
  type: :development
69
109
  prerelease: false
70
110
  version_requirements: !ruby/object:Gem::Requirement
71
111
  requirements:
72
112
  - - "~>"
73
113
  - !ruby/object:Gem::Version
74
- version: 0.13.0
114
+ version: 0.4.2
75
115
  - !ruby/object:Gem::Dependency
76
- name: gli
116
+ name: rufo
77
117
  requirement: !ruby/object:Gem::Requirement
78
118
  requirements:
79
119
  - - "~>"
80
120
  - !ruby/object:Gem::Version
81
- version: '2.21'
82
- type: :runtime
121
+ version: 0.15.1
122
+ type: :development
83
123
  prerelease: false
84
124
  version_requirements: !ruby/object:Gem::Requirement
85
125
  requirements:
86
126
  - - "~>"
87
127
  - !ruby/object:Gem::Version
88
- version: '2.21'
89
- description:
90
- email:
128
+ version: 0.15.1
129
+ description:
130
+ email:
91
131
  executables:
92
132
  - zae
93
133
  extensions: []
@@ -95,18 +135,19 @@ extra_rdoc_files: []
95
135
  files:
96
136
  - exe/zae
97
137
  - lib/zae.rb
98
- - lib/zae/become.rb
99
138
  - lib/zae/commands.rb
100
- - lib/zae/config.rb
101
- - lib/zae/engage.rb
139
+ - lib/zae/files.rb
140
+ - lib/zae/parse.rb
141
+ - lib/zae/permission.rb
142
+ - lib/zae/settings.rb
102
143
  - lib/zae/translate.rb
103
144
  - lib/zae/version.rb
104
145
  homepage: https://github.com/easbarba/zae
105
146
  licenses:
106
- - gpl-v3
147
+ - GPL-3.0-or-later
107
148
  metadata:
108
149
  homepage_uri: https://github.com/easbarba/zae
109
- post_install_message:
150
+ post_install_message:
110
151
  rdoc_options: []
111
152
  require_paths:
112
153
  - lib
@@ -114,15 +155,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
155
  requirements:
115
156
  - - ">="
116
157
  - !ruby/object:Gem::Version
117
- version: '2.7'
158
+ version: '3.0'
118
159
  required_rubygems_version: !ruby/object:Gem::Requirement
119
160
  requirements:
120
161
  - - ">="
121
162
  - !ruby/object:Gem::Version
122
163
  version: '0'
123
164
  requirements: []
124
- rubygems_version: 3.3.5
125
- signing_key:
165
+ rubygems_version: 3.4.6
166
+ signing_key:
126
167
  specification_version: 4
127
- summary: a handy runner of distributions packages manager commands
168
+ summary: One runner to handle them, package managers, all.
128
169
  test_files: []
data/lib/zae/become.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'pathname'
4
-
5
- module Zae
6
- # define how command should be run, either to become super user or not.
7
- class Become
8
- attr_accessor
9
-
10
- SUDO_PATH = Pathname.new('/usr/bin/sudo')
11
- DOAS_PATH = Pathname.new('/usr/bin/doas')
12
-
13
- def initialize(action, config)
14
- @action = action
15
- @config = config
16
- end
17
-
18
- def need?
19
- return false if @config[:become].nil?
20
-
21
- if @config[:become].key?(@action)
22
- true
23
- else
24
- false
25
- end
26
- end
27
-
28
- # query which become methods are available on user system
29
- def exec
30
- if SUDO_PATH.exist?
31
- SUDO_PATH
32
- elsif DOAS_PATH.exist?
33
- DOAS_PATH
34
- else
35
- 'unknown'
36
- end
37
- end
38
- end
39
- end
data/lib/zae/config.rb DELETED
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'pathname'
4
-
5
- module Zae
6
- # Query for configuration files and returns matching ones
7
- class Config
8
- CFG_FOLDER = Pathname.new(File.join(Dir.home, '.config', 'zae'))
9
-
10
- # package manager found
11
- attr_accessor :found
12
-
13
- def initialize
14
- @found = discovered || files[executable]
15
- end
16
-
17
- # config files folder location
18
- def folder
19
- xdg_config_folder || CFG_FOLDER
20
- end
21
-
22
- # package manager executable location
23
- def executable
24
- return Pathname.new(discovered[:exec]).basename.to_path.to_sym if discovered?
25
-
26
- # get all availables executables
27
- exec = files.each_value.find { |cfg| Config.executable? cfg[:exec] }[:exec]
28
- Pathname.new(exec).basename.to_path.to_sym
29
- end
30
-
31
- # active package manager executable
32
- alias active executable
33
-
34
- # once executable is discovered create a new file w/ its path or name in
35
- # $HOME so to avoid probing for it in every startup
36
- def discovered
37
- exec = folder.join('.discovered').read.chop.to_sym if discovered?
38
-
39
- files[exec] || nil
40
- end
41
-
42
- # is there any configuration available?
43
- def any?
44
- files.any?
45
- # - config folder do exist?
46
- # - any yaml config file?
47
- # - .discovered do exist?
48
- end
49
-
50
- private
51
-
52
- # executable exist?
53
- def self.executable?(exec)
54
- File.executable? exec.to_s
55
- end
56
-
57
- # Get all Configuration files
58
- def files
59
- # return if any?
60
-
61
- {}.tap do |elem|
62
- folder.each_child do |file|
63
- name = file.sub_ext('').basename.to_s.to_sym
64
- elem[name] = load_config(file)
65
- end
66
- end
67
- end
68
-
69
- # once executable is discovered create a new file w/ its path or name in
70
- # $HOME to avoid probing everytime run
71
- def discovered?
72
- folder.join('.discovered').exist?
73
- end
74
-
75
- # when xdg config is set, defaults to it to probe for configuration fiels
76
- def xdg_config_folder
77
- Pathname.new(File.join(ENV['XDG_CONFIG_HOME'], 'zae')) if ENV['XDG_CONFIG_HOME']
78
- end
79
-
80
- # Load file with famous serialization formats
81
- def load_config(file)
82
- require 'yaml'
83
- YAML.load_file(file, symbolize_names: true)
84
- end
85
- end
86
- end
data/lib/zae/engage.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Zae
4
- # make it so
5
- class Engage
6
- def commands
7
- Commands.new
8
- end
9
- end
10
- end