awshucks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CHANGES +4 -0
  2. data/LICENSE +19 -0
  3. data/README +32 -0
  4. data/Rakefile +14 -0
  5. data/TODO +143 -0
  6. data/bin/awshucks +10 -0
  7. data/lib/awshucks.rb +29 -0
  8. data/lib/awshucks/cli.rb +76 -0
  9. data/lib/awshucks/command.rb +98 -0
  10. data/lib/awshucks/commands.rb +3 -0
  11. data/lib/awshucks/commands/backup.rb +59 -0
  12. data/lib/awshucks/commands/backups.rb +25 -0
  13. data/lib/awshucks/commands/help.rb +22 -0
  14. data/lib/awshucks/commands/list.rb +39 -0
  15. data/lib/awshucks/commands/new_config.rb +36 -0
  16. data/lib/awshucks/commands/reset_metadata_cache.rb +38 -0
  17. data/lib/awshucks/commands/restore.rb +54 -0
  18. data/lib/awshucks/config.rb +83 -0
  19. data/lib/awshucks/ext.rb +23 -0
  20. data/lib/awshucks/file_info.rb +23 -0
  21. data/lib/awshucks/file_store.rb +111 -0
  22. data/lib/awshucks/gemspec.rb +48 -0
  23. data/lib/awshucks/scanner.rb +58 -0
  24. data/lib/awshucks/specification.rb +128 -0
  25. data/lib/awshucks/version.rb +18 -0
  26. data/resources/awshucks.yml +21 -0
  27. data/spec/awshucks_spec.rb +7 -0
  28. data/spec/cli_spec.rb +130 -0
  29. data/spec/command_spec.rb +111 -0
  30. data/spec/commands/backup_spec.rb +164 -0
  31. data/spec/commands/backups_spec.rb +41 -0
  32. data/spec/commands/help_spec.rb +42 -0
  33. data/spec/commands/list_spec.rb +77 -0
  34. data/spec/commands/new_config_spec.rb +102 -0
  35. data/spec/commands/reset_metadata_cache_spec.rb +93 -0
  36. data/spec/commands/restore_spec.rb +219 -0
  37. data/spec/config_spec.rb +152 -0
  38. data/spec/ext_spec.rb +28 -0
  39. data/spec/file_info_spec.rb +45 -0
  40. data/spec/file_store_spec.rb +352 -0
  41. data/spec/scanner_spec.rb +106 -0
  42. data/spec/spec_helper.rb +36 -0
  43. data/spec/specification_spec.rb +41 -0
  44. metadata +121 -0
@@ -0,0 +1,106 @@
1
+ require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
+
3
+ describe Awshucks::Scanner do
4
+
5
+ it "takes a directory and a list of ignore globs to new" do
6
+ Awshucks::Scanner.new('/dir', ['*.', 'CVS']).should be_instance_of(Awshucks::Scanner)
7
+ end
8
+
9
+ it "requires a directory, but the ignore list is optional" do
10
+ Awshucks::Scanner.new('/dir').should be_instance_of(Awshucks::Scanner)
11
+ end
12
+
13
+ end
14
+
15
+ describe Awshucks::Scanner, '.each_file' do
16
+
17
+ it "instantiates Awshucks::Scanner and calls the each_file instance method" do
18
+ @scanner = mock('scanner')
19
+ @scanner.should_receive(:each_file).and_yield(mock('info'))
20
+ Awshucks::Scanner.should_receive(:new).and_return(@scanner)
21
+ Awshucks::Scanner.each_file('/') {|info| }
22
+ end
23
+
24
+ end
25
+
26
+ describe Awshucks::Scanner, '#each_file' do
27
+
28
+ before(:each) do
29
+
30
+ # build up a mock filesystem
31
+ # /base/dir
32
+ # /. and /..
33
+ # /.dotfile # ignored file
34
+ # /file
35
+ # /symlink # ignored symlink
36
+ # /subdir
37
+ # /subdir/subfile
38
+ # /CVS # ignored directory
39
+
40
+ @stat = mock("File::Stat instance")
41
+ @stat.stub!(:symlink?).and_return(false)
42
+ @stat.stub!(:directory?).and_return(false)
43
+ @stat.stub!(:mtime).and_return(Time.now)
44
+ @stat.stub!(:size).and_return(12345)
45
+ @symlink_stat = mock("File::Stat instance")
46
+ @symlink_stat.stub!(:symlink?).and_return(true)
47
+ @symlink_stat.stub!(:directory?).and_return(false)
48
+ @dir_stat = mock("File::Stat instance")
49
+ @dir_stat.stub!(:symlink?).and_return(false)
50
+ @dir_stat.stub!(:directory?).and_return(true)
51
+
52
+ File.should_receive(:lstat).any_number_of_times.and_return do |path|
53
+ # puts "got #{path}"
54
+ case path
55
+ when '/base/dir/subdir', '/base/dir/CVS'
56
+ @dir_stat
57
+ when '/base/dir/symlink'
58
+ @symlink_stat
59
+ else
60
+ @stat
61
+ end
62
+ end
63
+
64
+ @base_dir = mock('base directory')
65
+ @subdir = mock('subdirectory')
66
+ @cvsdir = mock('CVS directory')
67
+
68
+ @base_dir.should_receive(:read).and_return('.', '..', '.dotfile', 'file', 'symlink', 'subdir', 'CVS', nil)
69
+ @subdir.should_receive(:read).and_return('.', '..', 'subfile', nil)
70
+ @cvsdir.should_receive(:read).any_number_of_times.and_return(nil)
71
+
72
+ Dir.should_receive(:open).with('/base/dir/').and_yield(@base_dir)
73
+ Dir.should_receive(:open).with('/base/dir/subdir').and_yield(@subdir)
74
+ Dir.should_receive(:open).at_most(1).with('/base/dir/CVS').and_yield(@cvsdir)
75
+
76
+ end
77
+
78
+ it "yields FileInfo objects for all entries, minus ignored files and directories" do
79
+ returning([]) do |yielded|
80
+ Awshucks::Scanner.new('/base/dir', ['.*', 'CVS']).each_file do |info|
81
+ info.should be_instance_of(Awshucks::FileInfo)
82
+ yielded << info.filename
83
+ end
84
+ end.should == %w(file subdir/subfile)
85
+ end
86
+
87
+ it "doesn't return '.' or '..' files" do
88
+ yielded = []
89
+ Awshucks::Scanner.new('/base/dir', ['.*', 'CVS']).each_file {|info| yielded << info.filename }
90
+ yielded.should_not include('.')
91
+ yielded.should_not include('..')
92
+ end
93
+
94
+ it "doesn't return symlinks" do
95
+ yielded = []
96
+ Awshucks::Scanner.new('/base/dir', ['.*', 'CVS']).each_file {|info| yielded << info.filename }
97
+ yielded.first.should_not include('symlink')
98
+ end
99
+
100
+ it "include all files if no ignore argument is provided" do
101
+ yielded = []
102
+ Awshucks::Scanner.new('/base/dir').each_file {|info| yielded << info.filename }
103
+ yielded.should == %w(.dotfile file subdir/subfile)
104
+ end
105
+
106
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'awshucks'
6
+
7
+ # TODO clean this file up...
8
+
9
+ module MiscHelpers
10
+ def fixture_path
11
+ File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
12
+ end
13
+
14
+ def fixture_file(filename)
15
+ File.join(fixture_path, filename)
16
+ end
17
+
18
+ end
19
+
20
+ module DummyFS
21
+
22
+ def dummy_fs_path
23
+ File.join(Awshucks::ROOT_DIR, 'spec', 'fixtures', 'dummy_fs')
24
+
25
+ # File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'dummy_fs'))
26
+ end
27
+
28
+ def dummy_file_path(filename)
29
+ File.join(dummy_fs_path, filename)
30
+ end
31
+
32
+ end
33
+
34
+ Spec::Runner.configure do |config|
35
+ config.include(DummyFS, MiscHelpers)
36
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
+
3
+ describe "Awshucks::SPEC" do
4
+
5
+ before(:each) do
6
+ @spec = Awshucks::SPEC
7
+ end
8
+
9
+ it "should include aws-s3 as a dependency" do
10
+ @spec.dependencies.map {|dep| dep.name}.should include('aws-s3')
11
+ end
12
+
13
+ # and, because 100% C0 code coverage is a happy feeling:
14
+ # but really, i shouldn't have to do this. bleh.
15
+
16
+ it "has a remote_root" do
17
+ @spec.remote_root.should == "/var/www/gforge-projects/awshucks/"
18
+ end
19
+
20
+ it "changes the remote root appropriately with a different rubyforge project" do
21
+ @spec.rubyforge_project = 'foo'
22
+ @spec.remote_root.should =~ /foo/
23
+ @spec.rubyforge_project = nil # side effects!
24
+ end
25
+
26
+ it "lists out the rdoc files" do
27
+ @spec.rdoc_files.should have_at_least(1).entry
28
+ end
29
+
30
+ it "has a remote rdoc location" do
31
+ @spec.remote_rdoc_location.should_not be_nil
32
+ end
33
+
34
+ it "has a remote coverage location" do
35
+ @spec.remote_coverage_location.should_not be_nil
36
+ end
37
+
38
+ it "has a remote site location" do
39
+ @spec.remote_site_location.should_not be_nil
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: awshucks
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-09-20 00:00:00 -06:00
8
+ summary: A Summary of awshucks.
9
+ require_paths:
10
+ - lib
11
+ email: nathan-ruby@otherward.net
12
+ homepage: http://awshucks.rubyforge.org/
13
+ rubyforge_project: awshucks
14
+ description: "TODO: A longer more detailed description of awshucks."
15
+ autorequire:
16
+ default_executable: awshucks
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Nathan Witmer
31
+ files:
32
+ - spec/awshucks_spec.rb
33
+ - spec/cli_spec.rb
34
+ - spec/command_spec.rb
35
+ - spec/commands/backup_spec.rb
36
+ - spec/commands/backups_spec.rb
37
+ - spec/commands/help_spec.rb
38
+ - spec/commands/list_spec.rb
39
+ - spec/commands/new_config_spec.rb
40
+ - spec/commands/reset_metadata_cache_spec.rb
41
+ - spec/commands/restore_spec.rb
42
+ - spec/config_spec.rb
43
+ - spec/ext_spec.rb
44
+ - spec/file_info_spec.rb
45
+ - spec/file_store_spec.rb
46
+ - spec/scanner_spec.rb
47
+ - spec/spec_helper.rb
48
+ - spec/specification_spec.rb
49
+ - CHANGES
50
+ - LICENSE
51
+ - Rakefile
52
+ - README
53
+ - TODO
54
+ - lib/awshucks/cli.rb
55
+ - lib/awshucks/command.rb
56
+ - lib/awshucks/commands/backup.rb
57
+ - lib/awshucks/commands/backups.rb
58
+ - lib/awshucks/commands/help.rb
59
+ - lib/awshucks/commands/list.rb
60
+ - lib/awshucks/commands/new_config.rb
61
+ - lib/awshucks/commands/reset_metadata_cache.rb
62
+ - lib/awshucks/commands/restore.rb
63
+ - lib/awshucks/commands.rb
64
+ - lib/awshucks/config.rb
65
+ - lib/awshucks/ext.rb
66
+ - lib/awshucks/file_info.rb
67
+ - lib/awshucks/file_store.rb
68
+ - lib/awshucks/gemspec.rb
69
+ - lib/awshucks/scanner.rb
70
+ - lib/awshucks/specification.rb
71
+ - lib/awshucks/version.rb
72
+ - lib/awshucks.rb
73
+ - resources/awshucks.yml
74
+ - bin/awshucks
75
+ test_files:
76
+ - spec/awshucks_spec.rb
77
+ - spec/cli_spec.rb
78
+ - spec/command_spec.rb
79
+ - spec/commands/backup_spec.rb
80
+ - spec/commands/backups_spec.rb
81
+ - spec/commands/help_spec.rb
82
+ - spec/commands/list_spec.rb
83
+ - spec/commands/new_config_spec.rb
84
+ - spec/commands/reset_metadata_cache_spec.rb
85
+ - spec/commands/restore_spec.rb
86
+ - spec/config_spec.rb
87
+ - spec/ext_spec.rb
88
+ - spec/file_info_spec.rb
89
+ - spec/file_store_spec.rb
90
+ - spec/scanner_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/specification_spec.rb
93
+ rdoc_options:
94
+ - --line-numbers
95
+ - --inline-source
96
+ - --main
97
+ - README
98
+ - --title
99
+ - "'awshucks -- A Summary of awshucks.'"
100
+ extra_rdoc_files:
101
+ - CHANGES
102
+ - LICENSE
103
+ - Rakefile
104
+ - README
105
+ - TODO
106
+ executables:
107
+ - awshucks
108
+ extensions: []
109
+
110
+ requirements: []
111
+
112
+ dependencies:
113
+ - !ruby/object:Gem::Dependency
114
+ name: aws-s3
115
+ version_requirement:
116
+ version_requirements: !ruby/object:Gem::Version::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.4.0
121
+ version: