snapshot_archive 0.22.0 → 0.23.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: f8135b5da8cb2ba0c10a0758f51885d7bc341bf70b3b1607f5b902cc10fc0e36
4
+ data.tar.gz: 29eb19fb7d5c4221eee6bbf019121557f79129f8b76b2f3adf619c95dd08d31d
5
5
  SHA512:
6
- metadata.gz: e985c80aff74be57d14dafad8f871ceb9eb9ff65a23e7f4509aa620cebc3413333ada392bc7152bc134a26e34a296daf51dd699f6d789d2370736926c6d5292d
7
- data.tar.gz: edf94735ecbba03ba4386d4b4b736e16ec99255c4ac7f39bfa47972515714377ce3e34a1b39a4632e84df65a130a642000cf8159310a277eea3ed71c2d4ee693
6
+ metadata.gz: 58bc9e336c62afe9d94a7846f855e006556465ba8ba91c9385b6af5277838782c6568b93bbb4bb3ed94e7675807a87a11cc04d7f85277b75bf01224e426c2a76
7
+ data.tar.gz: aa4abe8a459183efe33c42c8c87dbf1f6cbf21523015e1910921f390c979b58f72f93a39e2e5b9587658d3d70da892aabbb1f916c76517a9a8c8596606d0d10e
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnapshotArchive
4
- VERSION = "0.22.0"
4
+ VERSION = "0.23.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.23.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