virtfs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +154 -0
  8. data/Rakefile +5 -0
  9. data/lib/virtfs-nativefs-thick.rb +1 -0
  10. data/lib/virtfs-nativefs-thin.rb +1 -0
  11. data/lib/virtfs.rb +38 -0
  12. data/lib/virtfs/activation.rb +97 -0
  13. data/lib/virtfs/block_io.rb +140 -0
  14. data/lib/virtfs/byte_range.rb +71 -0
  15. data/lib/virtfs/context.rb +300 -0
  16. data/lib/virtfs/context_manager.rb +175 -0
  17. data/lib/virtfs/context_switch_class_methods.rb +96 -0
  18. data/lib/virtfs/delegate_module.rb +40 -0
  19. data/lib/virtfs/dir_instance_delegate.rb +3 -0
  20. data/lib/virtfs/exception.rb +13 -0
  21. data/lib/virtfs/file_instance_delegate.rb +3 -0
  22. data/lib/virtfs/file_modes_and_options.rb +293 -0
  23. data/lib/virtfs/find_class_methods.rb +106 -0
  24. data/lib/virtfs/io_buffer.rb +133 -0
  25. data/lib/virtfs/io_instance_delegate.rb +3 -0
  26. data/lib/virtfs/kernel.rb +146 -0
  27. data/lib/virtfs/nativefs/thick.rb +30 -0
  28. data/lib/virtfs/nativefs/thick/dir_class_methods.rb +38 -0
  29. data/lib/virtfs/nativefs/thick/file_class_methods.rb +178 -0
  30. data/lib/virtfs/nativefs/thin.rb +32 -0
  31. data/lib/virtfs/nativefs/thin/dir.rb +30 -0
  32. data/lib/virtfs/nativefs/thin/dir_class_methods.rb +41 -0
  33. data/lib/virtfs/nativefs/thin/file.rb +112 -0
  34. data/lib/virtfs/nativefs/thin/file_class_methods.rb +181 -0
  35. data/lib/virtfs/protofs/protofs.rb +7 -0
  36. data/lib/virtfs/protofs/protofs_base.rb +12 -0
  37. data/lib/virtfs/protofs/protofs_dir.rb +13 -0
  38. data/lib/virtfs/protofs/protofs_dir_class.rb +31 -0
  39. data/lib/virtfs/protofs/protofs_file.rb +27 -0
  40. data/lib/virtfs/protofs/protofs_file_class.rb +136 -0
  41. data/lib/virtfs/stat.rb +100 -0
  42. data/lib/virtfs/thin_dir_delegator.rb +79 -0
  43. data/lib/virtfs/thin_file_delegator.rb +77 -0
  44. data/lib/virtfs/thin_io_delegator_methods.rb +301 -0
  45. data/lib/virtfs/thin_io_delegator_methods_bufferio.rb +337 -0
  46. data/lib/virtfs/v_dir.rb +238 -0
  47. data/lib/virtfs/v_file.rb +480 -0
  48. data/lib/virtfs/v_io.rb +243 -0
  49. data/lib/virtfs/v_pathname.rb +128 -0
  50. data/lib/virtfs/version.rb +3 -0
  51. data/spec/activate_spec.rb +202 -0
  52. data/spec/chroot_spec.rb +120 -0
  53. data/spec/context_manager_class_spec.rb +246 -0
  54. data/spec/context_manager_instance_spec.rb +255 -0
  55. data/spec/context_spec.rb +335 -0
  56. data/spec/data/UTF-16LE-data.txt +0 -0
  57. data/spec/data/UTF-8-data.txt +212 -0
  58. data/spec/dir_class_spec.rb +506 -0
  59. data/spec/dir_instance_spec.rb +208 -0
  60. data/spec/file_class_spec.rb +2106 -0
  61. data/spec/file_instance_spec.rb +154 -0
  62. data/spec/file_modes_and_options_spec.rb +1556 -0
  63. data/spec/find_spec.rb +142 -0
  64. data/spec/io_bufferio_size_shared_examples.rb +371 -0
  65. data/spec/io_bufferio_size_spec.rb +861 -0
  66. data/spec/io_bufferio_spec.rb +801 -0
  67. data/spec/io_class_spec.rb +145 -0
  68. data/spec/io_instance_spec.rb +516 -0
  69. data/spec/kernel_spec.rb +285 -0
  70. data/spec/mount_spec.rb +186 -0
  71. data/spec/nativefs_local_root_spec.rb +132 -0
  72. data/spec/path_spec.rb +39 -0
  73. data/spec/spec_helper.rb +126 -0
  74. data/tasks/rspec.rake +3 -0
  75. data/tasks/yard.rake +7 -0
  76. data/test/UTF-8-demo.txt +212 -0
  77. data/test/bench.rb +18 -0
  78. data/test/bio_internal_test.rb +45 -0
  79. data/test/delegate_io.rb +31 -0
  80. data/test/delegate_module.rb +62 -0
  81. data/test/encode_test.rb +42 -0
  82. data/test/enoent_test.rb +30 -0
  83. data/test/namespace_test.rb +42 -0
  84. data/test/read_block_valid_encoding.rb +44 -0
  85. data/test/read_test.rb +78 -0
  86. data/test/stream_readers.rb +46 -0
  87. data/test/utf-16-demo.txt +0 -0
  88. data/test/utf8_to_utf16.rb +77 -0
  89. data/test/wrapper_test.rb +34 -0
  90. data/virtfs.gemspec +29 -0
  91. metadata +230 -0
