folio 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/COPYING +675 -0
  2. data/MANIFEST +234 -0
  3. data/METADATA +8 -0
  4. data/NEWS +9 -0
  5. data/README +69 -0
  6. data/demo/sample1/foo/foo.txt +1 -0
  7. data/demo/sample1/tryme.rb +14 -0
  8. data/doc/rdoc/classes/Folio/BlockDevice.html +117 -0
  9. data/doc/rdoc/classes/Folio/CharacterDevice.html +117 -0
  10. data/doc/rdoc/classes/Folio/Device.html +119 -0
  11. data/doc/rdoc/classes/Folio/Directory.html +420 -0
  12. data/doc/rdoc/classes/Folio/Document.html +261 -0
  13. data/doc/rdoc/classes/Folio/FileNotFound.html +92 -0
  14. data/doc/rdoc/classes/Folio/FileObject.html +1200 -0
  15. data/doc/rdoc/classes/Folio/Link.html +238 -0
  16. data/doc/rdoc/classes/Folio/Pipe.html +131 -0
  17. data/doc/rdoc/classes/Folio/Prompt.html +796 -0
  18. data/doc/rdoc/classes/Folio/Socket.html +115 -0
  19. data/doc/rdoc/classes/Folio.html +148 -0
  20. data/doc/rdoc/created.rid +1 -0
  21. data/doc/rdoc/files/COPYING.html +992 -0
  22. data/doc/rdoc/files/METADATA.html +101 -0
  23. data/doc/rdoc/files/NEWS.html +102 -0
  24. data/doc/rdoc/files/README.html +171 -0
  25. data/doc/rdoc/files/lib/folio/device_rb.html +96 -0
  26. data/doc/rdoc/files/lib/folio/directory_rb.html +96 -0
  27. data/doc/rdoc/files/lib/folio/document_rb.html +96 -0
  28. data/doc/rdoc/files/lib/folio/errors_rb.html +92 -0
  29. data/doc/rdoc/files/lib/folio/fileobject_rb.html +92 -0
  30. data/doc/rdoc/files/lib/folio/link_rb.html +96 -0
  31. data/doc/rdoc/files/lib/folio/pipe_rb.html +96 -0
  32. data/doc/rdoc/files/lib/folio/prompt_rb.html +92 -0
  33. data/doc/rdoc/files/lib/folio/socket_rb.html +96 -0
  34. data/doc/rdoc/files/lib/folio_rb.html +105 -0
  35. data/doc/rdoc/fr_class_index.html +58 -0
  36. data/doc/rdoc/fr_file_index.html +60 -0
  37. data/doc/rdoc/fr_method_index.html +185 -0
  38. data/doc/rdoc/index.html +26 -0
  39. data/doc/rdoc/rdoc-style.css +175 -0
  40. data/doc/ri/Folio/BlockDevice/blockdev%3f-i.yaml +10 -0
  41. data/doc/ri/Folio/BlockDevice/cdesc-BlockDevice.yaml +18 -0
  42. data/doc/ri/Folio/CharacterDevice/cdesc-CharacterDevice.yaml +18 -0
  43. data/doc/ri/Folio/CharacterDevice/chardev%3f-i.yaml +10 -0
  44. data/doc/ri/Folio/Device/cdesc-Device.yaml +18 -0
  45. data/doc/ri/Folio/Device/new-c.yaml +10 -0
  46. data/doc/ri/Folio/Directory/%2b-i.yaml +12 -0
  47. data/doc/ri/Folio/Directory/%2f-i.yaml +13 -0
  48. data/doc/ri/Folio/Directory/cd-i.yaml +12 -0
  49. data/doc/ri/Folio/Directory/cdesc-Directory.yaml +49 -0
  50. data/doc/ri/Folio/Directory/chdir-i.yaml +11 -0
  51. data/doc/ri/Folio/Directory/chmod_r-i.yaml +10 -0
  52. data/doc/ri/Folio/Directory/chown_r-i.yaml +12 -0
  53. data/doc/ri/Folio/Directory/chroot-i.yaml +10 -0
  54. data/doc/ri/Folio/Directory/cp_r-i.yaml +12 -0
  55. data/doc/ri/Folio/Directory/delete-i.yaml +12 -0
  56. data/doc/ri/Folio/Directory/directory%3f-i.yaml +10 -0
  57. data/doc/ri/Folio/Directory/entries-i.yaml +12 -0
  58. data/doc/ri/Folio/Directory/foreach-i.yaml +10 -0
  59. data/doc/ri/Folio/Directory/new-c.yaml +10 -0
  60. data/doc/ri/Folio/Directory/paths-i.yaml +12 -0
  61. data/doc/ri/Folio/Directory/rm_r-i.yaml +10 -0
  62. data/doc/ri/Folio/Directory/rm_rf-i.yaml +10 -0
  63. data/doc/ri/Folio/Directory/rmdir-i.yaml +13 -0
  64. data/doc/ri/Folio/Directory/unlink-i.yaml +12 -0
  65. data/doc/ri/Folio/Document/cdesc-Document.yaml +34 -0
  66. data/doc/ri/Folio/Document/delete-i.yaml +10 -0
  67. data/doc/ri/Folio/Document/executable%3f-i.yaml +10 -0
  68. data/doc/ri/Folio/Document/executable_real%3f-i.yaml +10 -0
  69. data/doc/ri/Folio/Document/file%3f-i.yaml +10 -0
  70. data/doc/ri/Folio/Document/intialize-i.yaml +10 -0
  71. data/doc/ri/Folio/Document/open-i.yaml +10 -0
  72. data/doc/ri/Folio/Document/read-i.yaml +10 -0
  73. data/doc/ri/Folio/Document/readlines-i.yaml +10 -0
  74. data/doc/ri/Folio/Document/truncate-i.yaml +10 -0
  75. data/doc/ri/Folio/Document/unlink-i.yaml +12 -0
  76. data/doc/ri/Folio/FileNotFound/cdesc-FileNotFound.yaml +15 -0
  77. data/doc/ri/Folio/FileObject/%3c%3d%3e-i.yaml +10 -0
  78. data/doc/ri/Folio/FileObject/%3d%3d-i.yaml +10 -0
  79. data/doc/ri/Folio/FileObject/%5b%5d-c.yaml +12 -0
  80. data/doc/ri/Folio/FileObject/atime-i.yaml +10 -0
  81. data/doc/ri/Folio/FileObject/basename-i.yaml +10 -0
  82. data/doc/ri/Folio/FileObject/blockdev%3f-i.yaml +10 -0
  83. data/doc/ri/Folio/FileObject/cdesc-FileObject.yaml +154 -0
  84. data/doc/ri/Folio/FileObject/chardev%3f-i.yaml +10 -0
  85. data/doc/ri/Folio/FileObject/chmod-i.yaml +10 -0
  86. data/doc/ri/Folio/FileObject/chown-i.yaml +10 -0
  87. data/doc/ri/Folio/FileObject/cp-i.yaml +12 -0
  88. data/doc/ri/Folio/FileObject/ctime-i.yaml +10 -0
  89. data/doc/ri/Folio/FileObject/delete-i.yaml +12 -0
  90. data/doc/ri/Folio/FileObject/delete_force-i.yaml +12 -0
  91. data/doc/ri/Folio/FileObject/directory%3f-i.yaml +10 -0
  92. data/doc/ri/Folio/FileObject/dirname-i.yaml +10 -0
  93. data/doc/ri/Folio/FileObject/exist%3f-i.yaml +13 -0
  94. data/doc/ri/Folio/FileObject/exists%3f-i.yaml +12 -0
  95. data/doc/ri/Folio/FileObject/extname-i.yaml +10 -0
  96. data/doc/ri/Folio/FileObject/file%3f-i.yaml +10 -0
  97. data/doc/ri/Folio/FileObject/fnmatch%3f-i.yaml +12 -0
  98. data/doc/ri/Folio/FileObject/fnmatch-i.yaml +11 -0
  99. data/doc/ri/Folio/FileObject/grpowned%3f-i.yaml +10 -0
  100. data/doc/ri/Folio/FileObject/identical%3f-i.yaml +10 -0
  101. data/doc/ri/Folio/FileObject/inspect-i.yaml +12 -0
  102. data/doc/ri/Folio/FileObject/install-i.yaml +12 -0
  103. data/doc/ri/Folio/FileObject/link-i.yaml +11 -0
  104. data/doc/ri/Folio/FileObject/link_force-i.yaml +11 -0
  105. data/doc/ri/Folio/FileObject/ln-i.yaml +12 -0
  106. data/doc/ri/Folio/FileObject/ln_f-i.yaml +12 -0
  107. data/doc/ri/Folio/FileObject/ln_s-i.yaml +12 -0
  108. data/doc/ri/Folio/FileObject/ln_sf-i.yaml +12 -0
  109. data/doc/ri/Folio/FileObject/mtime-i.yaml +10 -0
  110. data/doc/ri/Folio/FileObject/mv-i.yaml +12 -0
  111. data/doc/ri/Folio/FileObject/new-c.yaml +10 -0
  112. data/doc/ri/Folio/FileObject/owned%3f-i.yaml +10 -0
  113. data/doc/ri/Folio/FileObject/pipe%3f-i.yaml +10 -0
  114. data/doc/ri/Folio/FileObject/readable%3f-i.yaml +10 -0
  115. data/doc/ri/Folio/FileObject/readable_real%3f-i.yaml +10 -0
  116. data/doc/ri/Folio/FileObject/relative-i.yaml +12 -0
  117. data/doc/ri/Folio/FileObject/rename-i.yaml +11 -0
  118. data/doc/ri/Folio/FileObject/restat-i.yaml +13 -0
  119. data/doc/ri/Folio/FileObject/rm-i.yaml +12 -0
  120. data/doc/ri/Folio/FileObject/rm_f-i.yaml +12 -0
  121. data/doc/ri/Folio/FileObject/setgid%3f-i.yaml +10 -0
  122. data/doc/ri/Folio/FileObject/setuid%3f-i.yaml +10 -0
  123. data/doc/ri/Folio/FileObject/size%3f-i.yaml +10 -0
  124. data/doc/ri/Folio/FileObject/size-i.yaml +10 -0
  125. data/doc/ri/Folio/FileObject/socket%3f-i.yaml +10 -0
  126. data/doc/ri/Folio/FileObject/split-i.yaml +12 -0
  127. data/doc/ri/Folio/FileObject/stat%21-i.yaml +12 -0
  128. data/doc/ri/Folio/FileObject/stat-i.yaml +12 -0
  129. data/doc/ri/Folio/FileObject/sticky%3f-i.yaml +10 -0
  130. data/doc/ri/Folio/FileObject/symlink-i.yaml +11 -0
  131. data/doc/ri/Folio/FileObject/symlink_force-i.yaml +11 -0
  132. data/doc/ri/Folio/FileObject/to_s-i.yaml +12 -0
  133. data/doc/ri/Folio/FileObject/touch-i.yaml +10 -0
  134. data/doc/ri/Folio/FileObject/unlink-i.yaml +15 -0
  135. data/doc/ri/Folio/FileObject/unlink_force-i.yaml +13 -0
  136. data/doc/ri/Folio/FileObject/util-i.yaml +10 -0
  137. data/doc/ri/Folio/FileObject/utime-i.yaml +10 -0
  138. data/doc/ri/Folio/FileObject/writable%3f-i.yaml +10 -0
  139. data/doc/ri/Folio/FileObject/writable_real%3f-i.yaml +10 -0
  140. data/doc/ri/Folio/FileObject/zero%3f-i.yaml +10 -0
  141. data/doc/ri/Folio/Link/cdesc-Link.yaml +29 -0
  142. data/doc/ri/Folio/Link/lchmod-i.yaml +10 -0
  143. data/doc/ri/Folio/Link/lchown-i.yaml +10 -0
  144. data/doc/ri/Folio/Link/link%3f-i.yaml +10 -0
  145. data/doc/ri/Folio/Link/lstat-i.yaml +10 -0
  146. data/doc/ri/Folio/Link/method_missing-i.yaml +11 -0
  147. data/doc/ri/Folio/Link/new-c.yaml +10 -0
  148. data/doc/ri/Folio/Link/readlink-i.yaml +10 -0
  149. data/doc/ri/Folio/Link/symlink%3f-i.yaml +10 -0
  150. data/doc/ri/Folio/Pipe/cdesc-Pipe.yaml +17 -0
  151. data/doc/ri/Folio/Pipe/new-c.yaml +10 -0
  152. data/doc/ri/Folio/Pipe/pipe%3f-i.yaml +10 -0
  153. data/doc/ri/Folio/Prompt/%2b-i.yaml +13 -0
  154. data/doc/ri/Folio/Prompt/%2f-i.yaml +12 -0
  155. data/doc/ri/Folio/Prompt/%5b%5d-c.yaml +10 -0
  156. data/doc/ri/Folio/Prompt/cd-i.yaml +10 -0
  157. data/doc/ri/Folio/Prompt/cdesc-Prompt.yaml +89 -0
  158. data/doc/ri/Folio/Prompt/chmod-i.yaml +10 -0
  159. data/doc/ri/Folio/Prompt/chmod_r-i.yaml +10 -0
  160. data/doc/ri/Folio/Prompt/chown-i.yaml +12 -0
  161. data/doc/ri/Folio/Prompt/chown_r-i.yaml +10 -0
  162. data/doc/ri/Folio/Prompt/cp-i.yaml +12 -0
  163. data/doc/ri/Folio/Prompt/cp_r-i.yaml +12 -0
  164. data/doc/ri/Folio/Prompt/directories-i.yaml +12 -0
  165. data/doc/ri/Folio/Prompt/entries-i.yaml +13 -0
  166. data/doc/ri/Folio/Prompt/file-i.yaml +12 -0
  167. data/doc/ri/Folio/Prompt/files-i.yaml +12 -0
  168. data/doc/ri/Folio/Prompt/fileutils-i.yaml +10 -0
  169. data/doc/ri/Folio/Prompt/glob-i.yaml +12 -0
  170. data/doc/ri/Folio/Prompt/install-i.yaml +10 -0
  171. data/doc/ri/Folio/Prompt/ln-i.yaml +12 -0
  172. data/doc/ri/Folio/Prompt/ln_s-i.yaml +12 -0
  173. data/doc/ri/Folio/Prompt/ln_sf-i.yaml +10 -0
  174. data/doc/ri/Folio/Prompt/localize-i.yaml +10 -0
  175. data/doc/ri/Folio/Prompt/ls-i.yaml +12 -0
  176. data/doc/ri/Folio/Prompt/mkdir-i.yaml +10 -0
  177. data/doc/ri/Folio/Prompt/mkdir_p-i.yaml +10 -0
  178. data/doc/ri/Folio/Prompt/mode-i.yaml +12 -0
  179. data/doc/ri/Folio/Prompt/mv-i.yaml +12 -0
  180. data/doc/ri/Folio/Prompt/new-c.yaml +11 -0
  181. data/doc/ri/Folio/Prompt/paths-i.yaml +12 -0
  182. data/doc/ri/Folio/Prompt/pwd-i.yaml +10 -0
  183. data/doc/ri/Folio/Prompt/rm-i.yaml +10 -0
  184. data/doc/ri/Folio/Prompt/rm_r-i.yaml +10 -0
  185. data/doc/ri/Folio/Prompt/rm_rf-i.yaml +10 -0
  186. data/doc/ri/Folio/Prompt/rmdir-i.yaml +10 -0
  187. data/doc/ri/Folio/Prompt/to_s-i.yaml +10 -0
  188. data/doc/ri/Folio/Prompt/touch-i.yaml +12 -0
  189. data/doc/ri/Folio/Socket/cdesc-Socket.yaml +16 -0
  190. data/doc/ri/Folio/Socket/new-c.yaml +10 -0
  191. data/doc/ri/Folio/cdesc-Folio.yaml +15 -0
  192. data/doc/ri/created.rid +1 -0
  193. data/lib/folio/device.rb +29 -0
  194. data/lib/folio/directory.rb +83 -0
  195. data/lib/folio/document.rb +66 -0
  196. data/lib/folio/errors.rb +7 -0
  197. data/lib/folio/fileobject.rb +242 -0
  198. data/lib/folio/link.rb +49 -0
  199. data/lib/folio/pipe.rb +16 -0
  200. data/lib/folio/prompt.rb +239 -0
  201. data/lib/folio/socket.rb +14 -0
  202. data/lib/folio.rb +79 -0
  203. data/test/fixture/bar.txt +0 -0
  204. data/test/fixture/foo.txt +0 -0
  205. data/test/test_folio.rb +28 -0
  206. data/test/test_helper.rb +7 -0
  207. metadata +300 -0
