awesome_backup 0.0.0 → 0.0.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:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f4588641c8aae8f2c87f4c76e9d84daf09b070f5aba36b781e419608817fe8f3
         | 
| 4 | 
            +
              data.tar.gz: 7f82d8d87b3e25413319c3c6977b89f5f91776d4b8ad6c172ace1cfd4b460065
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 68ca5afd2fbcc7778535a47e76967f48df0aed5bec611f4c2414895774cac1601347ec253ce93a1e21545ddc8f345277b574f244e34852167b0677d4b2a98250
         | 
| 7 | 
            +
              data.tar.gz: 1580efb82ae1fc05df6d4287430bd17e7d93350224cf12ae313181a4a04f54d11e5e8d6395dd0470971210904b83f9f009f0645a94d5e8caa72945e6dedc1c7d
         | 
| @@ -1,20 +1,24 @@ | |
| 1 1 | 
             
            require "English"
         | 
| 2 2 |  | 
| 3 3 | 
             
            class AwesomeBackup::PostgresBackupService < AwesomeBackup::ApplicationService
         | 
| 4 | 
            -
              def  | 
| 5 | 
            -
                 | 
| 6 | 
            -
                 | 
| 4 | 
            +
              def perform
         | 
| 5 | 
            +
                run_command("#{pg_dump_command} > \"#{tempfile_path}\"")
         | 
| 6 | 
            +
                attach_file
         | 
| 7 | 
            +
                succeed!(backup: backup)
         | 
| 8 | 
            +
              end
         | 
| 7 9 |  | 
| 8 | 
            -
             | 
| 10 | 
            +
            private
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def attach_file
         | 
| 9 13 | 
             
                backup.file.attach(
         | 
| 10 14 | 
             
                  io: File.open(tempfile_path),
         | 
| 11 15 | 
             
                  filename: "database.dump"
         | 
| 12 16 | 
             
                )
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                succeed!(backup: backup)
         | 
| 15 17 | 
             
              end
         | 
| 16 18 |  | 
| 17 | 
            -
             | 
| 19 | 
            +
              def backup
         | 
| 20 | 
            +
                @backup ||= AwesomeBackup::PostgresBackup.create!
         | 
| 21 | 
            +
              end
         | 
| 18 22 |  | 
| 19 23 | 
             
              def database_config
         | 
| 20 24 | 
             
                @database_config ||= Rails.configuration.database_configuration.fetch(Rails.env)
         | 
| @@ -48,6 +52,13 @@ private | |
| 48 52 | 
             
                " -U \"#{database_config.fetch("username")}\"" if database_config["username"].present?
         | 
| 49 53 | 
             
              end
         | 
| 50 54 |  | 
| 55 | 
            +
              def run_command(command)
         | 
| 56 | 
            +
                result = `#{command}`
         | 
| 57 | 
            +
                raise "Command failed: #{result}" unless $CHILD_STATUS.exitstatus.zero?
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                result
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 51 62 | 
             
              def tempfile_path
         | 
| 52 63 | 
             
                @tempfile_path ||= "#{Dir.tmpdir}/#{SecureRandom.hex}.dump"
         | 
| 53 64 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: awesome_backup
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - kaspernj
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2021-10-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -205,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 205 205 | 
             
              requirements:
         | 
| 206 206 | 
             
              - - ">="
         | 
| 207 207 | 
             
                - !ruby/object:Gem::Version
         | 
| 208 | 
            -
                  version: ' | 
| 208 | 
            +
                  version: '2.5'
         | 
| 209 209 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 210 210 | 
             
              requirements:
         | 
| 211 211 | 
             
              - - ">="
         | 
| 212 212 | 
             
                - !ruby/object:Gem::Version
         | 
| 213 213 | 
             
                  version: '0'
         | 
| 214 214 | 
             
            requirements: []
         | 
| 215 | 
            -
            rubygems_version: 3.0. | 
| 215 | 
            +
            rubygems_version: 3.0.8
         | 
| 216 216 | 
             
            signing_key: 
         | 
| 217 217 | 
             
            specification_version: 4
         | 
| 218 218 | 
             
            summary: Make backups of your stuff in a simple way.
         |