Binary file
@@ -0,0 +1,77 @@
1
+ begin
2
+ utf8_string = ""
3
+ bin_string = ""
4
+
5
+ puts "Read UTF-8 file, returning UTF-8"
6
+ File.open("utf-8-demo.txt", "r:UTF-8:UTF-8") do |io|
7
+ utf8_string = io.read
8
+ end
9
+ puts "\tutf8_string.encoding.name = #{utf8_string.encoding.name} (valid: #{utf8_string.valid_encoding?})"
10
+ puts "\tutf8_string.length = #{utf8_string.length}"
11
+ puts "\tutf8_string.bytesize = #{utf8_string.bytesize}"
12
+ puts
13
+
14
+ puts "Transcode UTF-8 to UTF-16"
15
+ utf16_string = utf8_string.encode("UTF-16le")
16
+ puts "\tutf16_string.encoding.name = #{utf16_string.encoding.name} (valid: #{utf16_string.valid_encoding?})"
17
+ puts "\tutf16_string.length = #{utf16_string.length}"
18
+ puts "\tutf16_string.bytesize = #{utf16_string.bytesize}"
19
+ puts
20
+
21
+ File.open("utf-16-demo.txt", "wb") do |io|
22
+ io.write(utf16_string)
23
+ end
24
+
25
+ puts "Read UTF-8 file, returning UTF-16"
26
+ File.open("utf-8-demo.txt", "r:UTF-8:UTF-16le") do |io|
27
+ utf16_string = io.read
28
+ end
29
+ puts "\tutf16_string.encoding.name = #{utf16_string.encoding.name} (valid: #{utf16_string.valid_encoding?})"
30
+ puts "\tutf16_string.length = #{utf16_string.length}"
31
+ puts "\tutf16_string.bytesize = #{utf16_string.bytesize}"
32
+ puts
33
+
34
+ puts "Read UTF-16 file, as binary"
35
+ File.open("utf-16-demo.txt", "rb") do |io|
36
+ bin_string = io.read
37
+ end
38
+ puts "\tbin_string.encoding.name = #{bin_string.encoding.name} (valid: #{bin_string.valid_encoding?})"
39
+ puts "\tbin_string.length = #{bin_string.length}"
40
+ puts "\tbin_string.bytesize = #{bin_string.bytesize}"
41
+ puts
42
+
43
+ puts "Force encode binary to UTF-16"
44
+ bin_string.force_encoding("UTF-16le")
45
+ puts "\tbin_string.encoding.name = #{bin_string.encoding.name} (valid: #{bin_string.valid_encoding?})"
46
+ puts "\tbin_string.length = #{bin_string.length}"
47
+ puts "\tbin_string.bytesize = #{bin_string.bytesize}"
48
+ puts
49
+
50
+ puts "Transcode UTF-16 to UTF-8"
51
+ utf8_string = bin_string.encode("UTF-8")
52
+ puts "\tutf8_string.encoding.name = #{utf8_string.encoding.name} (valid: #{utf8_string.valid_encoding?})"
53
+ puts "\tutf8_string.length = #{utf8_string.length}"
54
+ puts "\tutf8_string.bytesize = #{utf8_string.bytesize}"
55
+ puts
56
+
57
+ puts "Read UTF-16 file, returning UTF-8"
58
+ File.open("utf-16-demo.txt", "r:UTF-16le:UTF-8") do |io|
59
+ utf16_string = io.read
60
+ end
61
+ puts "\tutf16_string.encoding.name = #{utf16_string.encoding.name} (valid: #{utf16_string.valid_encoding?})"
62
+ puts "\tutf16_string.length = #{utf16_string.length}"
63
+ puts "\tutf16_string.bytesize = #{utf16_string.bytesize}"
64
+ puts
65
+
66
+ puts "Read UTF-16 file, returning UTF-16"
67
+ File.open("utf-16-demo.txt", "r:UTF-16le:UTF-16le") do |io|
68
+ utf16_string = io.read
69
+ end
70
+ puts "\tutf16_string.encoding.name = #{utf16_string.encoding.name} (valid: #{utf16_string.valid_encoding?})"
71
+ puts "\tutf16_string.length = #{utf16_string.length}"
72
+ puts "\tutf16_string.bytesize = #{utf16_string.bytesize}"
73
+ puts
74
+ rescue => err
75
+ puts err.to_s
76
+ puts err.backtrace.join("\n")
77
+ end
@@ -0,0 +1,34 @@
1
+ require "yaml"
2
+
3
+ def update_dir(dir)
4
+ dir.instance_variable_set(:@_id, dir.object_id)
5
+ end
6
+
7
+ def dump_load(obj)
8
+ YAML.load(YAML.dump(obj))
9
+ end
10
+
11
+ begin
12
+ dir1 = Dir.new(".")
13
+ puts "dir1.inspect = #{dir1.inspect}"
14
+ puts "dir1.instance_variables = #{dir1.instance_variables}"
15
+ puts
16
+
17
+ dir2 = dump_load(dir1)
18
+ puts "dir2.inspect = #{dir2.inspect}"
19
+ puts "dir2.instance_variables = #{dir2.instance_variables}"
20
+ puts
21
+
22
+ update_dir(dir1)
23
+ puts "dir1.inspect = #{dir1.inspect}"
24
+ puts "dir1.instance_variables = #{dir1.instance_variables}"
25
+ puts
26
+
27
+ dir3 = dump_load(dir1)
28
+ puts "dir3.inspect = #{dir3.inspect}"
29
+ puts "dir3.instance_variables = #{dir3.instance_variables}"
30
+ puts
31
+ rescue => err
32
+ puts err.to_s
33
+ puts err.backtrace.join("\n")
34
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'virtfs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "virtfs"
8
+ spec.version = VirtFS::VERSION
9
+ spec.authors = ["Richard Oliveri"]
10
+ spec.email = ["roliveri@redhat.com"]
11
+
12
+ spec.summary = "Virtual filesystem facility for Ruby"
13
+ spec.description = %q{
14
+ Supports "pluggable" filesystem modules - instances of which,
15
+ can be mounted anywhere in the global filesystem namespace of the Ruby process.
16
+ }
17
+ spec.homepage = ""
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "yard"
29
+ end
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virtfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Oliveri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: "\n Supports \"pluggable\" filesystem modules - instances of which,\n
70
+ \ can be mounted anywhere in the global filesystem namespace of the Ruby process.\n
71
+ \ "
72
+ email:
73
+ - roliveri@redhat.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - doc/arch.dia
86
+ - doc/arch.png
87
+ - lib/virtfs-nativefs-thick.rb
88
+ - lib/virtfs-nativefs-thin.rb
89
+ - lib/virtfs.rb
90
+ - lib/virtfs/activation.rb
91
+ - lib/virtfs/block_io.rb
92
+ - lib/virtfs/byte_range.rb
93
+ - lib/virtfs/context.rb
94
+ - lib/virtfs/context_manager.rb
95
+ - lib/virtfs/context_switch_class_methods.rb
96
+ - lib/virtfs/delegate_module.rb
97
+ - lib/virtfs/dir_instance_delegate.rb
98
+ - lib/virtfs/exception.rb
99
+ - lib/virtfs/file_instance_delegate.rb
100
+ - lib/virtfs/file_modes_and_options.rb
101
+ - lib/virtfs/find_class_methods.rb
102
+ - lib/virtfs/io_buffer.rb
103
+ - lib/virtfs/io_instance_delegate.rb
104
+ - lib/virtfs/kernel.rb
105
+ - lib/virtfs/nativefs/thick.rb
106
+ - lib/virtfs/nativefs/thick/dir_class_methods.rb
107
+ - lib/virtfs/nativefs/thick/file_class_methods.rb
108
+ - lib/virtfs/nativefs/thin.rb
109
+ - lib/virtfs/nativefs/thin/dir.rb
110
+ - lib/virtfs/nativefs/thin/dir_class_methods.rb
111
+ - lib/virtfs/nativefs/thin/file.rb
112
+ - lib/virtfs/nativefs/thin/file_class_methods.rb
113
+ - lib/virtfs/protofs/protofs.rb
114
+ - lib/virtfs/protofs/protofs_base.rb
115
+ - lib/virtfs/protofs/protofs_dir.rb
116
+ - lib/virtfs/protofs/protofs_dir_class.rb
117
+ - lib/virtfs/protofs/protofs_file.rb
118
+ - lib/virtfs/protofs/protofs_file_class.rb
119
+ - lib/virtfs/stat.rb
120
+ - lib/virtfs/thin_dir_delegator.rb
121
+ - lib/virtfs/thin_file_delegator.rb
122
+ - lib/virtfs/thin_io_delegator_methods.rb
123
+ - lib/virtfs/thin_io_delegator_methods_bufferio.rb
124
+ - lib/virtfs/v_dir.rb
125
+ - lib/virtfs/v_file.rb
126
+ - lib/virtfs/v_io.rb
127
+ - lib/virtfs/v_pathname.rb
128
+ - lib/virtfs/version.rb
129
+ - spec/activate_spec.rb
130
+ - spec/chroot_spec.rb
131
+ - spec/context_manager_class_spec.rb
132
+ - spec/context_manager_instance_spec.rb
133
+ - spec/context_spec.rb
134
+ - spec/data/UTF-16LE-data.txt
135
+ - spec/data/UTF-8-data.txt
136
+ - spec/dir_class_spec.rb
137
+ - spec/dir_instance_spec.rb
138
+ - spec/file_class_spec.rb
139
+ - spec/file_instance_spec.rb
140
+ - spec/file_modes_and_options_spec.rb
141
+ - spec/find_spec.rb
142
+ - spec/io_bufferio_size_shared_examples.rb
143
+ - spec/io_bufferio_size_spec.rb
144
+ - spec/io_bufferio_spec.rb
145
+ - spec/io_class_spec.rb
146
+ - spec/io_instance_spec.rb
147
+ - spec/kernel_spec.rb
148
+ - spec/mount_spec.rb
149
+ - spec/nativefs_local_root_spec.rb
150
+ - spec/path_spec.rb
151
+ - spec/spec_helper.rb
152
+ - tasks/rspec.rake
153
+ - tasks/yard.rake
154
+ - test/UTF-8-demo.txt
155
+ - test/bench.rb
156
+ - test/bio_internal_test.rb
157
+ - test/delegate_io.rb
158
+ - test/delegate_module.rb
159
+ - test/encode_test.rb
160
+ - test/enoent_test.rb
161
+ - test/namespace_test.rb
162
+ - test/read_block_valid_encoding.rb
163
+ - test/read_test.rb
164
+ - test/stream_readers.rb
165
+ - test/utf-16-demo.txt
166
+ - test/utf8_to_utf16.rb
167
+ - test/wrapper_test.rb
168
+ - virtfs.gemspec
169
+ homepage: ''
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.6.12
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: Virtual filesystem facility for Ruby
193
+ test_files:
194
+ - spec/activate_spec.rb
195
+ - spec/chroot_spec.rb
196
+ - spec/context_manager_class_spec.rb
197
+ - spec/context_manager_instance_spec.rb
198
+ - spec/context_spec.rb
199
+ - spec/data/UTF-16LE-data.txt
200
+ - spec/data/UTF-8-data.txt
201
+ - spec/dir_class_spec.rb
202
+ - spec/dir_instance_spec.rb
203
+ - spec/file_class_spec.rb
204
+ - spec/file_instance_spec.rb
205
+ - spec/file_modes_and_options_spec.rb
206
+ - spec/find_spec.rb
207
+ - spec/io_bufferio_size_shared_examples.rb
208
+ - spec/io_bufferio_size_spec.rb
209
+ - spec/io_bufferio_spec.rb
210
+ - spec/io_class_spec.rb
211
+ - spec/io_instance_spec.rb
212
+ - spec/kernel_spec.rb
213
+ - spec/mount_spec.rb
214
+ - spec/nativefs_local_root_spec.rb
215
+ - spec/path_spec.rb
216
+ - spec/spec_helper.rb
217
+ - test/UTF-8-demo.txt
218
+ - test/bench.rb
219
+ - test/bio_internal_test.rb
220
+ - test/delegate_io.rb
221
+ - test/delegate_module.rb
222
+ - test/encode_test.rb
223
+ - test/enoent_test.rb
224
+ - test/namespace_test.rb
225
+ - test/read_block_valid_encoding.rb
226
+ - test/read_test.rb
227
+ - test/stream_readers.rb
228
+ - test/utf-16-demo.txt
229
+ - test/utf8_to_utf16.rb
230
+ - test/wrapper_test.rb