virtfs-camcorderfs 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/virtfs-camcorderfs.rb +1 -0
- data/lib/virtfs/camcorderfs.rb +13 -0
- data/lib/virtfs/camcorderfs/cc_delegate.rb +18 -0
- data/lib/virtfs/camcorderfs/cc_delegate/dir_class_methods.rb +51 -0
- data/lib/virtfs/camcorderfs/cc_delegate/dir_instance_methods.rb +20 -0
- data/lib/virtfs/camcorderfs/cc_delegate/file_class_methods.rb +188 -0
- data/lib/virtfs/camcorderfs/cc_delegate/file_instance_methods.rb +145 -0
- data/lib/virtfs/camcorderfs/dir.rb +37 -0
- data/lib/virtfs/camcorderfs/file.rb +157 -0
- data/lib/virtfs/camcorderfs/fs.rb +106 -0
- data/lib/virtfs/camcorderfs/fs/dir_class_methods.rb +38 -0
- data/lib/virtfs/camcorderfs/fs/dir_instance_methods.rb +20 -0
- data/lib/virtfs/camcorderfs/fs/file_class_methods.rb +179 -0
- data/lib/virtfs/camcorderfs/fs/file_instance_methods.rb +144 -0
- data/lib/virtfs/camcorderfs/real_dir.rb +27 -0
- data/lib/virtfs/camcorderfs/real_file.rb +27 -0
- data/lib/virtfs/camcorderfs/version.rb +5 -0
- data/virtfs-camcorderfs.gemspec +32 -0
- metadata +143 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
2
|
+
#
|
3
|
+
# Directory class methods - called by VirtFS::Dir.
|
4
|
+
# Makes recordable call to corresponding CcDelegate method.
|
5
|
+
#
|
6
|
+
class FS
|
7
|
+
module DirClassMethods
|
8
|
+
def dir_delete(p)
|
9
|
+
ccd_call(__method__, apply_root(p))
|
10
|
+
end
|
11
|
+
|
12
|
+
def dir_chdir(p)
|
13
|
+
ccd_call(__method__, apply_root(p))
|
14
|
+
end
|
15
|
+
|
16
|
+
def dir_entries(p)
|
17
|
+
ccd_call(__method__, apply_root(p))
|
18
|
+
end
|
19
|
+
|
20
|
+
def dir_exist?(p)
|
21
|
+
ccd_call(__method__, apply_root(p))
|
22
|
+
end
|
23
|
+
|
24
|
+
def dir_foreach(p, &block)
|
25
|
+
return_enum(dir_entries(p), block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def dir_mkdir(p, permissions)
|
29
|
+
ccd_call(__method__, apply_root(p), permissions)
|
30
|
+
end
|
31
|
+
|
32
|
+
def dir_new(fs_rel_path, hash_args, open_path, cwd)
|
33
|
+
instance_handle = ccd_call(__method__, apply_root(fs_rel_path), hash_args, open_path, cwd)
|
34
|
+
VirtFS::CamcorderFS::Dir.new(self, instance_handle, hash_args)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
2
|
+
#
|
3
|
+
# Directory instance methods - called by CamcorderFS::Dir instances - thick interface.
|
4
|
+
# Makes recordable call to corresponding CcDelegate method.
|
5
|
+
#
|
6
|
+
class FS
|
7
|
+
module DirInstanceMethods
|
8
|
+
#
|
9
|
+
# Dir instance methods - delegate to CcDelegate.
|
10
|
+
#
|
11
|
+
def dir_i_close(instance_handle)
|
12
|
+
ccd_call(__method__, instance_handle)
|
13
|
+
end
|
14
|
+
|
15
|
+
def dir_i_each(instance_handle, block, rv)
|
16
|
+
return_enum(ccd_call(__method__, instance_handle), block, rv)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
2
|
+
#
|
3
|
+
# File class methods - called by VirtFS::File.
|
4
|
+
# Makes recordable call to corresponding CcDelegate method.
|
5
|
+
#
|
6
|
+
class FS
|
7
|
+
module FileClassMethods
|
8
|
+
def file_atime(p)
|
9
|
+
ccd_call(__method__, apply_root(p))
|
10
|
+
end
|
11
|
+
|
12
|
+
def file_blockdev?(p)
|
13
|
+
ccd_call(__method__, apply_root(p))
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_chardev?(p)
|
17
|
+
ccd_call(__method__, apply_root(p))
|
18
|
+
end
|
19
|
+
|
20
|
+
def file_chmod(permission, p)
|
21
|
+
ccd_call(__method__, permission, apply_root(p))
|
22
|
+
end
|
23
|
+
|
24
|
+
def file_chown(owner, group, p)
|
25
|
+
ccd_call(__method__, owner, group, apply_root(p))
|
26
|
+
end
|
27
|
+
|
28
|
+
def file_ctime(p)
|
29
|
+
ccd_call(__method__, apply_root(p))
|
30
|
+
end
|
31
|
+
|
32
|
+
def file_delete(p)
|
33
|
+
ccd_call(__method__, apply_root(p))
|
34
|
+
end
|
35
|
+
|
36
|
+
def file_directory?(p)
|
37
|
+
ccd_call(__method__, apply_root(p))
|
38
|
+
end
|
39
|
+
|
40
|
+
def file_executable?(p)
|
41
|
+
ccd_call(__method__, apply_root(p))
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_executable_real?(p)
|
45
|
+
ccd_call(__method__, apply_root(p))
|
46
|
+
end
|
47
|
+
|
48
|
+
def file_exist?(p)
|
49
|
+
ccd_call(__method__, apply_root(p))
|
50
|
+
end
|
51
|
+
|
52
|
+
def file_file?(p)
|
53
|
+
ccd_call(__method__, apply_root(p))
|
54
|
+
end
|
55
|
+
|
56
|
+
def file_ftype(p)
|
57
|
+
ccd_call(__method__, apply_root(p))
|
58
|
+
end
|
59
|
+
|
60
|
+
def file_grpowned?(p)
|
61
|
+
ccd_call(__method__, apply_root(p))
|
62
|
+
end
|
63
|
+
|
64
|
+
def file_identical?(p1, p2)
|
65
|
+
ccd_call(__method__, apply_root(p1), apply_root(p2))
|
66
|
+
end
|
67
|
+
|
68
|
+
def file_lchmod(permission, p)
|
69
|
+
ccd_call(__method__, permission, apply_root(p))
|
70
|
+
end
|
71
|
+
|
72
|
+
def file_lchown(owner, group, p)
|
73
|
+
ccd_call(__method__, owner, group, apply_root(p))
|
74
|
+
end
|
75
|
+
|
76
|
+
def file_link(p1, p2)
|
77
|
+
ccd_call(__method__, apply_root(p1), apply_root(p2))
|
78
|
+
end
|
79
|
+
|
80
|
+
def file_lstat(p)
|
81
|
+
ccd_call(__method__, apply_root(p))
|
82
|
+
end
|
83
|
+
|
84
|
+
def file_mtime(p)
|
85
|
+
ccd_call(__method__, apply_root(p))
|
86
|
+
end
|
87
|
+
|
88
|
+
def file_owned?(p)
|
89
|
+
ccd_call(__method__, apply_root(p))
|
90
|
+
end
|
91
|
+
|
92
|
+
def file_pipe?(p)
|
93
|
+
ccd_call(__method__, apply_root(p))
|
94
|
+
end
|
95
|
+
|
96
|
+
def file_readable?(p)
|
97
|
+
ccd_call(__method__, apply_root(p))
|
98
|
+
end
|
99
|
+
|
100
|
+
def file_readable_real?(p)
|
101
|
+
ccd_call(__method__, apply_root(p))
|
102
|
+
end
|
103
|
+
|
104
|
+
def file_readlink(p)
|
105
|
+
ccd_call(__method__, apply_root(p))
|
106
|
+
end
|
107
|
+
|
108
|
+
def file_rename(p1, p2)
|
109
|
+
ccd_call(__method__, apply_root(p1), apply_root(p2))
|
110
|
+
end
|
111
|
+
|
112
|
+
def file_setgid?(p)
|
113
|
+
ccd_call(__method__, apply_root(p))
|
114
|
+
end
|
115
|
+
|
116
|
+
def file_setuid?(p)
|
117
|
+
ccd_call(__method__, apply_root(p))
|
118
|
+
end
|
119
|
+
|
120
|
+
def file_size(p)
|
121
|
+
ccd_call(__method__, apply_root(p))
|
122
|
+
end
|
123
|
+
|
124
|
+
def file_socket?(p)
|
125
|
+
ccd_call(__method__, apply_root(p))
|
126
|
+
end
|
127
|
+
|
128
|
+
def file_stat(p)
|
129
|
+
ccd_call(__method__, apply_root(p))
|
130
|
+
end
|
131
|
+
|
132
|
+
def file_sticky?(p)
|
133
|
+
ccd_call(__method__, apply_root(p))
|
134
|
+
end
|
135
|
+
|
136
|
+
def file_symlink(oname, p)
|
137
|
+
#
|
138
|
+
# We don't apply_root to oname, because it's either an
|
139
|
+
# absolute path in the global FS namespace, or a path
|
140
|
+
# relative to the location of the new link.
|
141
|
+
#
|
142
|
+
ccd_call(__method__, oname, apply_root(p))
|
143
|
+
end
|
144
|
+
|
145
|
+
def file_symlink?(p)
|
146
|
+
ccd_call(__method__, apply_root(p))
|
147
|
+
end
|
148
|
+
|
149
|
+
def file_truncate(p, len)
|
150
|
+
ccd_call(__method__, apply_root(p), len)
|
151
|
+
end
|
152
|
+
|
153
|
+
def file_utime(atime, mtime, p)
|
154
|
+
ccd_call(__method__, atime, mtime, apply_root(p))
|
155
|
+
end
|
156
|
+
|
157
|
+
def file_world_readable?(p)
|
158
|
+
ccd_call(__method__, apply_root(p))
|
159
|
+
end
|
160
|
+
|
161
|
+
def file_world_writable?(p)
|
162
|
+
ccd_call(__method__, apply_root(p))
|
163
|
+
end
|
164
|
+
|
165
|
+
def file_writable?(p)
|
166
|
+
ccd_call(__method__, apply_root(p))
|
167
|
+
end
|
168
|
+
|
169
|
+
def file_writable_real?(p)
|
170
|
+
ccd_call(__method__, apply_root(p))
|
171
|
+
end
|
172
|
+
|
173
|
+
def file_new(fs_rel_path, parsed_args, open_path, cwd)
|
174
|
+
instance_handle = ccd_call(__method__, apply_root(fs_rel_path), parsed_args, open_path, cwd)
|
175
|
+
VirtFS::CamcorderFS::File.new(self, instance_handle, parsed_args)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
2
|
+
#
|
3
|
+
# File instance methods - called by CamcorderFS::File instances - thick interface.
|
4
|
+
# Makes recordable call to corresponding CcDelegate method.
|
5
|
+
#
|
6
|
+
class FS
|
7
|
+
module FileInstanceMethods
|
8
|
+
#
|
9
|
+
# File instance methods - delegate to CcDelegate.
|
10
|
+
#
|
11
|
+
def file_i_atime(instance_handle)
|
12
|
+
ccd_call(__method__, instance_handle)
|
13
|
+
end
|
14
|
+
|
15
|
+
def file_i_chmod(instance_handle, permission)
|
16
|
+
ccd_call(__method__, instance_handle, permission)
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_i_chown(instance_handle, owner, group)
|
20
|
+
ccd_call(__method__, instance_handle, owner, group)
|
21
|
+
end
|
22
|
+
|
23
|
+
def file_i_ctime(instance_handle)
|
24
|
+
ccd_call(__method__, instance_handle)
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_i_flock(instance_handle, locking_constant)
|
28
|
+
ccd_call(__method__, instance_handle, locking_constant)
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_i_lstat(instance_handle)
|
32
|
+
ccd_call(__method__, instance_handle)
|
33
|
+
end
|
34
|
+
|
35
|
+
def file_i_mtime(instance_handle)
|
36
|
+
ccd_call(__method__, instance_handle)
|
37
|
+
end
|
38
|
+
|
39
|
+
def file_i_size(instance_handle)
|
40
|
+
ccd_call(__method__, instance_handle)
|
41
|
+
end
|
42
|
+
|
43
|
+
def file_i_truncate(instance_handle, to_size)
|
44
|
+
ccd_call(__method__, instance_handle, to_size)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# IO instance methods.
|
49
|
+
#
|
50
|
+
def file_i_close(instance_handle)
|
51
|
+
ccd_call(__method__, instance_handle)
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_i_close_on_exec?(instance_handle)
|
55
|
+
ccd_call(__method__, instance_handle)
|
56
|
+
end
|
57
|
+
|
58
|
+
def file_i_close_on_exec=(instance_handle, bool_val)
|
59
|
+
ccd_call(__method__, instance_handle, bool_val)
|
60
|
+
end
|
61
|
+
|
62
|
+
def file_i_close_read(instance_handle)
|
63
|
+
ccd_call(__method__, instance_handle)
|
64
|
+
end
|
65
|
+
|
66
|
+
def file_i_close_write(instance_handle)
|
67
|
+
ccd_call(__method__, instance_handle)
|
68
|
+
end
|
69
|
+
|
70
|
+
def file_i_fcntl(instance_handle, cmd, arg)
|
71
|
+
ccd_call(__method__, instance_handle, cmd, arg)
|
72
|
+
end
|
73
|
+
|
74
|
+
def file_i_fdatasync(instance_handle)
|
75
|
+
ccd_call(__method__, instance_handle)
|
76
|
+
end
|
77
|
+
|
78
|
+
def file_i_fileno(instance_handle)
|
79
|
+
ccd_call(__method__, instance_handle)
|
80
|
+
end
|
81
|
+
|
82
|
+
def file_i_flush(instance_handle)
|
83
|
+
ccd_call(__method__, instance_handle)
|
84
|
+
end
|
85
|
+
|
86
|
+
def file_i_fsync(instance_handle)
|
87
|
+
ccd_call(__method__, instance_handle)
|
88
|
+
end
|
89
|
+
|
90
|
+
def file_i_ioctl(instance_handle, cms, arg)
|
91
|
+
ccd_call(__method__, instance_handle, cms, arg)
|
92
|
+
end
|
93
|
+
|
94
|
+
def file_i_isatty(instance_handle)
|
95
|
+
ccd_call(__method__, instance_handle)
|
96
|
+
end
|
97
|
+
|
98
|
+
def file_i_pid(instance_handle)
|
99
|
+
ccd_call(__method__, instance_handle)
|
100
|
+
end
|
101
|
+
|
102
|
+
def file_i_raw_read(instance_handle, start_byte, num_bytes)
|
103
|
+
rv = ccd_call(__method__, instance_handle, start_byte, num_bytes)
|
104
|
+
rv.force_encoding('ASCII-8BIT') # Needed when loaded from YAML.
|
105
|
+
end
|
106
|
+
|
107
|
+
def file_i_raw_write(instance_handle, start_byte, buf)
|
108
|
+
ccd_call(__method__, instance_handle, start_byte, buf)
|
109
|
+
end
|
110
|
+
|
111
|
+
def file_i_readpartial(instance_handle, limit, result)
|
112
|
+
ccd_call(__method__, instance_handle, limit, result)
|
113
|
+
end
|
114
|
+
|
115
|
+
def file_i_read_nonblock(instance_handle, limit, result)
|
116
|
+
ccd_call(__method__, instance_handle, limit, result)
|
117
|
+
end
|
118
|
+
|
119
|
+
def file_i_stat(instance_handle)
|
120
|
+
ccd_call(__method__, instance_handle)
|
121
|
+
end
|
122
|
+
|
123
|
+
def file_i_sync(instance_handle)
|
124
|
+
ccd_call(__method__, instance_handle)
|
125
|
+
end
|
126
|
+
|
127
|
+
def file_i_sync=(instance_handle, bool_val)
|
128
|
+
ccd_call(__method__, instance_handle, bool_val)
|
129
|
+
end
|
130
|
+
|
131
|
+
def file_i_to_i(instance_handle)
|
132
|
+
ccd_call(__method__, instance_handle)
|
133
|
+
end
|
134
|
+
|
135
|
+
def file_i_tty?(instance_handle)
|
136
|
+
ccd_call(__method__, instance_handle)
|
137
|
+
end
|
138
|
+
|
139
|
+
def file_i_write_nonblock(instance_handle, buf)
|
140
|
+
ccd_call(__method__, instance_handle, buf)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# When recording calls to instance methods of File and Dir, a reference to
|
3
|
+
# the instance is passed to the method call being recorded. During the "record"
|
4
|
+
# phase, the target of the call is an instance of "real" File (or Dir).
|
5
|
+
#
|
6
|
+
# During VirtFS activation, The File constant is mapped to VirtFS::vFile,
|
7
|
+
# and a reference to the "real" File class is saved in the VfsRealFile constant.
|
8
|
+
#
|
9
|
+
# When instanitating an instance of the File class, we need to ensure we always
|
10
|
+
# use the "real" File class (as opposed to VirtFS::vFile). However, if we use
|
11
|
+
# the VfsRealFile constant to do this, it results in recording an ambiguous
|
12
|
+
# instance reference to the cassette. This is because:
|
13
|
+
#
|
14
|
+
# VfsRealFile.class.name == File (not VfsRealFile)
|
15
|
+
# File.class.name == File (when not activated)
|
16
|
+
# File.class.name == VirtFS::vFile (when activated)
|
17
|
+
#
|
18
|
+
# This results in failed cassette playback during activation because it won't
|
19
|
+
# be able to find a VirtFS::vFile entry in the cassette.
|
20
|
+
#
|
21
|
+
# Using a proper subclass of the "real" File class solves this problem, because:
|
22
|
+
# CcRealFile.class.name == CcRealFile
|
23
|
+
#
|
24
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
25
|
+
class RealDir < VfsRealDir
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# When recording calls to instance methods of File and Dir, a reference to
|
3
|
+
# the instance is passed to the method call being recorded. During the "record"
|
4
|
+
# phase, the target of the call is an instance of "real" File (or Dir).
|
5
|
+
#
|
6
|
+
# During VirtFS activation, The File constant is mapped to VirtFS::vFile,
|
7
|
+
# and a reference to the "real" File class is saved in the VfsRealFile constant.
|
8
|
+
#
|
9
|
+
# When instanitating an instance of the File class, we need to ensure we always
|
10
|
+
# use the "real" File class (as opposed to VirtFS::vFile). However, if we use
|
11
|
+
# the VfsRealFile constant to do this, it results in recording an ambiguous
|
12
|
+
# instance reference to the cassette. This is because:
|
13
|
+
#
|
14
|
+
# VfsRealFile.class.name == File (not VfsRealFile)
|
15
|
+
# File.class.name == File (when not activated)
|
16
|
+
# File.class.name == VirtFS::vFile (when activated)
|
17
|
+
#
|
18
|
+
# This results in failed cassette playback during activation because it won't
|
19
|
+
# be able to find a VirtFS::vFile entry in the cassette.
|
20
|
+
#
|
21
|
+
# Using a proper subclass of the "real" File class solves this problem, because:
|
22
|
+
# CcRealFile.class.name == CcRealFile
|
23
|
+
#
|
24
|
+
module VirtFS::CamcorderFS # rubocop:disable Style/ClassAndModuleChildren
|
25
|
+
class RealFile < VfsRealFile
|
26
|
+
end
|
27
|
+
end
|