vfs 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +2 -2
  2. data/lib/vfs.rb +18 -0
  3. data/lib/vfs/entries/dir.rb +272 -0
  4. data/lib/vfs/entries/entry.rb +127 -0
  5. data/lib/vfs/entries/file.rb +185 -0
  6. data/lib/vfs/entries/universal_entry.rb +24 -0
  7. data/lib/vfs/entry_proxy.rb +38 -0
  8. data/lib/vfs/error.rb +4 -0
  9. data/lib/vfs/integration/string.rb +19 -0
  10. data/lib/vfs/path.rb +125 -0
  11. data/lib/vfs/storages/hash_fs.rb +194 -0
  12. data/lib/vfs/storages/local.rb +138 -0
  13. data/lib/vfs/storages/specification.rb +127 -0
  14. data/lib/vfs/support.rb +2 -0
  15. data/readme.md +110 -14
  16. data/spec/container_spec.rb +31 -0
  17. data/spec/dir_spec.rb +224 -0
  18. data/spec/entry_spec.rb +24 -0
  19. data/spec/file_spec.rb +189 -0
  20. data/spec/path_spec.rb +121 -0
  21. data/spec/spec_helper.rb +2 -9
  22. data/spec/storages/hash_fs_spec.rb +10 -0
  23. data/spec/storages/local_spec.rb +10 -0
  24. data/spec/universal_entry_spec.rb +42 -0
  25. metadata +25 -23
  26. data/lib/old/ssh.rb +0 -11
  27. data/lib/rsh.rb +0 -19
  28. data/lib/rsh/box.rb +0 -182
  29. data/lib/rsh/box/marks.rb +0 -29
  30. data/lib/rsh/drivers/abstract.rb +0 -15
  31. data/lib/rsh/drivers/local.rb +0 -48
  32. data/lib/rsh/drivers/ssh.rb +0 -147
  33. data/lib/rsh/gems.rb +0 -2
  34. data/lib/rsh/support.rb +0 -30
  35. data/spec/abstract_driver.rb +0 -82
  36. data/spec/abstract_driver/dir/dir2/file +0 -0
  37. data/spec/abstract_driver/local_file +0 -1
  38. data/spec/box_spec.rb +0 -109
  39. data/spec/box_spec/dir/dir2/file +0 -0
  40. data/spec/box_spec/local_file +0 -1
  41. data/spec/config.example.yml +0 -4
  42. data/spec/config.yml +0 -5
  43. data/spec/local_driver_spec.rb +0 -9
  44. data/spec/ssh_driver_spec.rb +0 -15
