engineyard-backup 0.0.1 → 0.0.2
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.
- data/README.txt +2 -3
- data/lib/backup/backup.rb +1 -1
- data/spec/backup/backup_spec.rb +12 -13
- data/spec/spec_helper.rb +2 -6
- metadata +13 -5
data/README.txt
CHANGED
@@ -7,8 +7,7 @@ A library to keep the latest X number of a file as backups
|
|
7
7
|
|
8
8
|
== FEATURES/PROBLEMS:
|
9
9
|
|
10
|
-
|
11
|
-
FIXME: Make releases an instance variable, not a constant
|
10
|
+
None as yet.
|
12
11
|
|
13
12
|
== SYNOPSIS:
|
14
13
|
|
@@ -19,7 +18,7 @@ FIXME: Make releases an instance variable, not a constant
|
|
19
18
|
|
20
19
|
== REQUIREMENTS:
|
21
20
|
|
22
|
-
|
21
|
+
mocha
|
23
22
|
|
24
23
|
== INSTALL:
|
25
24
|
|
data/lib/backup/backup.rb
CHANGED
data/spec/backup/backup_spec.rb
CHANGED
@@ -14,34 +14,36 @@ describe Backup do
|
|
14
14
|
it "should take 1 argument of a filename" do
|
15
15
|
lambda { Backup.new }.should raise_error(ArgumentError)
|
16
16
|
lambda { Backup.new("something") }.should raise_error("No such file found")
|
17
|
-
File.
|
17
|
+
File.expects(:file?).returns(true)
|
18
18
|
lambda { Backup.new("something") }.should_not raise_error
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "and passed a valid filename" do
|
22
22
|
before(:each) do
|
23
|
-
File.
|
24
|
-
Dir.
|
23
|
+
File.expects(:file?).at_least_once.returns(true)
|
24
|
+
Dir.stubs(:glob).returns( valid_backups )
|
25
25
|
@backup = Backup.new("my.cnf")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should save a new file and delete all backups out of the threshold" do
|
29
|
-
FileUtils.
|
30
|
-
|
29
|
+
FileUtils.expects(:mv).times(1)
|
30
|
+
valid_backups(9, :chronological).last(4).each do |backup|
|
31
|
+
File.expects(:delete).with(backup).returns(1)
|
32
|
+
end
|
31
33
|
@backup.run
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should not raise errors with zero current backups" do
|
35
|
-
Dir.
|
36
|
-
FileUtils.
|
37
|
-
File.
|
37
|
+
Dir.stubs(:glob).returns( [] )
|
38
|
+
FileUtils.expects(:mv)
|
39
|
+
File.expects(:delete).times(0).returns(1)
|
38
40
|
@backup.run
|
39
41
|
end
|
40
42
|
|
41
43
|
describe "which returns a valid glob of files" do
|
42
44
|
|
43
45
|
before(:each) do
|
44
|
-
Dir.
|
46
|
+
Dir.stubs(:glob).returns( valid_backups )
|
45
47
|
@backup = Backup.new("my.cnf")
|
46
48
|
@backup.find_all_releases
|
47
49
|
end
|
@@ -69,11 +71,8 @@ describe Backup do
|
|
69
71
|
|
70
72
|
describe "which returns an invalid glob of files" do
|
71
73
|
|
72
|
-
before(:each) do
|
73
|
-
Dir.stub!(:glob).and_return( invalid_backups(3) )
|
74
|
-
end
|
75
|
-
|
76
74
|
it "should handle incorrectly named files gracefully" do
|
75
|
+
Dir.stubs(:glob).returns( invalid_backups(3) )
|
77
76
|
lambda { Backup.new("my.cnf") }.should_not raise_error(ArgumentError)
|
78
77
|
end
|
79
78
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
1
|
Spec::Runner.configure do |config|
|
4
2
|
# == Mock Framework
|
5
3
|
#
|
6
4
|
# RSpec uses it's own mocking framework by default. If you prefer to
|
7
5
|
# use mocha, flexmock or RR, uncomment the appropriate line:
|
8
6
|
#
|
9
|
-
|
7
|
+
config.mock_with :mocha
|
10
8
|
# config.mock_with :flexmock
|
11
9
|
# config.mock_with :rr
|
12
|
-
end
|
13
|
-
|
14
|
-
# EOF
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie van Dyke
|
@@ -9,10 +9,18 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mocha
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.5.6
|
23
|
+
version:
|
16
24
|
description: Backup is a Ruby library to ease the backup of files, keeping the latest X releases. Just require it and go.
|
17
25
|
email: jvandyke@engineyard.com
|
18
26
|
executables: []
|
@@ -72,6 +80,6 @@ rubyforge_project:
|
|
72
80
|
rubygems_version: 1.0.1
|
73
81
|
signing_key:
|
74
82
|
specification_version: 2
|
75
|
-
summary: A library
|
83
|
+
summary: A library that allows you to backup a file from within your own code.
|
76
84
|
test_files:
|
77
85
|
- spec/backup/backup_spec.rb
|