snapshot_archive 0.11.0 → 0.13.0

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
  SHA256:
3
- metadata.gz: 994084b5ec3f9502e482da4842450e634dc6a5aeef20a2ad114273197a34d058
4
- data.tar.gz: 2e6d22fa72a1e146eed5004e693d01bd16062bd5a28e87588712ed7c77a6e268
3
+ metadata.gz: 7c8a429af95388506fe67325d85ec86e603b37f67fbc1cac4550da0e42a8e74d
4
+ data.tar.gz: 3bffd5d06b37296c811c6207fd88d751c55599083f238b56d9cc0b39b378549d
5
5
  SHA512:
6
- metadata.gz: 7086c92ca86e1af94d5ddd3dc5ce863d646d67392ef61cda16562b42a8c214e185df006f561d46bd565782d4208dfbb8c82b8018fc494fa7fd5d5819be9918fc
7
- data.tar.gz: 28e34f40111454d50982e8cc3d715f3371d97c04638358244143dfbd5c03cb777176e5ba65075e52b168a03f4415e28e9de9273e29963e808390c7af0cfc2491
6
+ metadata.gz: 26befeebb1559a46e2cb5d6537b89ad2d23835ddd6add79c9a48b9049a0633630504ed1c15d3ca5e0da79b75ebed0aa481789bdf560f15dc970085bc5aedd40b
7
+ data.tar.gz: f037383fe511d4c17b82104792a4f3f9d2d8873b81edef58526cae776ddb8df6e0fda2ef77c204d5873f0c67f6b2a21d6196e423864e19178cc5e4ed79a9f623
data/README.md CHANGED
@@ -130,14 +130,14 @@ SnapshotArchive.configure do |config|
130
130
  # Using an object:
131
131
 
132
132
  class MyCustomStore
133
- def backup(dir, args=[])
133
+ def backup(dir:, id:, args: [])
134
134
  path = File.join(dir, "my_custom_store.txt")
135
135
  File.write(path, "received args: #{args}")
136
136
 
137
137
  { "path" => path }
138
138
  end
139
139
 
140
- def restore(metadata)
140
+ def restore(metadata:)
141
141
  puts(File.read(metadata.fetch("path")))
142
142
  end
143
143
  end
@@ -148,14 +148,14 @@ SnapshotArchive.configure do |config|
148
148
  # Using the store builder:
149
149
 
150
150
  config.register_store("my_custom_store") do |store|
151
- store.backup do |dir, args=[]|
151
+ store.backup do |dir:, id:, args: []|
152
152
  path = File.join(dir, "my_custom_store.txt")
153
153
  File.write(path, "received args: #{args}")
154
154
 
155
155
  { "path" => path }
156
156
  end
157
157
 
158
- store.restore do |metadata|
158
+ store.restore do |metadata:|
159
159
  puts(File.read(metadata.fetch("path")))
160
160
  end
161
161
  end
@@ -1,14 +1,15 @@
1
1
  module SnapshotArchive
2
2
  module Archives
3
3
  class Builder
4
- def self.call(dir:, stores:)
5
- new(dir, stores).call
4
+ def self.call(dir:, stores:, id:)
5
+ new(dir, stores, id).call
6
6
  end
7
7
 
8
- attr_reader :dir, :stores
9
- def initialize(dir, stores)
8
+ attr_reader :dir, :stores, :id
9
+ def initialize(dir, stores, id)
10
10
  @dir = dir
11
11
  @stores = stores
12
+ @id = id
12
13
  end
13
14
 
14
15
  def call
@@ -18,7 +19,7 @@ module SnapshotArchive
18
19
  File
19
20
  .join(dir, name)
20
21
  .tap { FileUtils.mkdir(_1) }
21
- .then { store.backup(_1)&.merge(type: name) }
22
+ .then { store.backup(_1, id)&.merge(type: name) }
22
23
  }
23
24
  .compact
24
25
  )
@@ -10,16 +10,16 @@ module SnapshotArchive
10
10
  @delete = delete
11
11
  end
12
12
 
13
- def backup(dir)
14
- @backup&.call(dir)
13
+ def backup(...)
14
+ @backup&.call(...)
15
15
  end
16
16
 
17
- def restore(metadata)
18
- @restore&.call(metadata)
17
+ def restore(...)
18
+ @restore&.call(...)
19
19
  end
20
20
 
21
- def delete(metadata)
22
- @delete&.call(metadata)
21
+ def delete(...)
22
+ @delete&.call(...)
23
23
  end
24
24
  end
25
25
 
@@ -12,7 +12,7 @@ module SnapshotArchive
12
12
  timestamp = Time.now
13
13
  dir = mkdir(id)
14
14
 
15
- archive_metadata = Archives::Builder.call(dir: dir, stores: stores)
15
+ archive_metadata = Archives::Builder.call(id: id, dir: dir, stores: stores)
16
16
 
17
17
  Cfg.shell.debug("Using stores: #{stores.keys.join(", ")}")
18
18
 
@@ -21,6 +21,7 @@ module SnapshotArchive
21
21
  else
22
22
  metadata = {
23
23
  __schema__: SCHEMA,
24
+ __gem_version__: SnapshotArchive::VERSION,
24
25
  id: id,
25
26
  message: msg,
26
27
  timestamp: timestamp.utc.iso8601,
@@ -9,35 +9,40 @@ module SnapshotArchive
9
9
  @args = args
10
10
  end
11
11
 
12
- def backup(dir)
13
- store.backup(dir, args)
12
+ def backup(dir:, id:)
13
+ store.backup(dir: dir, id: id, args: args)
14
14
  end
15
15
 
16
- def restore(metadata)
17
- store.restore(metadata)
16
+ def restore(...)
17
+ store.restore(...)
18
+ end
19
+
20
+ def delete(...)
21
+ store.delete(...)
18
22
  end
19
23
  end
20
24
 
21
25
  module Mysql
22
26
  class << self
23
- def backup(dir, args)
24
- Backup.call(dir, args)
27
+ def backup(...)
28
+ Backup.call(...)
25
29
  end
26
30
 
27
- def restore(metadata)
28
- Restore.call(metadata)
31
+ def restore(...)
32
+ Restore.call(...)
29
33
  end
30
34
  end
31
35
 
32
36
  class Backup
33
- def self.call(dir, names)
34
- new(dir, names).call
37
+ def self.call(...)
38
+ new(...).call
35
39
  end
36
40
 
37
- attr_reader :dir, :names
38
- def initialize(dir, names)
41
+ attr_reader :dir, :names, :id
42
+ def initialize(dir:, id:, args:)
39
43
  @dir = dir
40
- @names = names
44
+ @id = id
45
+ @names = args
41
46
  end
42
47
 
43
48
  def call
@@ -61,12 +66,12 @@ module SnapshotArchive
61
66
  end
62
67
 
63
68
  class Restore
64
- def self.call(metadata)
65
- new(metadata).call
69
+ def self.call(...)
70
+ new(...).call
66
71
  end
67
72
 
68
73
  attr_reader :metadata
69
- def initialize(metadata)
74
+ def initialize(metadata:)
70
75
  @metadata = metadata
71
76
  end
72
77
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnapshotArchive
4
- VERSION = "0.11.0"
4
+ VERSION = "0.13.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom