activerecord-snapshot 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18d5d34a4ada1258ba348e7d97d4926c70a57830
4
- data.tar.gz: 39df59bd7e29419efe9cfd30288f9933ba122c03
3
+ metadata.gz: 5e940ac1dd6c0727931c63986fd0d9ab647a8a97
4
+ data.tar.gz: 581896f88fb4b33b80bdbf8332298dc1dbe01b96
5
5
  SHA512:
6
- metadata.gz: eded70402ecd026b2995eadc893d780e0e67244b307a6783d005a6fa0beecc002f7ee635eaa95d634638b6fbc420e6ee3f242300b7c3daa6c2982fc2ce1db658
7
- data.tar.gz: 1404fe17a689e44fb9cb00bf96a5f128b674d6468b96516f42d3e7285f47719ddd880f24c007698a07dc8d8027fb5cc1feb2ac1be3507d7ad4838947b759e1a9
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 Configuration < Hashie::Dash
13
- class S3Paths < Hashie::Dash
14
- include Hashie::Extensions::Dash::IndifferentAccess
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 < Hashie::Dash
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 < Hashie::Dash
32
- include Hashie::Extensions::Dash::IndifferentAccess
33
-
34
- def initialize(database_hash)
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 < Hashie::Dash
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 Hashie::Extensions::Dash::Coercion
53
- include Hashie::Extensions::Dash::IndifferentAccess
48
+ include Singleton
54
49
 
55
- def self.env
56
- ENV.fetch("SNAPSHOT_ENV", Rails.env)
50
+ def initialize
51
+ super(read_config_file)
52
+ @env = ENV.fetch("SNAPSHOT_ENV", Rails.env)
57
53
  end
58
54
 
59
- property :db, default: ->(_) { ::Rails.application.config.database_configuration[env] }, coerce: DBConfig
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
- def self.config_file
71
- ::Rails.root.join("config", "snapshot.yml")
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
- @config ||= Configuration.new(YAML.safe_load(ERB.new(::File.read(config_file)).result))
84
+ Configuration.instance
76
85
  end
77
86
  end
78
87
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Snapshot
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  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.1
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-20 00:00:00.000000000 Z
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.5.1
157
+ rubygems_version: 2.6.12
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Snapshots for ActiveRecord