systemdy 0.2.1 → 0.3.0
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 +4 -4
 - data/CHANGELOG.md +16 -0
 - data/Gemfile.lock +1 -1
 - data/lib/systemdy/service.rb +8 -3
 - data/lib/systemdy/utility/formatter.rb +14 -3
 - data/lib/systemdy/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 90fbfbbdbdcd12922983d5bd751e628f3f7a8b5f3858a420e5e13ad0e73e30da
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cd74d56bcb932d1a067ef936e9133c9097f2df2d0b743c76e30c48e90b8839e0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 894062ea8f1b6724d72148b81aa27877ba9f53d3ee9264ff89a1009ae10ebc7bc09c83a934f1511cb85a755f9654851c25875faa8d3110c06044506a4b7881f3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 597bdadedfff3fb63c934d2f6b0666398dbfd01e28d3799578046f427c10c580aee0d3b2070b3b8db5411603c2cb7836327409e93f547088f4e4f9d5cd159d57
         
     | 
    
        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
    
    
    
        data/lib/systemdy/service.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
                             
     | 
| 
      
 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 
     | 
    
         
            -
                         
     | 
| 
      
 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 
     | 
    
         
            -
                             
     | 
| 
      
 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 
     | 
| 
       15 
     | 
    
         
            -
                            return system_call_without_new_line if !$?.success? 
     | 
| 
       16 
     | 
    
         
            -
                            system_call_without_new_line.split(/\n/) 
     | 
| 
      
 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
         
     | 
    
        data/lib/systemdy/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       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 
     | 
    
         
            +
            date: 2022-10-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            email: magic4dev@gmail.com
         
     |