fs-snapshot 0.1.2 → 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.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Aleksey Palazhchenko
1
+ Copyright (c) 2009-2010 Aleksey Palazhchenko
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,6 +1,28 @@
1
1
  = fs-snapshot
2
2
 
3
- Description goes here.
3
+ Tiny gem to manage directory snapshots.
4
+
5
+ It's helpful for tests when file system is used by external programs:
6
+ require 'test/unit'
7
+ require 'active_support'
8
+ require 'active_support/test_case'
9
+ require 'fs-snapshot'
10
+
11
+ class ActiveSupport::TestCase
12
+ @@snapshoter = FsSnapshoter.new '/var/db/repositories', '/tmp/snapshots'
13
+ SNAPSHOT_NAME = 'snap'
14
+
15
+ setup :take_snapshot
16
+ def take_snapshot
17
+ @@snapshoter.take(SNAPSHOT_NAME)
18
+ end
19
+
20
+ teardown :restore_snapshot
21
+ def restore_snapshot
22
+ @@snapshoter.restore(SNAPSHOT_NAME)
23
+ @@snapshoter.delete(SNAPSHOT_NAME)
24
+ end
25
+ end
4
26
 
5
27
  == Note on Patches/Pull Requests
6
28
 
data/Rakefile CHANGED
@@ -5,12 +5,12 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "fs-snapshot"
8
- gem.summary = "Manages snapshots of the filesystem."
9
- gem.description = ""
10
- gem.email = "alek.silverstone@gmail.com"
8
+ gem.summary = "Tiny gem to manage directory snapshots."
9
+ gem.description = nil
10
+ gem.email = "alek@silverstone.name"
11
11
  gem.homepage = "http://github.com/AlekSi/fs-snapshot"
12
12
  gem.authors = ["Aleksey Palazhchenko"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
13
+ gem.add_development_dependency "shoulda"
14
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
15
  end
16
16
  Jeweler::GemcutterTasks.new
@@ -34,7 +34,7 @@ begin
34
34
  end
35
35
  rescue LoadError
36
36
  task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ abort "RCov is not available. In order to run rcov, you must: gem install rcov"
38
38
  end
39
39
  end
40
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/fs-snapshot.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fs-snapshot}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aleksey Palazhchenko"]
12
- s.date = %q{2009-12-04}
12
+ s.date = %q{2010-01-19}
13
13
  s.description = %q{}
14
- s.email = %q{alek.silverstone@gmail.com}
14
+ s.email = %q{alek@silverstone.name}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
35
  s.rubygems_version = %q{1.3.5}
36
- s.summary = %q{Manages snapshots of the filesystem.}
36
+ s.summary = %q{Tiny gem to manage directory snapshots.}
37
37
  s.test_files = [
38
38
  "test/helper.rb",
39
39
  "test/test_fs-snapshoter.rb"
@@ -44,12 +44,12 @@ Gem::Specification.new do |s|
44
44
  s.specification_version = 3
45
45
 
46
46
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
48
  else
49
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ s.add_dependency(%q<shoulda>, [">= 0"])
50
50
  end
51
51
  else
52
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
53
  end
54
54
  end
55
55
 
@@ -16,7 +16,7 @@ class FsSnapshoter
16
16
 
17
17
  # Returns array of existing snapshots.
18
18
  def list
19
- @snapshots_dir.children(false).collect { |entry| entry.to_str }
19
+ @snapshots_dir.children(false).collect { |entry| entry.to_s }
20
20
  end
21
21
 
22
22
  # Takes a snapshot.
@@ -24,7 +24,7 @@ class FsSnapshoter
24
24
  raise "Snapshot already exists - '#{name}'!" if list.include? name
25
25
  dir = snapshot_dir(name)
26
26
  dir.mkdir
27
- FileUtils.cp_r @data_dir.to_str + '/.', dir
27
+ FileUtils.cp_r @data_dir.to_s + '/.', dir
28
28
  return true
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ class FsSnapshoter
32
32
  def restore(name)
33
33
  raise "No such snapshot - '#{name}'!" unless list.include? name
34
34
  FileUtils.rm_rf @data_dir
35
- FileUtils.cp_r snapshot_dir(name).to_str + '/.', @data_dir
35
+ FileUtils.cp_r snapshot_dir(name).to_s + '/.', @data_dir
36
36
  return true
37
37
  end
38
38
 
data/test/helper.rb CHANGED
@@ -2,10 +2,9 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
4
 
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'fs-snapshot'))
6
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'fs-snapshoter'
7
+ require 'fs-snapshot'
9
8
 
10
9
  class Test::Unit::TestCase
11
10
  end
@@ -1,5 +1,4 @@
1
1
  require 'helper'
2
- require 'tmpdir'
3
2
 
4
3
  class TestFsSnapshoter < Test::Unit::TestCase
5
4
 
@@ -13,8 +12,12 @@ class TestFsSnapshoter < Test::Unit::TestCase
13
12
  end
14
13
 
15
14
  def setup
16
- @data_dir = Pathname.new(Dir.mktmpdir ['fs-snap-', '-data'])
17
- @snapshots_dir = Pathname.new(Dir.mktmpdir ['fs-snap-', '-snapshots'])
15
+ require 'tmpdir'
16
+ data_dir = Dir.tmpdir + "/fs-snap-#{$$}-data"
17
+ snapshots_dir = Dir.tmpdir + "/fs-snap-#{$$}-snapshots"
18
+ Dir.mkdir(data_dir)
19
+ Dir.mkdir(snapshots_dir)
20
+ @data_dir, @snapshots_dir = Pathname.new(data_dir), Pathname.new(snapshots_dir)
18
21
  @snapshoter = FsSnapshoter.new @data_dir, @snapshots_dir
19
22
 
20
23
  # create test dir structure
@@ -38,8 +41,8 @@ class TestFsSnapshoter < Test::Unit::TestCase
38
41
  end
39
42
 
40
43
  should "return passed parameters" do
41
- assert_equal @data_dir, @snapshoter.data_dir
42
- assert_equal @snapshots_dir, @snapshoter.snapshots_dir
44
+ assert_contains [@data_dir, Pathname.new('/private' + @data_dir.to_s)], @snapshoter.data_dir
45
+ assert_contains [@snapshots_dir, Pathname.new('/private' + @snapshots_dir.to_s)], @snapshoter.snapshots_dir
43
46
  end
44
47
 
45
48
  should "return empty snapshots list" do
@@ -50,7 +53,7 @@ class TestFsSnapshoter < Test::Unit::TestCase
50
53
  setup do
51
54
  @snapshoter.take 'snap1'
52
55
  assert_equal ['snap1'], @snapshoter.list
53
- assert_equal ['snap1'], @snapshoter.snapshots_dir.children(false).collect { |entry| entry.to_str }
56
+ assert_equal ['snap1'], @snapshoter.snapshots_dir.children(false).collect { |entry| entry.to_s }
54
57
  end
55
58
 
56
59
  should "delete snapshot" do
@@ -67,15 +70,9 @@ class TestFsSnapshoter < Test::Unit::TestCase
67
70
  end
68
71
 
69
72
  should "raise exceptions" do
70
- assert_raise RuntimeError do
71
- @snapshoter.take('snap1')
72
- end
73
- assert_raise RuntimeError do
74
- @snapshoter.restore('no_such_snapshot')
75
- end
76
- assert_raise RuntimeError do
77
- @snapshoter.delete('no_such_snapshot')
78
- end
73
+ assert_raise(RuntimeError) { @snapshoter.take('snap1') }
74
+ assert_raise(RuntimeError) { @snapshoter.restore('no_such_snapshot') }
75
+ assert_raise(RuntimeError) { @snapshoter.delete('no_such_snapshot') }
79
76
  end
80
77
  end
81
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fs-snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Palazhchenko
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-04 00:00:00 +03:00
12
+ date: 2010-01-19 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
16
+ name: shoulda
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -23,7 +23,7 @@ dependencies:
23
23
  version: "0"
24
24
  version:
25
25
  description: ""
26
- email: alek.silverstone@gmail.com
26
+ email: alek@silverstone.name
27
27
  executables: []
28
28
 
29
29
  extensions: []
@@ -70,7 +70,7 @@ rubyforge_project:
70
70
  rubygems_version: 1.3.5
71
71
  signing_key:
72
72
  specification_version: 3
73
- summary: Manages snapshots of the filesystem.
73
+ summary: Tiny gem to manage directory snapshots.
74
74
  test_files:
75
75
  - test/helper.rb
76
76
  - test/test_fs-snapshoter.rb