@@ -0,0 +1,239 @@
1
+ module Folio
2
+
3
+ # = Prompt class
4
+ #
5
+ class Prompt
6
+
7
+ attr :path
8
+
9
+ #
10
+ def initialize(*path)
11
+ opts = (Hash===path.last ? path.pop : {})
12
+ mode(opts)
13
+
14
+ if path.empty?
15
+ path = Dir.pwd
16
+ else
17
+ path = File.join(*path)
18
+ end
19
+
20
+ raise FileNotFound unless ::File.exist?(path)
21
+ raise FileNotFound unless ::File.directory?(path)
22
+
23
+ @path = Directory.new(path)
24
+ end
25
+
26
+ # opertaton mode
27
+ def mode(opts=nil)
28
+ return @mode unless opts
29
+ opts.each do |key, val|
30
+ next unless val
31
+ case key
32
+ when :noop
33
+ @mode = (@mode == :verbose ? :dryrun : :noop)
34
+ when :verbose
35
+ @mode = (@mode == :noop ? :dryrun : :verbose)
36
+ when :dryrun
37
+ @mode = :dryrun
38
+ end
39
+ end
40
+ end
41
+
42
+ def to_s ; path.to_s ; end
43
+ def pwd ; path ; end
44
+
45
+ # Get the FileObject.
46
+ def file(name)
47
+ FileObject(name)
48
+ end
49
+
50
+ #--
51
+ # ::Dir
52
+ #++
53
+
54
+ # Join paths.
55
+ def +(fname)
56
+ @path =+ fname
57
+ end
58
+ alias_method :/, :+
59
+
60
+ # Directory entries.
61
+ def paths
62
+ path.paths
63
+ end
64
+
65
+ # Directory entries.
66
+ def entries
67
+ path.entries
68
+ end
69
+ alias_method :ls, :entries
70
+
71
+ # Directory entries.
72
+ def directories
73
+ path.paths.select{ |f| f.directory? }
74
+ end
75
+
76
+ # Directory entries.
77
+ def files
78
+ path.paths.select{ |f| f.file? }
79
+ end
80
+
81
+ # Glob pattern.
82
+ def glob(*patterns)
83
+ opts = (::Integer===patterns.last ? patterns.pop : 0)
84
+ pattern = localize(pattern)
85
+ ::Dir.glob(pattern, opts).each{ |f| FileObject[f] }
86
+ end
87
+
88
+ def cd(dir, &block)
89
+ #dir = localize(dir)
90
+ if block
91
+ @path.cd(dir, &block)
92
+ else
93
+ @path += dir
94
+ end
95
+ end
96
+
97
+ #--
98
+ # fileutils
99
+ #++
100
+
101
+ def mkdir(dir, options)
102
+ dir = localize(dir)
103
+ fileutils.mkdir(dir, options)
104
+ end
105
+
106
+ def mkdir_p(dir, options)
107
+ dir = localize(dir)
108
+ fileutils.mkdir_p(dir, options)
109
+ end
110
+
111
+ def rmdir(dir, options)
112
+ dir = localize(dir)
113
+ fileutils.rmdir(dir, options)
114
+ end
115
+
116
+ # ln(list, destdir, options)
117
+ def ln(old, new, options)
118
+ old = localize(old)
119
+ new = localize(new)
120
+ fileutils.ln(old, new, options)
121
+ end
122
+
123
+ # ln_s(list, destdir, options)
124
+ def ln_s(old, new, options)
125
+ old = localize(old)
126
+ new = localize(new)
127
+ fileutils.ln_s(old, new, options)
128
+ end
129
+
130
+ def ln_sf(old, new, options)
131
+ old = localize(old)
132
+ new = localize(new)
133
+ fileutils.ln_sf(old, new, options)
134
+ end
135
+
136
+ # cp(list, dir, options)
137
+ def cp(src, dest, options)
138
+ src = localize(src)
139
+ dest = localize(dest)
140
+ fileutils.cp(src, dest, options)
141
+ end
142
+
143
+ # cp_r(list, dir, options)
144
+ def cp_r(src, dest, options)
145
+ src = localize(src)
146
+ dest = localize(dest)
147
+ fileutils.cp_r(src, dest, options)
148
+ end
149
+
150
+ # mv(list, dir, options)
151
+ def mv(src, dest, options)
152
+ src = localize(src)
153
+ dest = localize(dest)
154
+ fileutils.mv(src, dest, options)
155
+ end
156
+
157
+ def rm(list, options)
158
+ list = localize(list)
159
+ fileutils.rm(list, options)
160
+ end
161
+
162
+ def rm_r(list, options)
163
+ list = localize(list)
164
+ fileutils.rm_f(list, options)
165
+ end
166
+
167
+ def rm_rf(list, options)
168
+ list = localize(list)
169
+ fileutils.rm_rf(list, options)
170
+ end
171
+
172
+ def install(src, dest, mode, options)
173
+ src = localize(src)
174
+ dest = localize(dest)
175
+ fileutils.install(src, dest, mode, options)
176
+ end
177
+
178
+ def chmod(mode, list, options)
179
+ list = localize(list)
180
+ fileutils.chmod(mode, list, options)
181
+ end
182
+
183
+ def chmod_r(mode, list, options)
184
+ list = localize(list)
185
+ fileutils.chmod_r(mode, list, options)
186
+ end
187
+ #alias_method :chmod_R, :chmod_r
188
+
189
+ def chown(user, group, list, options)
190
+ list = localize(list)
191
+ fileutils.chown(user, group, list, options)
192
+ end
193
+
194
+ def chown_r(user, group, list, options)
195
+ list = localize(list)
196
+ fileutils.chown_r(user, group, list, options)
197
+ end
198
+ #alias_method :chown_R, :chown_r
199
+
200
+ def touch(list, options)
201
+ list = localize(list)
202
+ fileutils.touch(list, options)
203
+ end
204
+
205
+ private
206
+
207
+ def localize(local_path)
208
+ case local_path
209
+ when Array
210
+ local_path.collect{ |lp| File.expand_path(File.join(path, lp)) }
211
+ else
212
+ File.expand_path(File.join(path, local_path))
213
+ end
214
+ end
215
+
216
+ def fileutils
217
+ return ::FileUtils unless @mode
218
+ case @mode
219
+ when :dryrun
220
+ ::FileUtils::DryRun
221
+ when :noop
222
+ ::FileUtils::Noop
223
+ when :verbose
224
+ ::FileUtils::Verbose
225
+ else
226
+ ::FileUtils
227
+ end
228
+ end
229
+
230
+ public#class
231
+
232
+ def self.[](path)
233
+ new(path)
234
+ end
235
+
236
+ end
237
+
238
+ end
239
+
@@ -0,0 +1,14 @@
1
+ require 'folio/fileobject'
2
+
3
+ module Folio
4
+
5
+ class Socket < FileObject
6
+
7
+ def initialize(path)
8
+ raise 'Sockets not yet supported.'
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
data/lib/folio.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'fileutils'
2
+ require 'folio/errors'
3
+ require 'folio/prompt'
4
+ require 'folio/fileobject'
5
+ require 'folio/directory'
6
+ require 'folio/document'
7
+ require 'folio/link'
8
+ require 'folio/device'
9
+ require 'folio/socket'
10
+ require 'folio/pipe'
11
+
12
+ #def folio(path)
13
+ # Folio.new(path)
14
+ #end
15
+
16
+ # = Folio
17
+ #
18
+ module Folio
19
+
20
+ def self.file(*path)
21
+ FileObject[*path]
22
+ end
23
+
24
+ def self.[](*path)
25
+ Prompt.new(*path)
26
+ end
27
+
28
+ end
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ #pwd()
39
+ =begin
40
+ if ::File.blockdev?(path)
41
+ Device.new(path)
42
+ elsif chardev?(path)
43
+ Device.new(path)
44
+ elsif pipe?(path)
45
+ Device.new(path)
46
+ elsif ::File.socket?(path)
47
+ Socket.new(path)
48
+ elsif ::File.directory?(path)
49
+ Directory.new(path)
50
+ else
51
+ Document.new(path)
52
+ end
53
+ end
54
+ =end
55
+
56
+ # delegate ?
57
+ =begin
58
+ def initialize(path)
59
+ @path = path = ::File.join(*path)
60
+
61
+ raise FileNotFound unless ::File.exist?(path)
62
+
63
+ if ::File.blockdev?(path) or chardev?(path)
64
+ @delegate = Device.new(path)
65
+ elsif ::File.link?(path)
66
+ @delegate = Link.new(path)
67
+ elsif ::File.directory?(path)
68
+ @delegate = Directory.new(path)
69
+ else
70
+ @delegate = Document.new(path)
71
+ end
72
+ end
73
+
74
+ def delete
75
+ @delegate.delete
76
+ @delegate = nil
77
+ end
78
+ =end
79
+
File without changes
File without changes
@@ -0,0 +1,28 @@
1
+ require 'folio'
2
+
3
+ require(File.dirname(__FILE__) + '/test_helper')
4
+
5
+ Quarry::Design.spec "Folio Specification" do
6
+
7
+ Dir.chdir(File.dirname(__FILE__))
8
+
9
+ demonstrate "filio navigation" do
10
+
11
+ c = Folio['fixture']
12
+
13
+ calling "entries" do
14
+ c.entries.sort.assert == ['.', '..', 'bar.txt', 'foo.txt', 'sub']
15
+ end
16
+
17
+ calling "paths" do
18
+ c.paths.sort.assert == [
19
+ Folio.file('fixture/bar.txt'),
20
+ Folio.file('fixture/foo.txt'),
21
+ Folio.file('fixture/sub')
22
+ ]
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH.unshift('lib')
2
+
3
+ require 'quarry/design/spec'
4
+
5
+ #$DEBUG = true
6
+ $VERBOSE = true
7
+
metadata ADDED
@@ -0,0 +1,300 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: folio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors: []
7
+
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-22 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Folio is a better way to access the file system.
17
+ email:
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - MANIFEST
25
+ - METADATA
26
+ - NEWS
27
+ - COPYING
28
+ files:
29
+ - doc
30
+ - doc/rdoc
31
+ - doc/rdoc/fr_file_index.html
32
+ - doc/rdoc/classes
33
+ - doc/rdoc/classes/Folio
34
+ - doc/rdoc/classes/Folio/FileObject.html
35
+ - doc/rdoc/classes/Folio/BlockDevice.html
36
+ - doc/rdoc/classes/Folio/Link.html
37
+ - doc/rdoc/classes/Folio/Document.html
38
+ - doc/rdoc/classes/Folio/CharacterDevice.html
39
+ - doc/rdoc/classes/Folio/Pipe.html
40
+ - doc/rdoc/classes/Folio/Device.html
41
+ - doc/rdoc/classes/Folio/Socket.html
42
+ - doc/rdoc/classes/Folio/Prompt.html
43
+ - doc/rdoc/classes/Folio/Directory.html
44
+ - doc/rdoc/classes/Folio/FileNotFound.html
45
+ - doc/rdoc/classes/Folio.html
46
+ - doc/rdoc/rdoc-style.css
47
+ - doc/rdoc/files
48
+ - doc/rdoc/files/README.html
49
+ - doc/rdoc/files/METADATA.html
50
+ - doc/rdoc/files/lib
51
+ - doc/rdoc/files/lib/folio
52
+ - doc/rdoc/files/lib/folio/fileobject_rb.html
53
+ - doc/rdoc/files/lib/folio/link_rb.html
54
+ - doc/rdoc/files/lib/folio/document_rb.html
55
+ - doc/rdoc/files/lib/folio/errors_rb.html
56
+ - doc/rdoc/files/lib/folio/device_rb.html
57
+ - doc/rdoc/files/lib/folio/prompt_rb.html
58
+ - doc/rdoc/files/lib/folio/socket_rb.html
59
+ - doc/rdoc/files/lib/folio/pipe_rb.html
60
+ - doc/rdoc/files/lib/folio/directory_rb.html
61
+ - doc/rdoc/files/lib/folio_rb.html
62
+ - doc/rdoc/files/NEWS.html
63
+ - doc/rdoc/files/COPYING.html
64
+ - doc/rdoc/fr_class_index.html
65
+ - doc/rdoc/index.html
66
+ - doc/rdoc/created.rid
67
+ - doc/rdoc/fr_method_index.html
68
+ - doc/ri
69
+ - doc/ri/Folio
70
+ - doc/ri/Folio/Prompt
71
+ - doc/ri/Folio/Prompt/chmod-i.yaml
72
+ - doc/ri/Folio/Prompt/touch-i.yaml
73
+ - doc/ri/Folio/Prompt/%2b-i.yaml
74
+ - doc/ri/Folio/Prompt/glob-i.yaml
75
+ - doc/ri/Folio/Prompt/mkdir-i.yaml
76
+ - doc/ri/Folio/Prompt/ln-i.yaml
77
+ - doc/ri/Folio/Prompt/mv-i.yaml
78
+ - doc/ri/Folio/Prompt/files-i.yaml
79
+ - doc/ri/Folio/Prompt/entries-i.yaml
80
+ - doc/ri/Folio/Prompt/rm_rf-i.yaml
81
+ - doc/ri/Folio/Prompt/paths-i.yaml
82
+ - doc/ri/Folio/Prompt/mkdir_p-i.yaml
83
+ - doc/ri/Folio/Prompt/pwd-i.yaml
84
+ - doc/ri/Folio/Prompt/%2f-i.yaml
85
+ - doc/ri/Folio/Prompt/ln_sf-i.yaml
86
+ - doc/ri/Folio/Prompt/chown-i.yaml
87
+ - doc/ri/Folio/Prompt/ln_s-i.yaml
88
+ - doc/ri/Folio/Prompt/directories-i.yaml
89
+ - doc/ri/Folio/Prompt/cp-i.yaml
90
+ - doc/ri/Folio/Prompt/rmdir-i.yaml
91
+ - doc/ri/Folio/Prompt/localize-i.yaml
92
+ - doc/ri/Folio/Prompt/chown_r-i.yaml
93
+ - doc/ri/Folio/Prompt/mode-i.yaml
94
+ - doc/ri/Folio/Prompt/cp_r-i.yaml
95
+ - doc/ri/Folio/Prompt/install-i.yaml
96
+ - doc/ri/Folio/Prompt/rm_r-i.yaml
97
+ - doc/ri/Folio/Prompt/cdesc-Prompt.yaml
98
+ - doc/ri/Folio/Prompt/chmod_r-i.yaml
99
+ - doc/ri/Folio/Prompt/file-i.yaml
100
+ - doc/ri/Folio/Prompt/to_s-i.yaml
101
+ - doc/ri/Folio/Prompt/%5b%5d-c.yaml
102
+ - doc/ri/Folio/Prompt/new-c.yaml
103
+ - doc/ri/Folio/Prompt/fileutils-i.yaml
104
+ - doc/ri/Folio/Prompt/cd-i.yaml
105
+ - doc/ri/Folio/Prompt/rm-i.yaml
106
+ - doc/ri/Folio/Prompt/ls-i.yaml
107
+ - doc/ri/Folio/Link
108
+ - doc/ri/Folio/Link/lstat-i.yaml
109
+ - doc/ri/Folio/Link/link%3f-i.yaml
110
+ - doc/ri/Folio/Link/cdesc-Link.yaml
111
+ - doc/ri/Folio/Link/lchmod-i.yaml
112
+ - doc/ri/Folio/Link/lchown-i.yaml
113
+ - doc/ri/Folio/Link/symlink%3f-i.yaml
114
+ - doc/ri/Folio/Link/new-c.yaml
115
+ - doc/ri/Folio/Link/readlink-i.yaml
116
+ - doc/ri/Folio/Link/method_missing-i.yaml
117
+ - doc/ri/Folio/FileObject
118
+ - doc/ri/Folio/FileObject/chmod-i.yaml
119
+ - doc/ri/Folio/FileObject/split-i.yaml
120
+ - doc/ri/Folio/FileObject/unlink_force-i.yaml
121
+ - doc/ri/Folio/FileObject/rm_f-i.yaml
122
+ - doc/ri/Folio/FileObject/readable%3f-i.yaml
123
+ - doc/ri/Folio/FileObject/touch-i.yaml
124
+ - doc/ri/Folio/FileObject/symlink-i.yaml
125
+ - doc/ri/Folio/FileObject/writable_real%3f-i.yaml
126
+ - doc/ri/Folio/FileObject/delete_force-i.yaml
127
+ - doc/ri/Folio/FileObject/atime-i.yaml
128
+ - doc/ri/Folio/FileObject/ln-i.yaml
129
+ - doc/ri/Folio/FileObject/readable_real%3f-i.yaml
130
+ - doc/ri/Folio/FileObject/mv-i.yaml
131
+ - doc/ri/Folio/FileObject/size%3f-i.yaml
132
+ - doc/ri/Folio/FileObject/owned%3f-i.yaml
133
+ - doc/ri/Folio/FileObject/chardev%3f-i.yaml
134
+ - doc/ri/Folio/FileObject/link-i.yaml
135
+ - doc/ri/Folio/FileObject/grpowned%3f-i.yaml
136
+ - doc/ri/Folio/FileObject/stat%21-i.yaml
137
+ - doc/ri/Folio/FileObject/identical%3f-i.yaml
138
+ - doc/ri/Folio/FileObject/%3c%3d%3e-i.yaml
139
+ - doc/ri/Folio/FileObject/blockdev%3f-i.yaml
140
+ - doc/ri/Folio/FileObject/util-i.yaml
141
+ - doc/ri/Folio/FileObject/delete-i.yaml
142
+ - doc/ri/Folio/FileObject/relative-i.yaml
143
+ - doc/ri/Folio/FileObject/utime-i.yaml
144
+ - doc/ri/Folio/FileObject/fnmatch%3f-i.yaml
145
+ - doc/ri/Folio/FileObject/ln_sf-i.yaml
146
+ - doc/ri/Folio/FileObject/chown-i.yaml
147
+ - doc/ri/Folio/FileObject/restat-i.yaml
148
+ - doc/ri/Folio/FileObject/ln_s-i.yaml
149
+ - doc/ri/Folio/FileObject/inspect-i.yaml
150
+ - doc/ri/Folio/FileObject/size-i.yaml
151
+ - doc/ri/Folio/FileObject/exists%3f-i.yaml
152
+ - doc/ri/Folio/FileObject/cp-i.yaml
153
+ - doc/ri/Folio/FileObject/setgid%3f-i.yaml
154
+ - doc/ri/Folio/FileObject/symlink_force-i.yaml
155
+ - doc/ri/Folio/FileObject/socket%3f-i.yaml
156
+ - doc/ri/Folio/FileObject/unlink-i.yaml
157
+ - doc/ri/Folio/FileObject/%3d%3d-i.yaml
158
+ - doc/ri/Folio/FileObject/zero%3f-i.yaml
159
+ - doc/ri/Folio/FileObject/setuid%3f-i.yaml
160
+ - doc/ri/Folio/FileObject/exist%3f-i.yaml
161
+ - doc/ri/Folio/FileObject/basename-i.yaml
162
+ - doc/ri/Folio/FileObject/ctime-i.yaml
163
+ - doc/ri/Folio/FileObject/cdesc-FileObject.yaml
164
+ - doc/ri/Folio/FileObject/ln_f-i.yaml
165
+ - doc/ri/Folio/FileObject/file%3f-i.yaml
166
+ - doc/ri/Folio/FileObject/directory%3f-i.yaml
167
+ - doc/ri/Folio/FileObject/stat-i.yaml
168
+ - doc/ri/Folio/FileObject/install-i.yaml
169
+ - doc/ri/Folio/FileObject/to_s-i.yaml
170
+ - doc/ri/Folio/FileObject/extname-i.yaml
171
+ - doc/ri/Folio/FileObject/%5b%5d-c.yaml
172
+ - doc/ri/Folio/FileObject/writable%3f-i.yaml
173
+ - doc/ri/Folio/FileObject/link_force-i.yaml
174
+ - doc/ri/Folio/FileObject/mtime-i.yaml
175
+ - doc/ri/Folio/FileObject/new-c.yaml
176
+ - doc/ri/Folio/FileObject/pipe%3f-i.yaml
177
+ - doc/ri/Folio/FileObject/rename-i.yaml
178
+ - doc/ri/Folio/FileObject/sticky%3f-i.yaml
179
+ - doc/ri/Folio/FileObject/rm-i.yaml
180
+ - doc/ri/Folio/FileObject/dirname-i.yaml
181
+ - doc/ri/Folio/FileObject/fnmatch-i.yaml
182
+ - doc/ri/Folio/Pipe
183
+ - doc/ri/Folio/Pipe/cdesc-Pipe.yaml
184
+ - doc/ri/Folio/Pipe/new-c.yaml
185
+ - doc/ri/Folio/Pipe/pipe%3f-i.yaml
186
+ - doc/ri/Folio/Socket
187
+ - doc/ri/Folio/Socket/cdesc-Socket.yaml
188
+ - doc/ri/Folio/Socket/new-c.yaml
189
+ - doc/ri/Folio/Document
190
+ - doc/ri/Folio/Document/open-i.yaml
191
+ - doc/ri/Folio/Document/read-i.yaml
192
+ - doc/ri/Folio/Document/cdesc-Document.yaml
193
+ - doc/ri/Folio/Document/executable%3f-i.yaml
194
+ - doc/ri/Folio/Document/readlines-i.yaml
195
+ - doc/ri/Folio/Document/delete-i.yaml
196
+ - doc/ri/Folio/Document/intialize-i.yaml
197
+ - doc/ri/Folio/Document/unlink-i.yaml
198
+ - doc/ri/Folio/Document/truncate-i.yaml
199
+ - doc/ri/Folio/Document/file%3f-i.yaml
200
+ - doc/ri/Folio/Document/executable_real%3f-i.yaml
201
+ - doc/ri/Folio/FileNotFound
202
+ - doc/ri/Folio/FileNotFound/cdesc-FileNotFound.yaml
203
+ - doc/ri/Folio/Device
204
+ - doc/ri/Folio/Device/cdesc-Device.yaml
205
+ - doc/ri/Folio/Device/new-c.yaml
206
+ - doc/ri/Folio/BlockDevice
207
+ - doc/ri/Folio/BlockDevice/blockdev%3f-i.yaml
208
+ - doc/ri/Folio/BlockDevice/cdesc-BlockDevice.yaml
209
+ - doc/ri/Folio/CharacterDevice
210
+ - doc/ri/Folio/CharacterDevice/chardev%3f-i.yaml
211
+ - doc/ri/Folio/CharacterDevice/cdesc-CharacterDevice.yaml
212
+ - doc/ri/Folio/Directory
213
+ - doc/ri/Folio/Directory/%2b-i.yaml
214
+ - doc/ri/Folio/Directory/entries-i.yaml
215
+ - doc/ri/Folio/Directory/rm_rf-i.yaml
216
+ - doc/ri/Folio/Directory/paths-i.yaml
217
+ - doc/ri/Folio/Directory/delete-i.yaml
218
+ - doc/ri/Folio/Directory/chroot-i.yaml
219
+ - doc/ri/Folio/Directory/%2f-i.yaml
220
+ - doc/ri/Folio/Directory/chdir-i.yaml
221
+ - doc/ri/Folio/Directory/foreach-i.yaml
222
+ - doc/ri/Folio/Directory/unlink-i.yaml
223
+ - doc/ri/Folio/Directory/rmdir-i.yaml
224
+ - doc/ri/Folio/Directory/cdesc-Directory.yaml
225
+ - doc/ri/Folio/Directory/chown_r-i.yaml
226
+ - doc/ri/Folio/Directory/directory%3f-i.yaml
227
+ - doc/ri/Folio/Directory/cp_r-i.yaml
228
+ - doc/ri/Folio/Directory/rm_r-i.yaml
229
+ - doc/ri/Folio/Directory/chmod_r-i.yaml
230
+ - doc/ri/Folio/Directory/new-c.yaml
231
+ - doc/ri/Folio/Directory/cd-i.yaml
232
+ - doc/ri/Folio/cdesc-Folio.yaml
233
+ - doc/ri/created.rid
234
+ - MANIFEST
235
+ - test
236
+ - test/test_folio.rb
237
+ - test/test_helper.rb
238
+ - test/fixture
239
+ - test/fixture/foo.txt
240
+ - test/fixture/sub
241
+ - test/fixture/bar.txt
242
+ - README
243
+ - METADATA
244
+ - demo
245
+ - demo/sample1
246
+ - demo/sample1/bar
247
+ - demo/sample1/foo
248
+ - demo/sample1/foo/foo.txt
249
+ - demo/sample1/tryme.rb
250
+ - lib
251
+ - lib/folio
252
+ - lib/folio/link.rb
253
+ - lib/folio/pipe.rb
254
+ - lib/folio/directory.rb
255
+ - lib/folio/device.rb
256
+ - lib/folio/errors.rb
257
+ - lib/folio/document.rb
258
+ - lib/folio/fileobject.rb
259
+ - lib/folio/socket.rb
260
+ - lib/folio/prompt.rb
261
+ - lib/folio.rb
262
+ - NEWS
263
+ - COPYING
264
+ has_rdoc: true
265
+ homepage: http://folio.rubyforge.org
266
+ post_install_message:
267
+ rdoc_options:
268
+ - --inline-source
269
+ - --title
270
+ - folio api
271
+ - --main
272
+ - README
273
+ require_paths:
274
+ - lib
275
+ required_ruby_version: !ruby/object:Gem::Requirement
276
+ requirements:
277
+ - - ">="
278
+ - !ruby/object:Gem::Version
279
+ version: "0"
280
+ version:
281
+ required_rubygems_version: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: "0"
286
+ version:
287
+ requirements: []
288
+
289
+ rubyforge_project: folio
290
+ rubygems_version: 1.2.0
291
+ signing_key:
292
+ specification_version: 2
293
+ summary: Folio is a better way to access the file system.
294
+ test_files:
295
+ - test/test_folio.rb
296
+ - test/test_helper.rb
297
+ - test/fixture
298
+ - test/fixture/foo.txt
299
+ - test/fixture/sub
300
+ - test/fixture/bar.txt