dddr 1.1.2 → 1.1.4
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/lib/dddr/version.rb +1 -1
- data/lib/dddr.rb +18 -13
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a61d06c6ebc3616c3da5cb9529144c21227a87c9cc16066c3d30676f689d6315
         | 
| 4 | 
            +
              data.tar.gz: e3d69c17b85e80c0c8b78ed560c1921b4ccddb766908e2798b5fab10c998a009
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3439a0a2a18760fdc510927d336e3e42b17a1cb933f602f21e7ea938f60c8d8bcd4585f54d2f7fd44bcd9f12cee428e83c7b2b791aa7ea4b7b056035dd60ebbc
         | 
| 7 | 
            +
              data.tar.gz: 7a0bfeb34044c07b29a584f7000be838f0f2b48a0bc98d08e815f112ba4baf9b65b326e6c24627ae77f4ab6e90d811488a73e4ef885dc4b14d19c6d1dcc9d513
         | 
    
        data/lib/dddr/version.rb
    CHANGED
    
    
    
        data/lib/dddr.rb
    CHANGED
    
    | @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
            require "sdbm"
         | 
| 4 3 | 
             
            require "securerandom"
         | 
| 5 4 | 
             
            require "date"
         | 
| 6 5 | 
             
            require "ostruct"
         | 
| 6 | 
            +
            require "fileutils"
         | 
| 7 7 |  | 
| 8 8 | 
             
            require_relative "dddr/version"
         | 
| 9 9 |  | 
| @@ -68,19 +68,24 @@ module Dddr | |
| 68 68 | 
             
                    data_dir = Dddr.configuration.data_dir
         | 
| 69 69 | 
             
                    container = Dddr.configuration.container
         | 
| 70 70 | 
             
                    raise Dddr::Error, "Container name is required" unless container
         | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
                     | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 71 | 
            +
                  
         | 
| 72 | 
            +
                    # Construct the target directory path
         | 
| 73 | 
            +
                    @name = "#{data_dir}/#{container}/#{env}/#{entity_class.name.downcase}"
         | 
| 74 | 
            +
                  
         | 
| 75 | 
            +
                    begin
         | 
| 76 | 
            +
                      # Ensure all directories in the path are created
         | 
| 77 | 
            +
                      FileUtils.mkdir_p(@name)
         | 
| 78 | 
            +
                  
         | 
| 79 | 
            +
                      # Change ownership only if the path starts with "/var/"
         | 
| 80 | 
            +
                      if @name.start_with?("/var/")
         | 
| 81 | 
            +
                        FileUtils.chown_R(ENV["USER"], nil, @name)
         | 
| 80 82 | 
             
                      end
         | 
| 83 | 
            +
                    rescue Errno::ENOENT => e
         | 
| 84 | 
            +
                      # Log or handle the error
         | 
| 85 | 
            +
                      raise "Failed to create or access the directory: #{e.message}"
         | 
| 81 86 | 
             
                    end
         | 
| 82 | 
            -
                    @name = "#{data_dir}/#{container}/#{env}/#{entity_class.name.downcase}"
         | 
| 83 87 | 
             
                  end
         | 
| 88 | 
            +
                       
         | 
| 84 89 |  | 
| 85 90 | 
             
                  def count
         | 
| 86 91 | 
             
                    all.count
         | 
| @@ -175,8 +180,8 @@ module Dddr | |
| 175 180 | 
             
                  self.uid = uid
         | 
| 176 181 | 
             
                  data_hash.each do |attribute, value|
         | 
| 177 182 | 
             
                    attribute = attribute.to_sym
         | 
| 178 | 
            -
                    if respond_to?("#{attribute}=")
         | 
| 179 | 
            -
                      send("#{attribute}=", value)
         | 
| 183 | 
            +
                    if respond_to?(:"#{attribute}=")
         | 
| 184 | 
            +
                      send(:"#{attribute}=", value)
         | 
| 180 185 | 
             
                    end
         | 
| 181 186 | 
             
                  end
         | 
| 182 187 | 
             
                end
         |