trashman 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d5a7113f4f529dd666222dbed4816841d66e97d
4
- data.tar.gz: 7ad829a02a4b986b99a4333cabc5612b3d047b6c
3
+ metadata.gz: d3123fcffadb2e8aaad277f3426254451f917496
4
+ data.tar.gz: cb7fe64a4ed48a8356f809976044b352bc140bab
5
5
  SHA512:
6
- metadata.gz: ff9ea4453ea673b1e35883da5d29855da00cd374335f02d2a122bf1f453b11edfe83bdd20f6c812d4cf372e422af57bad94f9504897a0f55412d77bbbdfefc7d
7
- data.tar.gz: cb60bbbf0a9c0db585952964315bdc7f47ccd0396f0e8e62208f2a27f0673e9e433b1a934d4fbf54f7b743aa6dbc5412b5dae03b4bd6df7304315872ca32b0da
6
+ metadata.gz: d72d011b6d7998e7360c00c73a228c320a82d89de1799c4c8e614d5290e800fba68635b9ee23c96170b7c4a4d3c2565c0e6ddfbe68ced3f3e7d3a6e9fd20e5bc
7
+ data.tar.gz: d928fa18b5d473297e3c7e17d53be90556464a15d37403a3b1d0cdd85b2fbcbc351672c40aef137c2f9adf94e2abb34f0a6b8b01ea165668e5c863e9b7af0a08
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ - 2.1.7
5
+ - 2.0.0
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
@@ -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."
@@ -38,7 +38,13 @@ module TrashMan
38
38
  end
39
39
 
40
40
  def files
41
- @files ||= container.files.sort_by { |file| file.key }
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
@@ -1,7 +1,7 @@
1
1
  module TrashMan
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 1
4
+ MINOR = 2
5
5
  TINY = 0
6
6
  PRE = nil
7
7
 
@@ -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.1.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: 2015-10-16 00:00:00.000000000 Z
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