vfs 0.0.4 → 0.1.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/Rakefile +2 -2
- data/lib/vfs.rb +18 -0
- data/lib/vfs/entries/dir.rb +272 -0
- data/lib/vfs/entries/entry.rb +127 -0
- data/lib/vfs/entries/file.rb +185 -0
- data/lib/vfs/entries/universal_entry.rb +24 -0
- data/lib/vfs/entry_proxy.rb +38 -0
- data/lib/vfs/error.rb +4 -0
- data/lib/vfs/integration/string.rb +19 -0
- data/lib/vfs/path.rb +125 -0
- data/lib/vfs/storages/hash_fs.rb +194 -0
- data/lib/vfs/storages/local.rb +138 -0
- data/lib/vfs/storages/specification.rb +127 -0
- data/lib/vfs/support.rb +2 -0
- data/readme.md +110 -14
- data/spec/container_spec.rb +31 -0
- data/spec/dir_spec.rb +224 -0
- data/spec/entry_spec.rb +24 -0
- data/spec/file_spec.rb +189 -0
- data/spec/path_spec.rb +121 -0
- data/spec/spec_helper.rb +2 -9
- data/spec/storages/hash_fs_spec.rb +10 -0
- data/spec/storages/local_spec.rb +10 -0
- data/spec/universal_entry_spec.rb +42 -0
- metadata +25 -23
- data/lib/old/ssh.rb +0 -11
- data/lib/rsh.rb +0 -19
- data/lib/rsh/box.rb +0 -182
- data/lib/rsh/box/marks.rb +0 -29
- data/lib/rsh/drivers/abstract.rb +0 -15
- data/lib/rsh/drivers/local.rb +0 -48
- data/lib/rsh/drivers/ssh.rb +0 -147
- data/lib/rsh/gems.rb +0 -2
- data/lib/rsh/support.rb +0 -30
- data/spec/abstract_driver.rb +0 -82
- data/spec/abstract_driver/dir/dir2/file +0 -0
- data/spec/abstract_driver/local_file +0 -1
- data/spec/box_spec.rb +0 -109
- data/spec/box_spec/dir/dir2/file +0 -0
- data/spec/box_spec/local_file +0 -1
- data/spec/config.example.yml +0 -4
- data/spec/config.yml +0 -5
- data/spec/local_driver_spec.rb +0 -9
- data/spec/ssh_driver_spec.rb +0 -15
data/lib/rsh/gems.rb
DELETED
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
|
data/spec/abstract_driver.rb
DELETED
@@ -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
|
data/spec/box_spec/dir/dir2/file
DELETED
File without changes
|
data/spec/box_spec/local_file
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
some content
|
data/spec/config.example.yml
DELETED
data/spec/config.yml
DELETED
data/spec/local_driver_spec.rb
DELETED
data/spec/ssh_driver_spec.rb
DELETED
@@ -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
|