systemdy 0.2.1 → 0.3.1

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: 3295c50515809b73fe45a95f7d9a515e06bc228595f32d8001794d234de5f9cb
4
- data.tar.gz: 2df557021563e4b76767652b0d23c0cdf6fba1bc161c568f15ec959f273edb83
3
+ metadata.gz: 0d100ae2959d85fb8084a5d6c23113dd70a417f3f5512b8ef9664f7e49ec4b70
4
+ data.tar.gz: 8d7e95b1a81f21778a56ba809b621cce17d73c509222da63939744645595eba6
5
5
  SHA512:
6
- metadata.gz: e57fab1a933d002e1c4328215f65b634656657a7e24e305b572d784515d4611140d28c1ade509d8507864db44a1503f16f0c4abbbe99c3b27f46481e685eeed7
7
- data.tar.gz: 1d9c0958c693c7bd6d0d7b02c36549ec3317f646773c2d07478844de7d91553aeba867b97f6dd48300488ca0e4819946dc6cd42ce9f4f0e3f43064442837206f
6
+ metadata.gz: 8d900cabf4fea970eade41af5121ae5c3b2bad2defb72486d88f64c5622b9cb7673e43fb027bd496f41c0c50def879dfe40dddf96b7da8732b872697b41bc5e4
7
+ data.tar.gz: 0507f8e49ce30ff6affc084b52f6b4388bb136f2272d6c6d234b2d5191cad404eec16f356a19b7a5010d45a98922c0119d057cd8177d6859f30ad41ab12464c8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [0.3.0] - 2022-10-21
2
+
3
+ ### Added
4
+
5
+ - Method remove_newline_from_system_command to Systemdy::Utility::Formatter class for remove \n characters from system calls
6
+
7
+ ### Changed
8
+
9
+ - Logic for class Systemdy::Service is_active? and is_enabled? instance methods
10
+
11
+ ## [0.2.1] - 2022-10-11
12
+
13
+ ### Fixed
14
+
15
+ - documentation_uri in gemspec
16
+
1
17
  ## [0.2.0] - 2022-10-10
2
18
 
3
19
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- systemdy (0.1.0)
4
+ systemdy (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -34,6 +34,8 @@ module Systemdy
34
34
 
35
35
  # delegate return_an_array_from_system_command method to Systemdy::Utility::Formatter class contained in Systemdy/utility/formatter.rb
36
36
  def_delegator Systemdy::Utility::Formatter, :return_an_array_from_system_command
37
+ # delegate remove_newline_from_system_command to Systemdy::Utility::Formatter class contained in Systemdy/utility/formatter.rb
38
+ def_delegator Systemdy::Utility::Formatter, :remove_newline_from_system_command
37
39
  # delegate render_message method to Systemdy::Utility::MessageDisplayer class contained in Systemdy/utility/message_displayer.rb
38
40
  def_delegator Systemdy::Utility::MessageDisplayer, :render_message
39
41
  # delegate check_if_a_service_exist method to Systemdy::Utility::Validator class contained in Systemdy/utility/validator.rb
@@ -101,8 +103,9 @@ module Systemdy
101
103
  #
102
104
  LIST_OF_ACTIONS.each do |action|
103
105
  define_method action do
106
+ return default_error_message() unless exist?
104
107
  sudo = Etc.getpwuid(Process.uid).name != 'root' ? 'sudo' : ''
105
- exist? ? `#{sudo} #{command} #{action} #{name}` : default_error_message()
108
+ `#{sudo} #{command} #{action} #{name}`
106
109
  end
107
110
  end
108
111
 
@@ -146,7 +149,8 @@ module Systemdy
146
149
  # }
147
150
  #
148
151
  def status
149
- exist? ? filter_by_keys(properties, LIST_OF_STATUS_PROPERTIES) : default_error_message()
152
+ return default_error_message() unless exist?
153
+ filter_by_keys(properties, LIST_OF_STATUS_PROPERTIES)
150
154
  end
151
155
 
152
156
  # create dynamically methods based on LIST_OF_STATUSES constant
@@ -165,7 +169,8 @@ module Systemdy
165
169
  # @note This method is generated with use of metaprogramming techniques
166
170
  LIST_OF_STATUSES.each do |status|
167
171
  define_method "is_#{status}?" do
168
- exist? ? return_an_array_from_system_command(`#{command} is-#{status} #{name}`).include?(status) : default_error_message()
172
+ return default_error_message() unless exist?
173
+ remove_newline_from_system_command(`#{command} is-#{status} #{name}`) == status
169
174
  end
170
175
  end
171
176
 
@@ -11,9 +11,20 @@ module Systemdy
11
11
  # list_of_files_in_my_folder = Systemdy::Utility::Formatter.return_an_array_from_system_command(`ls -la`)
12
12
  # @todo execute system calls with backtick instead of system() beacuse system() return only true or false and not the expected value
13
13
  def self.return_an_array_from_system_command(system_call)
14
- system_call_without_new_line = system_call.chomp! # remove \n from system call returned value
15
- return system_call_without_new_line if !$?.success? # return system error message if the process has non-zero exit status
16
- system_call_without_new_line.split(/\n/) # convert values returned by `` system call to an array-based list
14
+ system_call_without_new_line = remove_newline_from_system_command(system_call) # remove \n from system call returned value
15
+ return system_call_without_new_line if !$?.success? # return system error message if the process has non-zero exit status
16
+ system_call_without_new_line.split(/\n/) # convert values returned by `` system call to an array-based list
17
+ end
18
+
19
+ # method for remove +\n+ characters from system calls
20
+ #
21
+ # @param system_call [String] system call to remove +\n+ characters from
22
+ # @return [String] the result of a system call without +\n+ characters
23
+ # @example remove +\n+ characters from system calls
24
+ # command_without_new_line = Systemdy::Utility::Formatter.remove_newline_from_system_command(`ls -la`)
25
+ # @todo execute system calls with backtick instead of system() beacuse system() return only true or false and not the expected value
26
+ def self.remove_newline_from_system_command(system_call)
27
+ system_call.chomp! # remove \n from system call returned value
17
28
  end
18
29
  end
19
30
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Systemdy
4
4
  # the current version of the gem
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: systemdy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - magic4dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-11 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: magic4dev@gmail.com
@@ -40,7 +40,7 @@ licenses:
40
40
  metadata:
41
41
  homepage_uri: https://github.com/magic4dev/systemdy
42
42
  source_code_uri: https://github.com/magic4dev/systemdy
43
- documentation_uri: https://www.rubydoc.info/github/magic4dev/systemdy/master
43
+ documentation_uri: https://www.rubydoc.info/gems/systemdy
44
44
  changelog_uri: https://github.com/magic4dev/systemdy/blob/master/CHANGELOG.md
45
45
  code_of_conduct_uri: https://github.com/magic4dev/systemdy/blob/master/CODE_OF_CONDUCT.md
46
46
  post_install_message: