vfs 0.3.12 → 0.3.13
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/lib/vfs.rb +5 -5
- data/lib/vfs/entries/dir.rb +65 -65
- data/lib/vfs/entries/entry.rb +38 -38
- data/lib/vfs/entries/entry/special_attributes.rb +2 -2
- data/lib/vfs/entries/file.rb +46 -46
- data/lib/vfs/entries/universal_entry.rb +5 -5
- data/lib/vfs/entry_proxy.rb +10 -10
- data/lib/vfs/integration/string.rb +4 -4
- data/lib/vfs/path.rb +25 -25
- data/lib/vfs/storages/local.rb +29 -29
- data/lib/vfs/storages/specification.rb +27 -27
- data/lib/vfs/vfs.rb +7 -7
- data/readme.md +14 -35
- data/spec/container_spec.rb +5 -5
- data/spec/dir_spec.rb +49 -49
- data/spec/entry_spec.rb +9 -9
- data/spec/file_spec.rb +47 -47
- data/spec/path_spec.rb +31 -31
- data/spec/spec_helper.rb +11 -11
- data/spec/storages/local_spec.rb +4 -4
- data/spec/universal_entry_spec.rb +9 -9
- metadata +1 -1
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'rspec_ext'
|
3
3
|
require 'ruby_ext'
|
4
4
|
|
5
|
-
shared_examples_for 'vfs storage' do
|
5
|
+
shared_examples_for 'vfs storage' do
|
6
6
|
before do
|
7
7
|
@storage.open_fs do |fs|
|
8
8
|
@tmp_dir = fs.tmp
|
@@ -15,29 +15,29 @@ shared_examples_for 'vfs storage' do
|
|
15
15
|
fs.delete_dir @tmp_dir if attrs && attrs[:dir]
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it 'should respond to :local?' do
|
20
20
|
@storage.open_fs{|fs| fs.should respond_to(:local?)}
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it 'should respond to :host'
|
24
|
-
|
24
|
+
|
25
25
|
it 'should have root dir' do
|
26
26
|
@storage.open_fs do |fs|
|
27
27
|
fs.attributes('/').subset(:file, :dir).should == {file: false, dir: true}
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
describe "files" do
|
30
|
+
|
31
|
+
describe "files" do
|
32
32
|
before do
|
33
33
|
@remote_file = "#{@tmp_dir}/remote_file"
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "file attributes" do
|
37
37
|
@storage.open_fs do |fs|
|
38
38
|
fs.attributes(@remote_file).should == {}
|
39
39
|
fs.write_file(@remote_file, false){|w| w.write 'something'}
|
40
|
-
attrs = fs.attributes(@remote_file)
|
40
|
+
attrs = fs.attributes(@remote_file)
|
41
41
|
fs.attributes(@remote_file).subset(:file, :dir).should == {file: true, dir: false}
|
42
42
|
end
|
43
43
|
end
|
@@ -46,39 +46,39 @@ shared_examples_for 'vfs storage' do
|
|
46
46
|
@storage.open_fs do |fs|
|
47
47
|
fs.write_file(@remote_file, false){|w| w.write 'something'}
|
48
48
|
fs.attributes(@remote_file)[:file].should be_true
|
49
|
-
|
50
|
-
data = ""
|
49
|
+
|
50
|
+
data = ""
|
51
51
|
fs.read_file(@remote_file){|buff| data << buff}
|
52
52
|
data.should == 'something'
|
53
|
-
|
53
|
+
|
54
54
|
# append
|
55
55
|
fs.write_file(@remote_file, true){|w| w.write ' another'}
|
56
|
-
data = ""
|
56
|
+
data = ""
|
57
57
|
fs.read_file(@remote_file){|buff| data << buff}
|
58
58
|
data.should == 'something another'
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "delete_file" do
|
63
63
|
@storage.open_fs do |fs|
|
64
|
-
fs.write_file(@remote_file, false){|w| w.write 'something'}
|
64
|
+
fs.write_file(@remote_file, false){|w| w.write 'something'}
|
65
65
|
fs.attributes(@remote_file)[:file].should be_true
|
66
66
|
fs.delete_file(@remote_file)
|
67
67
|
fs.attributes(@remote_file).should == {}
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
describe 'directories' do
|
73
73
|
# before do
|
74
74
|
# @from_local, @remote_path, @to_local = "#{@local_dir}/dir", "#{@tmp_dir}/upload", "#{@local_dir}/download"
|
75
75
|
# end
|
76
|
-
|
76
|
+
|
77
77
|
before do
|
78
78
|
@remote_dir = "#{@tmp_dir}/some_dir"
|
79
79
|
end
|
80
|
-
|
81
|
-
it "directory_exist?, create_dir, delete_dir" do
|
80
|
+
|
81
|
+
it "directory_exist?, create_dir, delete_dir" do
|
82
82
|
@storage.open_fs do |fs|
|
83
83
|
fs.attributes(@remote_dir).should == {}
|
84
84
|
fs.create_dir(@remote_dir)
|
@@ -87,43 +87,43 @@ shared_examples_for 'vfs storage' do
|
|
87
87
|
fs.attributes(@remote_dir).should == {}
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it 'should delete not-empty directories' do
|
92
92
|
@storage.open_fs do |fs|
|
93
93
|
fs.create_dir(@remote_dir)
|
94
94
|
fs.create_dir("#{@remote_dir}/dir")
|
95
|
-
fs.write_file("#{@remote_dir}/dir/file", false){|w| w.write 'something'}
|
95
|
+
fs.write_file("#{@remote_dir}/dir/file", false){|w| w.write 'something'}
|
96
96
|
fs.delete_dir(@remote_dir)
|
97
97
|
fs.attributes(@remote_dir).should == {}
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
it 'each' do
|
102
102
|
@storage.open_fs do |fs|
|
103
103
|
list = {}
|
104
104
|
fs.each_entry(@tmp_dir, nil){|path, type| list[path] = type}
|
105
105
|
list.should be_empty
|
106
|
-
|
106
|
+
|
107
107
|
dir, file = "#{@tmp_dir}/dir", "#{@tmp_dir}/file"
|
108
108
|
fs.create_dir(dir)
|
109
109
|
fs.write_file(file, false){|w| w.write 'something'}
|
110
|
-
|
110
|
+
|
111
111
|
list = {}
|
112
112
|
fs.each_entry(@tmp_dir, nil){|path, type| list[path] = type}
|
113
113
|
list.should == {'dir' => :dir, 'file' => :file}
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
# it "upload_directory & download_directory" do
|
118
118
|
# upload_path_check = "#{@remote_path}/dir2/file"
|
119
|
-
# check_attributes upload_path_check, nil
|
119
|
+
# check_attributes upload_path_check, nil
|
120
120
|
# fs.upload_directory(@from_local, @remote_path)
|
121
121
|
# check_attributes upload_path_check, file: true, dir: false
|
122
|
-
#
|
122
|
+
#
|
123
123
|
# download_path_check = "#{@to_local}/dir2/file"
|
124
124
|
# File.exist?(download_path_check).should be_false
|
125
125
|
# fs.download_directory(@remote_path, @to_local)
|
126
126
|
# File.exist?(download_path_check).should be_true
|
127
127
|
# end
|
128
|
-
end
|
128
|
+
end
|
129
129
|
end
|
data/lib/vfs/vfs.rb
CHANGED
@@ -3,28 +3,28 @@ module Vfs
|
|
3
3
|
def default_storage
|
4
4
|
::Vfs::Storages::Local.new
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def to_entry
|
8
8
|
'/'.to_entry
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def to_file
|
12
12
|
to_entry.file
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def to_dir
|
16
16
|
to_entry.dir
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# def [] path
|
20
20
|
# to_entry[path]
|
21
21
|
# end
|
22
22
|
# alias_method :/, :[]
|
23
|
-
|
23
|
+
|
24
24
|
%w(
|
25
|
-
entry dir file
|
25
|
+
entry dir file
|
26
26
|
entries dirs files
|
27
|
-
[] /
|
27
|
+
[] /
|
28
28
|
tmp
|
29
29
|
).each do |m|
|
30
30
|
script = <<-RUBY
|
data/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Vfs - Virtual File System
|
2
2
|
|
3
|
-
Handy and simple abstraction over any storage that can represent concept of File and Directory (or at least part of it).
|
3
|
+
Handy and simple abstraction over any storage that can represent concept of File and Directory (or at least part of it).
|
4
4
|
The Vfs for File System is kinda the same as ActiveRecord is for Relational Databases.
|
5
5
|
|
6
6
|
Currently, there are following implementations available:
|
@@ -19,7 +19,7 @@ Currently, there are following implementations available:
|
|
19
19
|
**Performance**:
|
20
20
|
|
21
21
|
- sometimes there's extra call to check if file or dir exist before overriding it
|
22
|
-
- copy: it doesn't use FileUtils.cp_r, it walks on the directory tree and copy each entry individually, so it's probably a little slover.
|
22
|
+
- copy: right now it doesn't use FileUtils.cp_r, it walks on the directory tree and copy each entry individually, so it's probably a little slover.
|
23
23
|
- right now :move and :rename implemented ASAP by copy & destroy, will be fixed as soon as I'll have time to do it.
|
24
24
|
|
25
25
|
## Installation
|
@@ -33,7 +33,7 @@ $ gem install vos
|
|
33
33
|
|
34
34
|
``` ruby
|
35
35
|
gem 'vfs' # Virtual File System
|
36
|
-
require 'vfs'
|
36
|
+
require 'vfs'
|
37
37
|
|
38
38
|
gem 'vos' # Virtual Operating System
|
39
39
|
require 'vos'
|
@@ -42,7 +42,7 @@ require 'vos'
|
|
42
42
|
# Connections, let's deploy our 'cool_app' project from our local box to remote server
|
43
43
|
|
44
44
|
``` ruby
|
45
|
-
server = Box.new('cool_app.com') # it will use id_rsa, or You can add {user: 'me', password: 'secret'}
|
45
|
+
server = Box.new('cool_app.com') # it will use id_rsa, or You can add {user: 'me', password: 'secret'}
|
46
46
|
me = '~'.to_dir # handy shortcut for local FS
|
47
47
|
|
48
48
|
deploy_dir = server['apps/cool_app']
|
@@ -52,7 +52,7 @@ projects = me['projects']
|
|
52
52
|
# Working with dirs, copying dir from any source to any destination (local/remote/custom_storage_type)
|
53
53
|
|
54
54
|
``` ruby
|
55
|
-
projects['cool_app'].copy_to deploy_dir
|
55
|
+
projects['cool_app'].copy_to deploy_dir
|
56
56
|
```
|
57
57
|
|
58
58
|
# Working with files
|
@@ -65,12 +65,12 @@ dbc.append("\ndatabase: mysql") # let's do it
|
|
65
65
|
|
66
66
|
dbc.update do |content| # and add host info
|
67
67
|
content + "\nhost: cool_app.com "
|
68
|
-
end
|
68
|
+
end
|
69
69
|
|
70
70
|
projects['cool_app/config/database.yml']. # or just overwrite it with our local dev version
|
71
71
|
copy_to! dbc
|
72
72
|
```
|
73
|
-
|
73
|
+
|
74
74
|
There are also streaming support (read/write/append) with &block, please go to specs for details
|
75
75
|
|
76
76
|
# Checks
|
@@ -94,15 +94,15 @@ deploy_dir.dirs # => list of dirs, also support &bl
|
|
94
94
|
```
|
95
95
|
|
96
96
|
For more please go to specs (create/update/move/copy/destroy/...)
|
97
|
-
|
97
|
+
|
98
98
|
## Integration with [Vos][vos] (Virtual Operating System)
|
99
|
-
|
100
|
-
```ruby
|
99
|
+
|
100
|
+
```ruby
|
101
101
|
server['apps/cool_app'].bash 'rails production'
|
102
102
|
```
|
103
103
|
|
104
|
-
For more details please go to [Vos][vos] project page.
|
105
|
-
Or checkout configuration I use to control my production servers [My Cluster][my_cluster] in conjunction with small
|
104
|
+
For more details please go to [Vos][vos] project page.
|
105
|
+
Or checkout configuration I use to control my production servers [My Cluster][my_cluster] in conjunction with small
|
106
106
|
configuration tool [Cluster Management][cluster_management].
|
107
107
|
|
108
108
|
# Why?
|
@@ -114,31 +114,10 @@ is to provide 1-to-1 clone of underlying OS API, instead of provididing handy to
|
|
114
114
|
|
115
115
|
And if you want to use remote FS - things are getting even worse and more complicated (Net::SSH & Net::SFTP use a little
|
116
116
|
different API than local FS, and you has to remember all thouse little quirks).
|
117
|
-
|
118
|
-
## Roadmap
|
119
|
-
|
120
|
-
### some future
|
121
|
-
|
122
|
-
- add storages: Hadoop DFS, MongoDB, Amazon S3
|
123
|
-
|
124
|
-
### v 0.2
|
125
|
-
|
126
|
-
- refactor specs with :fakefs
|
127
|
-
- remove :host from Vfs to Vos
|
128
|
-
- efficient (not copy/destroy) versions of move_to, rename
|
129
|
-
- access via attributes and helpers for unix chmod
|
130
|
-
- add storages: remote FS over HTTP.
|
131
|
-
|
132
|
-
Done:
|
133
|
-
|
134
|
-
- glob search for directories: Dir['**/*.yml']
|
135
117
|
|
136
|
-
|
118
|
+
Copyright (c) Alexey Petrushin http://petrush.in, released under the MIT license.
|
137
119
|
|
138
|
-
|
139
|
-
- File.append
|
140
|
-
- list of entries/files/dirs
|
141
|
-
- support for efficient copy for Local and SSH storages
|
120
|
+
## Please let me know about bugs and Your proposals, there's the 'Issues' tab at the top, feel free to submit.
|
142
121
|
|
143
122
|
[vos]: http://github.com/alexeypetrushin/vos
|
144
123
|
[cluster_management]: http://github.com/alexeypetrushin/cluster_management
|
data/spec/container_spec.rb
CHANGED
@@ -2,26 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'Container' do
|
4
4
|
with_test_fs
|
5
|
-
|
5
|
+
|
6
6
|
it "should threat paths as UniversalEntry except it ends with '/'" do
|
7
7
|
test_fs.should_receive(:entry).with('tmp/a/b')
|
8
8
|
test_fs['tmp/a/b']
|
9
|
-
|
9
|
+
|
10
10
|
test_fs.should_receive(:dir).with('tmp/a/b')
|
11
11
|
test_fs['tmp/a/b/']
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it '/' do
|
15
15
|
test_fs[:some_path].should == test_fs / :some_path
|
16
16
|
test_fs[:some_path][:another_path].should == test_fs / :some_path / :another_path
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "UniversalEntry should be wrapped inside of proxy, Dir and File should not" do
|
20
20
|
-> {test_fs.dir.proxy?}.should raise_error(NoMethodError)
|
21
21
|
-> {test_fs.file.proxy?}.should raise_error(NoMethodError)
|
22
22
|
test_fs.entry.proxy?.should be_true
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "sometimes it also should inexplicitly guess that path is a Dir instead of UniversalEntry (but still wrap it inside of Proxy)" do
|
26
26
|
dir = test_fs['tmp/a/..']
|
27
27
|
dir.proxy?.should be_true
|
data/spec/dir_spec.rb
CHANGED
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'Dir' do
|
4
4
|
with_test_fs
|
5
|
-
|
5
|
+
|
6
6
|
before do
|
7
7
|
@path = test_fs['a/b/c']
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe 'existence' do
|
11
11
|
it "should check only dirs" do
|
12
12
|
@path.should_not exist
|
@@ -18,29 +18,29 @@ describe 'Dir' do
|
|
18
18
|
@path.dir.should exist
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should not respond to read and write methods" do
|
23
23
|
-> {@path.dir.read}.should raise_error(NoMethodError)
|
24
24
|
-> {@path.dir.write}.should raise_error(NoMethodError)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe 'create' do
|
28
28
|
it 'should be chainable' do
|
29
29
|
@path.dir.create.should == @path
|
30
30
|
@path.dir.create!.should == @path
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it 'should create parent dirs if not exists' do
|
34
34
|
@path.parent.should_not exist
|
35
35
|
@path.dir.create
|
36
36
|
@path.should be_dir
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it 'should silently exit if dir already exist' do
|
40
40
|
@path.dir.create
|
41
41
|
@path.dir.create
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it 'should override existing file if override specified' do
|
45
45
|
@path.file.create
|
46
46
|
@path.should be_file
|
@@ -48,7 +48,7 @@ describe 'Dir' do
|
|
48
48
|
@path.dir.create!
|
49
49
|
@path.should be_dir
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it 'should override existing dir if override specified' do
|
53
53
|
@path.dir.create
|
54
54
|
@path.should be_dir
|
@@ -56,7 +56,7 @@ describe 'Dir' do
|
|
56
56
|
@path.should be_dir
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
describe 'destroying' do
|
61
61
|
it "should raise error if it's trying to destroy a file (unless force specified)" do
|
62
62
|
@path.file.create
|
@@ -64,36 +64,36 @@ describe 'Dir' do
|
|
64
64
|
@path.dir.destroy!
|
65
65
|
@path.entry.should_not exist
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "shouldn't raise if dir not exist" do
|
69
69
|
@path.dir.destroy
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it 'should destroy recursivelly' do
|
73
73
|
dir = @path.dir
|
74
74
|
dir.create
|
75
75
|
dir.file('file').write 'something'
|
76
76
|
dir.dir('dir').create.tap do |dir|
|
77
|
-
dir.file('file2').write 'something2'
|
77
|
+
dir.file('file2').write 'something2'
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
dir.destroy
|
81
81
|
dir.should_not exist
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it 'should be chainable' do
|
85
85
|
@path.dir.destroy.should == @path
|
86
86
|
@path.dir.destroy!.should == @path
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
describe 'entries, files, dirs' do
|
91
91
|
before do
|
92
92
|
@path.dir('dir').create
|
93
93
|
@path.dir('dir/another_dir').create
|
94
|
-
@path.file('file').create
|
94
|
+
@path.file('file').create
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
it 'entries' do
|
98
98
|
-> {@path['non_existing'].entries}.should raise_error(Vfs::Error, /not exist/)
|
99
99
|
@path['non_existing'].entries(bang: false).should == []
|
@@ -102,71 +102,71 @@ describe 'Dir' do
|
|
102
102
|
@path.entries{|e| list << e}
|
103
103
|
list.to_set.should be_eql([@path.dir('dir'), @path.file('file')].to_set)
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
it "glob search support"
|
107
|
-
|
107
|
+
|
108
108
|
it 'should raise error if trying :entries on file' do
|
109
109
|
@path.file('some_file').create
|
110
110
|
-> {@path.dir('some_file').entries}.should raise_error(/File/)
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
it 'files' do
|
114
114
|
@path.files.should be_eql([@path.file('file')])
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
it 'dirs' do
|
118
118
|
@path.dirs.should be_eql([@path.dir('dir')])
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it 'has? & include?' do
|
122
122
|
@path.include?('dir').should be_true
|
123
123
|
@path.include?('dir/another_dir').should be_true
|
124
124
|
@path.include?('file').should be_true
|
125
125
|
@path.include?('non_existing').should be_false
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
it 'empty?'
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
describe 'copying' do
|
132
|
-
before do
|
132
|
+
before do
|
133
133
|
@from = @path.dir
|
134
134
|
@from.create
|
135
135
|
@from.file('file').write 'something'
|
136
136
|
@from.dir('dir').create.tap do |dir|
|
137
|
-
dir.file('file2').write 'something2'
|
137
|
+
dir.file('file2').write 'something2'
|
138
138
|
end
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
it 'should not copy to itself' do
|
142
142
|
-> {@from.copy_to @from}.should raise_error(Vfs::Error, /itself/)
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
shared_examples_for 'copy_to behavior' do
|
146
146
|
it 'should not copy to file (and overwrite if forced)' do
|
147
147
|
-> {@from.copy_to @to.file}.should raise_error(/can't copy Dir to File/)
|
148
|
-
|
148
|
+
|
149
149
|
@from.copy_to! @to.file
|
150
150
|
@to['file'].read.should == 'something'
|
151
151
|
end
|
152
|
-
|
152
|
+
|
153
153
|
it 'should not override files (and override if forced)' do
|
154
154
|
@from.copy_to @to
|
155
155
|
-> {@from.copy_to @to}.should raise_error(/already exist/)
|
156
|
-
|
156
|
+
|
157
157
|
@from['dir/file2'].write! 'another'
|
158
158
|
@from.copy_to! @to
|
159
159
|
@to['dir/file2'].read.should == 'another'
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
it 'should copy to UniversalEntry (and overwrite if forced)' do
|
163
163
|
@from.copy_to @to.entry
|
164
164
|
-> {@from.copy_to @to.entry}.should raise_error(/already exist/)
|
165
|
-
|
165
|
+
|
166
166
|
@from.copy_to! @to.entry
|
167
|
-
@to['file'].read.should == 'something'
|
167
|
+
@to['file'].read.should == 'something'
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
it "shouldn't delete existing content of directory" do
|
171
171
|
@to.dir.create!
|
172
172
|
@to.file('existing_file').write 'existing_content'
|
@@ -181,25 +181,25 @@ describe 'Dir' do
|
|
181
181
|
@to.file('existing_file').read.should == 'existing_content'
|
182
182
|
@to.dir('existing_dir').should exist
|
183
183
|
@to.file('dir/existing_file2').read.should == 'existing_content2'
|
184
|
-
end
|
185
|
-
|
184
|
+
end
|
185
|
+
|
186
186
|
it 'should be chainable' do
|
187
187
|
@from.copy_to(@to).should == @to
|
188
188
|
@from.copy_to!(@to).should == @to
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
it "should override without deleting other files" do
|
192
|
-
@from.copy_to(@to).should == @to
|
192
|
+
@from.copy_to(@to).should == @to
|
193
193
|
@to.file('other_file').write 'other'
|
194
|
-
|
194
|
+
|
195
195
|
@from.copy_to!(@to).should == @to
|
196
196
|
@to.file('other_file').read.should == 'other'
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
-
describe 'general copy' do
|
200
|
+
describe 'general copy' do
|
201
201
|
it_should_behave_like 'copy_to behavior'
|
202
|
-
|
202
|
+
|
203
203
|
before do
|
204
204
|
# prevenging usage of :efficient_dir_copy
|
205
205
|
# Vfs::Dir.dont_use_efficient_dir_copy = true
|
@@ -209,29 +209,29 @@ describe 'Dir' do
|
|
209
209
|
# after do
|
210
210
|
# Vfs::Dir.dont_use_efficient_dir_copy = false
|
211
211
|
# end
|
212
|
-
end
|
213
|
-
|
212
|
+
end
|
213
|
+
|
214
214
|
# describe 'effective copy' do
|
215
215
|
# it_should_behave_like 'copy_to behavior'
|
216
|
-
#
|
216
|
+
#
|
217
217
|
# before do
|
218
218
|
# @to = test_fs['to']
|
219
219
|
# end
|
220
220
|
# end
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
describe 'moving' do
|
224
224
|
it 'move_to' do
|
225
225
|
from, to = @path.file('from'), @path.file('to')
|
226
226
|
from.should_receive(:copy_to).with(to, {})
|
227
227
|
from.should_receive(:destroy).with({})
|
228
228
|
from.move_to to
|
229
|
-
|
229
|
+
|
230
230
|
from.should_receive(:move_to).with(to, override: true)
|
231
231
|
from.move_to! to
|
232
232
|
end
|
233
|
-
|
234
|
-
it 'should be chainable' do
|
233
|
+
|
234
|
+
it 'should be chainable' do
|
235
235
|
from, to = @path.dir('from').create, @path.dir('to')
|
236
236
|
from.move_to(to).should == to
|
237
237
|
from.create
|