data/lib/rsh/gems.rb DELETED
@@ -1,2 +0,0 @@
1
- gem 'net-ssh'
2
- gem 'net-sftp'
data/lib/rsh/support.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'fileutils'
2
- require 'net/ssh'
3
- require 'net/sftp'
4
-
5
- # class File
6
- # class << self
7
- # def ensure_dir_exist directory, options = {}
8
- # options = options.symbolize_keys
9
- # clean = options.delete :clean
10
- # raise "unsupported options #{options.keys}!" unless options.empty?
11
- #
12
- # FileUtils.rm_r directory, :force => true if clean and File.exist?(directory)
13
- # FileUtils.mkdir_p directory
14
- # end
15
- #
16
- # def copy_dir_content from, to
17
- # Dir.glob "#{from}/*" do |item|
18
- # FileUtils.cp_r item, to
19
- # end
20
- # end
21
- #
22
- # def copy_dir from, to
23
- # FileUtils.cp_r from, to
24
- # end
25
- #
26
- # def remove_dir dir
27
- # FileUtils.rm_r dir
28
- # end
29
- # end
30
- # end
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for 'abstract driver' do
4
- dir = "#{File.dirname __FILE__}/abstract_driver"
5
- with_tmp_spec_dir dir, before: :each
6
-
7
- describe "io" do
8
- before :each do
9
- @local_dir = spec_dir
10
- @remote_dir = @driver.generate_tmp_dir_name
11
-
12
- @driver.remove_directory @remote_dir if @driver.directory_exist? @remote_dir
13
- @driver.create_directory @remote_dir
14
- end
15
-
16
- after :each do
17
- @driver.remove_directory @remote_dir if @driver.directory_exist? @remote_dir
18
- end
19
-
20
- describe "files" do
21
- before :each do
22
- @local_file = "#{@local_dir}/local_file"
23
- @check_file = "#{@local_dir}/check_file"
24
- @remote_file = "#{@remote_dir}/remote_file"
25
- end
26
-
27
- it "file_exist?" do
28
- @driver.file_exist?(@remote_file).should be_false
29
- @driver.upload_file(@local_file, @remote_file)
30
- @driver.file_exist?(@remote_file).should be_true
31
- end
32
-
33
- it "upload & download file" do
34
- @driver.upload_file(@local_file, @remote_file)
35
- @driver.file_exist?(@remote_file).should be_true
36
-
37
- @driver.download_file(@remote_file, @check_file)
38
- File.read(@local_file).should == File.read(@check_file)
39
- end
40
-
41
- it "remove_file" do
42
- @driver.upload_file(@local_file, @remote_file)
43
- @driver.file_exist?(@remote_file).should be_true
44
- @driver.remove_file(@remote_file)
45
- @driver.file_exist?(@remote_file).should be_false
46
- end
47
- end
48
-
49
- describe 'directories' do
50
- before :each do
51
- @from_local, @remote_path, @to_local = "#{@local_dir}/dir", "#{@remote_dir}/upload", "#{@local_dir}/download"
52
- end
53
-
54
- it "directory_exist?, create_directory, remove_directory" do
55
- dir = "#{@remote_dir}/some_dir"
56
- @driver.directory_exist?(dir).should be_false
57
- @driver.create_directory(dir)
58
- @driver.directory_exist?(dir).should be_true
59
- @driver.remove_directory(dir)
60
- @driver.directory_exist?(dir).should be_false
61
- end
62
-
63
- it "upload_directory & download_directory" do
64
- upload_path_check = "#{@remote_path}/dir2/file"
65
- @driver.file_exist?(upload_path_check).should be_false
66
- @driver.upload_directory(@from_local, @remote_path)
67
- @driver.file_exist?(upload_path_check).should be_true
68
-
69
- download_path_check = "#{@to_local}/dir2/file"
70
- File.exist?(download_path_check).should be_false
71
- @driver.download_directory(@remote_path, @to_local)
72
- File.exist?(download_path_check).should be_true
73
- end
74
- end
75
- end
76
-
77
- describe "shell" do
78
- it 'exec' do
79
- @driver.exec("echo 'ok'").should == [0, "ok\n", ""]
80
- end
81
- end
82
- end
File without changes
@@ -1 +0,0 @@
1
- some content
data/spec/box_spec.rb DELETED
@@ -1,109 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rsh::Box do
4
- with_tmp_spec_dir before: :each
5
-
6
- before :each do
7
- @box = Rsh::Box.new
8
-
9
- @local_dir = spec_dir
10
- @remote_dir = @box.generate_tmp_dir_name
11
-
12
- @box.remove_directory @remote_dir if @box.directory_exist? @remote_dir
13
- @box.create_directory @remote_dir
14
- end
15
-
16
- after :each do
17
- @box.remove_directory @remote_dir if @box.directory_exist? @remote_dir
18
- end
19
-
20
- describe "io" do
21
- describe "files" do
22
- before :each do
23
- @local_file = "#{@local_dir}/local_file"
24
- @check_file = "#{@local_dir}/check_file"
25
- @remote_file = "#{@remote_dir}/remote_file"
26
- end
27
-
28
- it "file_exist?" do
29
- @box.file_exist?(@remote_file).should be_false
30
- @box.upload_file(@local_file, @remote_file)
31
- @box.file_exist?(@remote_file).should be_true
32
- end
33
-
34
- it "upload_file" do
35
- @box.upload_file(@local_file, @remote_file)
36
- @box.file_exist?(@remote_file).should be_true
37
-
38
- lambda{@box.upload_file(@local_file, @remote_file)}.should raise_error(/exists/)
39
-
40
- # upload with override
41
- @box.upload_file(@local_file, @remote_file, override: true)
42
- @box.file_exist?(@remote_file).should be_true
43
- end
44
-
45
- it "download_file" do
46
- lambda{@box.download_file(@remote_file, @check_file)}.should raise_error(/not exists/)
47
- @box.upload_file(@local_file, @remote_file)
48
- @box.download_file(@remote_file, @check_file)
49
- File.read(@local_file).should == File.read(@check_file)
50
- end
51
-
52
- it "remove_file" do
53
- lambda{@box.remove_file(@remote_file)}.should raise_error(/not exists/)
54
- @box.upload_file(@local_file, @remote_file)
55
- @box.file_exist?(@remote_file).should be_true
56
- @box.remove_file(@remote_file)
57
- @box.file_exist?(@remote_file).should be_false
58
- end
59
- end
60
-
61
- describe 'directories' do
62
- before :each do
63
- @from_local, @remote_path, @to_local = "#{@local_dir}/dir", "#{@remote_dir}/upload", "#{@local_dir}/download"
64
- end
65
-
66
- it "directory_exist?" do
67
- @box.file_exist?(@remote_path).should be_false
68
- @box.upload_directory(@from_local, @remote_path)
69
- @box.file_exist?(@remote_path).should be_true
70
- end
71
-
72
- it "upload_directory" do
73
- @box.upload_directory(@from_local, @remote_path)
74
- @box.directory_exist?(@remote_path).should be_true
75
-
76
- lambda{@box.upload_directory(@from_local, @remote_path)}.should raise_error(/exists/)
77
-
78
- # upload with override
79
- @box.upload_directory(@from_local, @remote_path, override: true)
80
- @box.directory_exist?(@remote_path).should be_true
81
- end
82
-
83
- it "download_directory" do
84
- lambda{@box.download_directory(@remote_path, @to_local)}.should raise_error(/not exists/)
85
- @box.upload_directory(@from_local, @remote_path)
86
- @box.download_directory(@remote_path, @to_local)
87
- File.exist?("#{@to_local}/dir2/file").should be_true
88
- end
89
-
90
- it "remove_directory" do
91
- lambda{@box.remove_directory(@remote_path)}.should raise_error(/not exists/)
92
- @box.upload_directory(@from_local, @remote_path)
93
- @box.directory_exist?(@remote_path).should be_true
94
- @box.remove_directory(@remote_path)
95
- @box.directory_exist?(@remote_path).should be_false
96
- end
97
- end
98
- end
99
-
100
- describe "shell" do
101
- it 'bash' do
102
- @box.bash("echo 'ok'").should == "ok\n"
103
- end
104
-
105
- it "exec" do
106
- @box.exec("echo 'ok'").should == [0, "ok\n", ""]
107
- end
108
- end
109
- end
File without changes
@@ -1 +0,0 @@
1
- some content
@@ -1,4 +0,0 @@
1
- :ssh:
2
- :host: some_host.com
3
- :user: some_user
4
- :password: some_password
data/spec/config.yml DELETED
@@ -1,5 +0,0 @@
1
- :remote_driver:
2
- :host: universal.4ire.net
3
- :ssh:
4
- :user: root
5
- :password: privateprivate
@@ -1,9 +0,0 @@
1
- require 'abstract_driver'
2
-
3
- describe Rsh::Drivers::Local do
4
- it_should_behave_like "abstract driver"
5
-
6
- before :each do
7
- @driver = Rsh::Drivers::Local.new
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- require 'abstract_driver'
2
- require 'yaml'
3
-
4
- describe Rsh::Drivers::Ssh do
5
- it_should_behave_like "abstract driver"
6
-
7
- before :each do
8
- @driver = Rsh::Drivers::Ssh.new config[:remote_driver]
9
- @driver.open
10
- end
11
-
12
- after :each do
13
- @driver.close
14
- end
15
- end