activerecord-snapshot 0.3.1 → 0.3.2
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/active_record/snapshot/configuration.rb +34 -25
- data/lib/active_record/snapshot/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5e940ac1dd6c0727931c63986fd0d9ab647a8a97
         | 
| 4 | 
            +
              data.tar.gz: 581896f88fb4b33b80bdbf8332298dc1dbe01b96
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4c99693338d284f980b2d8a6a6c92475fbdbd43f2331853c16f0e92ddb71fa045890f23a80b6cfb60743808d33846de6ff4d738bbff637305df4a3a3db3ac55b
         | 
| 7 | 
            +
              data.tar.gz: 16be625dff9065a4862887082953c3a320645853c87eb4c1a6a0cee4e37db9eb62f421702ad205b65003bc9438693d68df6aea9d9474dfe2dfd141fb9248b9d3
         | 
| @@ -9,18 +9,18 @@ require "hashie" | |
| 9 9 |  | 
| 10 10 | 
             
            module ActiveRecord
         | 
| 11 11 | 
             
              module Snapshot
         | 
| 12 | 
            -
                class  | 
| 13 | 
            -
                   | 
| 14 | 
            -
             | 
| 12 | 
            +
                class ConfigClass < Hashie::Dash
         | 
| 13 | 
            +
                  include Hashie::Extensions::Dash::Coercion
         | 
| 14 | 
            +
                  include Hashie::Extensions::Dash::IndifferentAccess
         | 
| 15 | 
            +
                end
         | 
| 15 16 |  | 
| 17 | 
            +
                class Configuration < ConfigClass
         | 
| 18 | 
            +
                  class S3Paths < ConfigClass
         | 
| 16 19 | 
             
                    property :snapshots, required: true
         | 
| 17 20 | 
             
                    property :named_snapshots, required: true
         | 
| 18 21 | 
             
                  end
         | 
| 19 22 |  | 
| 20 | 
            -
                  class S3Config <  | 
| 21 | 
            -
                    include Hashie::Extensions::Dash::Coercion
         | 
| 22 | 
            -
                    include Hashie::Extensions::Dash::IndifferentAccess
         | 
| 23 | 
            -
             | 
| 23 | 
            +
                  class S3Config < ConfigClass
         | 
| 24 24 | 
             
                    property :access_key_id, required: true
         | 
| 25 25 | 
             
                    property :secret_access_key, required: true
         | 
| 26 26 | 
             
                    property :bucket, required: true
         | 
| @@ -28,11 +28,10 @@ module ActiveRecord | |
| 28 28 | 
             
                    property :paths, required: true, coerce: S3Paths
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 |  | 
| 31 | 
            -
                  class DBConfig <  | 
| 32 | 
            -
                     | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                      super database_hash.slice("database", "username", "password", "host")
         | 
| 31 | 
            +
                  class DBConfig < ConfigClass
         | 
| 32 | 
            +
                    def initialize(env)
         | 
| 33 | 
            +
                      database_hash = ::Rails.application.config.database_configuration[env]
         | 
| 34 | 
            +
                      super(database_hash.slice("database", "username", "password", "host"))
         | 
| 36 35 | 
             
                    end
         | 
| 37 36 |  | 
| 38 37 | 
             
                    property :database, required: true
         | 
| @@ -41,38 +40,48 @@ module ActiveRecord | |
| 41 40 | 
             
                    property :password
         | 
| 42 41 | 
             
                  end
         | 
| 43 42 |  | 
| 44 | 
            -
                  class StoreConfig <  | 
| 45 | 
            -
                    include Hashie::Extensions::Dash::Coercion
         | 
| 46 | 
            -
                    include Hashie::Extensions::Dash::IndifferentAccess
         | 
| 47 | 
            -
             | 
| 43 | 
            +
                  class StoreConfig < ConfigClass
         | 
| 48 44 | 
             
                    property :tmp, default: ->(_) { ::Rails.root.join("tmp/snapshots") }, coerce: Pathname
         | 
| 49 45 | 
             
                    property :local, default: ->(_) { ::Rails.root.join("db/snapshots") }, coerce: Pathname
         | 
| 50 46 | 
             
                  end
         | 
| 51 47 |  | 
| 52 | 
            -
                  include  | 
| 53 | 
            -
                  include Hashie::Extensions::Dash::IndifferentAccess
         | 
| 48 | 
            +
                  include Singleton
         | 
| 54 49 |  | 
| 55 | 
            -
                  def  | 
| 56 | 
            -
                     | 
| 50 | 
            +
                  def initialize
         | 
| 51 | 
            +
                    super(read_config_file)
         | 
| 52 | 
            +
                    @env = ENV.fetch("SNAPSHOT_ENV", Rails.env)
         | 
| 57 53 | 
             
                  end
         | 
| 58 54 |  | 
| 59 | 
            -
                   | 
| 55 | 
            +
                  attr_accessor :env
         | 
| 56 | 
            +
             | 
| 60 57 | 
             
                  property :s3, required: true, coerce: S3Config
         | 
| 61 58 | 
             
                  property :ssl_key, required: true
         | 
| 62 59 | 
             
                  property :tables, required: true
         | 
| 63 60 | 
             
                  property :store, coerce: StoreConfig
         | 
| 64 61 |  | 
| 62 | 
            +
                  def db
         | 
| 63 | 
            +
                    DBConfig.new(env)
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 65 66 | 
             
                  def adapter
         | 
| 66 67 | 
             
                    ActiveRecord::Snapshot::MySQL
         | 
| 67 68 | 
             
                  end
         | 
| 68 | 
            -
                end
         | 
| 69 69 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 70 | 
            +
                  private
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  def config_file
         | 
| 73 | 
            +
                    ::Rails.root.join("config", "snapshot.yml")
         | 
| 74 | 
            +
                  end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  def read_config_file
         | 
| 77 | 
            +
                    contents = File.read(config_file)
         | 
| 78 | 
            +
                    interpolated = ERB.new(contents).result
         | 
| 79 | 
            +
                    YAML.safe_load(interpolated)
         | 
| 80 | 
            +
                  end
         | 
| 72 81 | 
             
                end
         | 
| 73 82 |  | 
| 74 83 | 
             
                def self.config
         | 
| 75 | 
            -
                   | 
| 84 | 
            +
                  Configuration.instance
         | 
| 76 85 | 
             
                end
         | 
| 77 86 | 
             
              end
         | 
| 78 87 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: activerecord-snapshot
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bernardo Farah
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-06- | 
| 11 | 
            +
            date: 2017-06-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         | 
| @@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 154 154 | 
             
                  version: '0'
         | 
| 155 155 | 
             
            requirements: []
         | 
| 156 156 | 
             
            rubyforge_project: 
         | 
| 157 | 
            -
            rubygems_version: 2. | 
| 157 | 
            +
            rubygems_version: 2.6.12
         | 
| 158 158 | 
             
            signing_key: 
         | 
| 159 159 | 
             
            specification_version: 4
         | 
| 160 160 | 
             
            summary: Snapshots for ActiveRecord
         |