trashman 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +5 -0
- data/lib/trashman/cli.rb +2 -0
- data/lib/trashman/manager.rb +7 -1
- data/lib/trashman/version_number.rb +1 -1
- data/spec/trashman/manager_spec.rb +9 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3123fcffadb2e8aaad277f3426254451f917496
|
4
|
+
data.tar.gz: cb7fe64a4ed48a8356f809976044b352bc140bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d72d011b6d7998e7360c00c73a228c320a82d89de1799c4c8e614d5290e800fba68635b9ee23c96170b7c4a4d3c2565c0e6ddfbe68ced3f3e7d3a6e9fd20e5bc
|
7
|
+
data.tar.gz: d928fa18b5d473297e3c7e17d53be90556464a15d37403a3b1d0cdd85b2fbcbc351672c40aef137c2f9adf94e2abb34f0a6b8b01ea165668e5c863e9b7af0a08
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# TrashMan
|
2
2
|
|
3
|
+
[![Build
|
4
|
+
Status](https://travis-ci.org/idealprojectgroup/trashman.svg?branch=master)](https://travis-ci.org/idealprojectgroup/trashman)
|
5
|
+
|
3
6
|
Removes outdated periodic backup files from your cloud storage bucket.
|
4
7
|
|
5
8
|
## Install
|
@@ -43,6 +46,8 @@ Options:
|
|
43
46
|
# Default: 100
|
44
47
|
--credentials=key:value # Credentials for your fog provider (depends on fog provider).
|
45
48
|
[--dry-run], [--no-dry-run] # As normal, but it does not destroy old backups.
|
49
|
+
[--pattern=PATTERN] # A regular expression to only consider
|
50
|
+
matching filenames for pruning.
|
46
51
|
```
|
47
52
|
|
48
53
|
## Contributors
|
data/lib/trashman/cli.rb
CHANGED
@@ -19,6 +19,8 @@ module TrashMan
|
|
19
19
|
desc: "Credentials for your fog provider (depends on fog provider)."
|
20
20
|
method_option :dry_run, type: :boolean, default: false,
|
21
21
|
desc: "As normal, but it does not destroy old backups."
|
22
|
+
method_option :pattern, type: :string,
|
23
|
+
desc: "A regular expression to only consider matching filenames for pruning."
|
22
24
|
def prune
|
23
25
|
if options.dry_run
|
24
26
|
say "This is a dry-run. No files will be deleted."
|
data/lib/trashman/manager.rb
CHANGED
@@ -38,7 +38,13 @@ module TrashMan
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def files
|
41
|
-
@files ||=
|
41
|
+
@files ||= begin
|
42
|
+
if options[:pattern]
|
43
|
+
container.files.select { |file| file.key =~ Regexp.new(options[:pattern]) }
|
44
|
+
else
|
45
|
+
container.files
|
46
|
+
end.sort_by { |file| file.key }
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
def queued_files
|
@@ -59,5 +59,14 @@ describe TrashMan::Manager do
|
|
59
59
|
|
60
60
|
TrashMan::Manager.new("rackspace", { credentials: {}, keep: 3, dry_run: true }).cleanup!
|
61
61
|
end
|
62
|
+
|
63
|
+
it "ignores files which don't match the pattern" do
|
64
|
+
backup = MockFogFile.new("anotherbackup.2014-12-31T10-00-01.tar.gz")
|
65
|
+
MockFogContainer.instance.files.unshift(backup)
|
66
|
+
expect(backup).to_not receive(:destroy)
|
67
|
+
|
68
|
+
TrashMan::Manager.new("rackspace", { credentials: {}, keep: 3, pattern: "\Abackup.*tgz\z" }).cleanup!
|
69
|
+
MockFogContainer.instance.files.shift
|
70
|
+
end
|
62
71
|
end
|
63
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trashman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Hopper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE
|
80
81
|
- README.md
|