snapshot_archive 0.12.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: 3e3eaa6f260c80eb714a688799f0a463800077eb8d202992ed2edfc2016296b3
4
- data.tar.gz: 0a8402fc3878033c5d4f434147deb19a1df08d457e4282bb93f440a3579c0235
3
+ metadata.gz: 7c8a429af95388506fe67325d85ec86e603b37f67fbc1cac4550da0e42a8e74d
4
+ data.tar.gz: 3bffd5d06b37296c811c6207fd88d751c55599083f238b56d9cc0b39b378549d
5
5
  SHA512:
6
- metadata.gz: 222b817e448faadbaf70756c8fad317d02a05cede98faf4cac696f673e7baa1b1f5258f8f368d1e7bf6dd0a5f0753b119dabfc2ba43abdc6c2ec1ab4422fe4f9
7
- data.tar.gz: '0697be13fa4393b9125528165256ee7816e41135e61e4d98910a4b93a2e3b2f0a02751ec474f59cd83b77a10d453785d7a0f70d22a0948dbf86733ebfd1e28ee'
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
 
@@ -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.12.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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom