snapshot_archive 0.22.0 → 0.24.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: 3e179b4873e666798d64842c95ffc5ced090e86fd397662b2e8c0a82bcee44cd
4
- data.tar.gz: ca9d90deb6deba132cda08faa9a7a1e67fceb9a6e6bb3f6920d72e8a3472126d
3
+ metadata.gz: a3540549c3bf29dc56aa3c7c8455e00233cb0fbb6c41dcc6520501059641b789
4
+ data.tar.gz: d0fb23ec4ff95d45c3e7dedba14f17de9311ca837434264bd2bf34619dceb14b
5
5
  SHA512:
6
- metadata.gz: e985c80aff74be57d14dafad8f871ceb9eb9ff65a23e7f4509aa620cebc3413333ada392bc7152bc134a26e34a296daf51dd699f6d789d2370736926c6d5292d
7
- data.tar.gz: edf94735ecbba03ba4386d4b4b736e16ec99255c4ac7f39bfa47972515714377ce3e34a1b39a4632e84df65a130a642000cf8159310a277eea3ed71c2d4ee693
6
+ metadata.gz: ab1279db3293e46d6e798f2229e69cf7af42f212b250a6910ea20f0b4706a58ebec75afa1c7e2b57e0b921b5f32d6fa37648ffe341dc2d042872313798ff8095
7
+ data.tar.gz: 1d2e8638e15b9d46352e74c4b9d9da92d30f28cbf4e5fb391b70eaa0c03866846da2722955dd3def39cd56d7fc00f4004e5f1c0a512079a4ee4328ea417298b8
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
data/exe/snap CHANGED
@@ -98,9 +98,22 @@ module SnapshotArchive
98
98
  command(:list) do |c|
99
99
  c.syntax = "snap list"
100
100
  c.description = "List available snapshots"
101
+ c.option(
102
+ "-o NUMBER_OF_DAYS",
103
+ "--older-than-days NUMBER_OF_DAYS",
104
+ Numeric,
105
+ <<~TXT
106
+ Limit the list to snapshots older than NUMBER_OF_DAYS days. This can
107
+ be useful for identifying old snapshots to delete.
108
+
109
+ Defaults to 0.
110
+ TXT
111
+ )
101
112
 
102
113
  c.action do |_args, options|
103
- SnapshotArchive::Cli.list
114
+ options.default(older_than_days: 0)
115
+
116
+ SnapshotArchive::Cli.list(older_than_days: options.older_than_days)
104
117
  end
105
118
  end
106
119
 
@@ -22,8 +22,8 @@ module SnapshotArchive
22
22
  Cfg.repository.restore(id)
23
23
  end
24
24
 
25
- def list
26
- Cfg.repository.list
25
+ def list(...)
26
+ Cfg.repository.list(...)
27
27
  end
28
28
 
29
29
  def show(id)
@@ -42,13 +42,16 @@ module SnapshotArchive
42
42
  Cfg.shell.info("Restored snapshot: #{id}")
43
43
  end
44
44
 
45
- def list
45
+ def list(older_than_days:)
46
46
  snapshots = (
47
47
  Dir
48
48
  .glob(File.join(path, "**/metadata.json"))
49
49
  .map { |metadata| JSON.parse(File.read(metadata)) }
50
50
  .sort_by { |metadata| metadata.fetch("timestamp") }
51
51
  .reverse
52
+ .select { |m|
53
+ Time.parse(m.fetch("timestamp")) < (Time.now - (older_than_days.to_i * 24 * 60 * 60))
54
+ }
52
55
  )
53
56
 
54
57
  if snapshots.count > 0
@@ -56,7 +59,7 @@ module SnapshotArchive
56
59
  Formatters::List.call(metadata)
57
60
  end
58
61
  else
59
- Cfg.shell.info("No snapshots in archive")
62
+ Cfg.shell.info("No snapshots found")
60
63
  end
61
64
  end
62
65
 
@@ -16,9 +16,9 @@ module SnapshotArchive
16
16
  def run(cmd)
17
17
  debug(cmd)
18
18
 
19
- `#{cmd}`
19
+ `#{cmd} 2>&1`
20
20
  .split("\n")
21
- .tap { raise CommandFailureError.new(cmd) unless $? == 0 }
21
+ .tap { raise CommandFailureError.new([cmd, _1].join("\n---\n")) unless $? == 0 }
22
22
  end
23
23
 
24
24
  def warn(msg)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnapshotArchive
4
- VERSION = "0.22.0"
4
+ VERSION = "0.24.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-20 00:00:00.000000000 Z
11
+ date: 2024-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -37,7 +37,6 @@ files:
37
37
  - ".ruby-version"
38
38
  - CODE_OF_CONDUCT.md
39
39
  - Gemfile
40
- - Gemfile.lock
41
40
  - LICENSE.txt
42
41
  - README.md
43
42
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,46 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- snapshot_archive (0.7.0)
5
- commander (~> 4.5)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- commander (4.6.0)
12
- highline (~> 2.0.0)
13
- highline (2.0.3)
14
- parallel (1.22.1)
15
- parser (3.1.1.0)
16
- ast (~> 2.4.1)
17
- rainbow (3.1.1)
18
- rake (13.0.6)
19
- regexp_parser (2.3.0)
20
- rexml (3.2.5)
21
- rubocop (1.27.0)
22
- parallel (~> 1.10)
23
- parser (>= 3.1.0.0)
24
- rainbow (>= 2.2.2, < 4.0)
25
- regexp_parser (>= 1.8, < 3.0)
26
- rexml
27
- rubocop-ast (>= 1.16.0, < 2.0)
28
- ruby-progressbar (~> 1.7)
29
- unicode-display_width (>= 1.4.0, < 3.0)
30
- rubocop-ast (1.16.0)
31
- parser (>= 3.1.1.0)
32
- ruby-progressbar (1.11.0)
33
- unicode-display_width (2.1.0)
34
-
35
- PLATFORMS
36
- aarch64-linux
37
- x86_64-darwin-19
38
- x86_64-darwin-20
39
-
40
- DEPENDENCIES
41
- rake (~> 13.0)
42
- rubocop (~> 1.7)
43
- snapshot_archive!
44
-
45
- BUNDLED WITH
46
- 2.2.17