bibliotech 0.2.10 → 0.2.11

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
  SHA1:
3
- metadata.gz: 362f3dae672cae010fb9c54ce32f9efe63ed11ae
4
- data.tar.gz: b0ef186c4471df52e2823fdeca2e064a8830c6e7
3
+ metadata.gz: 78931ee4f81a0aad3515900a1ae81c8701e7d9a4
4
+ data.tar.gz: 1b041221fb2870192453e8b91593cd495e383303
5
5
  SHA512:
6
- metadata.gz: 4ae066bc0ad6d6ca7e68c78d123ee98405bcf9e94ebb837118db657deaf2bb5458800842fe14a505fe747c75e9fe51ef5cea695aeacd0ab3bf3c2a0e8675d09a
7
- data.tar.gz: 9b487de7b0a95505ac761879862c934ce6dd6ac69b3a730cdc58c2c9bfc7eb0cf7360e0a0be747a0ce0f22f2ac70dd25419dbebd17e78f00715c97b9064da40b
6
+ metadata.gz: a8f215b830a6bbcc1b38138e870cef3108d3b211f77f411be2a477a2cb6e60353efec6ab3feb25ec7faa59befb5be50339265f6a840b4d7fa1bca87b5174725c
7
+ data.tar.gz: 4367fbb3f7795f4c36cd72843df9fb505bcf45e1889dd3bc160346cabbd867f58ffac9a409172947af3cfc7eeff24713c5088e49274a1f4f63f2eb67a56de7d0
@@ -30,18 +30,17 @@ module BiblioTech
30
30
  def backup_needed?(time)
31
31
  most_recent = most_recent()
32
32
  return true if most_recent.nil?
33
- time - most_recent.timestamp < config.backup_frequency * 60
33
+ (time - most_recent.timestamp) > (config.backup_frequency * 60)
34
34
  end
35
35
 
36
36
  def list
37
- @list ||=
38
- begin
39
- list = PruneList.new(path, name).list
40
- schedules.each do |schedule|
41
- schedule.mark(list)
42
- end
43
- list
44
- end
37
+ @list ||= PruneList.new(path, name).list
38
+ end
39
+
40
+ def mark_list
41
+ schedules.each do |schedule|
42
+ schedule.mark(list)
43
+ end
45
44
  end
46
45
 
47
46
  def most_recent
@@ -55,6 +54,7 @@ module BiblioTech
55
54
  end
56
55
 
57
56
  def pruneable
57
+ mark_list
58
58
  list.select do |record|
59
59
  !record.keep?
60
60
  end
@@ -203,12 +203,16 @@ module BiblioTech
203
203
  end
204
204
 
205
205
  def each_prune_schedule
206
- local_get(:prune_schedule).each do |frequency, limit|
206
+ local_get(:prune_schedule).map do |frequency, limit|
207
207
  real_frequency = regularize_frequency(frequency)
208
208
  unless real_frequency % backup_frequency == 0
209
209
  raise "Pruning frequency #{real_frequency}:#{frequency} is not a multiple of backup frequency: #{backup_frequency}:#{local_get(:backup_frequency)}"
210
210
  end
211
- yield(real_frequency, limit)
211
+ [real_frequency, limit]
212
+ end.sort_by do |frequency, limit|
213
+ frequency
214
+ end.each do |frequency, limit|
215
+ yield(frequency, limit)
212
216
  end
213
217
  end
214
218
 
@@ -42,6 +42,25 @@ module BiblioTech
42
42
  end
43
43
  end
44
44
 
45
+ context "with a recent file" do
46
+ before :each do
47
+ sandbox.new :file => "db_backups/#{pruner.filename_for(Time.now.utc - 120)}"
48
+ end
49
+
50
+ it "should return false from #backup_needed?" do
51
+ expect(pruner.backup_needed?(Time.now.utc)).to be_falsey
52
+ end
53
+ end
54
+
55
+ context "with an old file" do
56
+ before :each do
57
+ sandbox.new :file => "db_backups/#{pruner.filename_for(Time.now.utc - (24 * 60 * 60 + 120))}"
58
+ end
59
+
60
+ it "should return true from #backup_needed?" do
61
+ expect(pruner.backup_needed?(Time.now.utc)).to be_truthy
62
+ end
63
+ end
45
64
  end
46
65
 
47
66
  describe Backups::PruneList do
@@ -89,7 +89,7 @@ module BiblioTech::Backups
89
89
  let(:frequency){ 60*8 }
90
90
  let(:test_jitter){ 60 }
91
91
 
92
- it "should mark 8 files kept" do
92
+ it "should mark 5 files kept" do
93
93
  expect(kept_files.count).to eql 5
94
94
  end
95
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliotech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Dorn
@@ -128,7 +128,7 @@ rdoc_options:
128
128
  - --main
129
129
  - doc/README
130
130
  - --title
131
- - bibliotech-0.2.10 Documentation
131
+ - bibliotech-0.2.11 Documentation
132
132
  require_paths:
133
133
  - lib/
134
134
  required_ruby_version: !ruby/object:Gem::Requirement