folio 0.3.0 → 0.4.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/CHANGES +91 -7
- data/COPYING +162 -669
- data/MANIFEST +52 -16
- data/README +1 -1
- data/RELEASE +14 -0
- data/VERSION +1 -1
- data/demo/sample1/tryme.rb +1 -1
- data/doc/log/basic_stats/index.html +39 -0
- data/doc/log/changelog.html +323 -0
- data/doc/log/changelog.xml +129 -0
- data/doc/log/changelog.xsl +33 -0
- data/doc/log/notes.xml +35 -0
- data/{NEWS → doc/note/release-0.3.0.txt} +1 -1
- data/doc/spec/index.html +552 -0
- data/lib/folio.rb +15 -3
- data/lib/folio/directory.rb +10 -5
- data/lib/folio/document.rb +11 -8
- data/lib/folio/errors.rb +15 -0
- data/lib/folio/fileobject.rb +6 -3
- data/lib/folio/filetest.rb +88 -0
- data/lib/folio/fileutils.rb +39 -0
- data/lib/folio/link.rb +2 -5
- data/lib/folio/minitar.rb +1063 -0
- data/lib/folio/multiglob.rb +91 -0
- data/lib/folio/path.rb +56 -0
- data/lib/folio/shell.rb +289 -50
- data/lib/folio/uploadutils.rb +434 -0
- data/lib/folio/xdg.rb +4 -0
- data/lib/folio/ziputils.rb +489 -0
- data/spec/document/basic.rd +53 -0
- data/spec/document/fixtures/foo.txt +1 -0
- data/spec/document/fixtures/out.txt +1 -0
- data/spec/link/fixtures/foo.txt +1 -0
- data/spec/link/general.rd +44 -0
- data/spec/shell/fixtures/foo.txt +1 -0
- data/spec/shell/fixtures/out.txt +1 -0
- data/spec/shell/general.rd +30 -0
- data/spec/shell/issues.rd +100 -0
- metadata +58 -27
@@ -0,0 +1,53 @@
|
|
1
|
+
= Document Unit Testing
|
2
|
+
|
3
|
+
Load the Folio library.
|
4
|
+
|
5
|
+
require 'folio'
|
6
|
+
|
7
|
+
Instantiate document object.
|
8
|
+
|
9
|
+
@foo = Folio.file('fixtures/foo.txt')
|
10
|
+
|
11
|
+
Confirm it is a a document.
|
12
|
+
|
13
|
+
@foo.assert.document?
|
14
|
+
|
15
|
+
Confirm it is equal to another document initialized identically.
|
16
|
+
|
17
|
+
@foo.assert == Folio.file('fixtures/foo.txt')
|
18
|
+
|
19
|
+
Confirm it is equal to the same file initialized from a different
|
20
|
+
working directory.
|
21
|
+
|
22
|
+
f = nil
|
23
|
+
Dir.chdir('fixtures') do
|
24
|
+
f = Folio.file('foo.txt')
|
25
|
+
end
|
26
|
+
@foo.assert == f
|
27
|
+
|
28
|
+
Document can be read.
|
29
|
+
|
30
|
+
@foo.read.assert == "THIS IS FOO!\n"
|
31
|
+
|
32
|
+
The #readlines methods read the document into an array of lines.
|
33
|
+
|
34
|
+
@foo.readlines.assert == ["THIS IS FOO!\n"]
|
35
|
+
|
36
|
+
We can also open the document for reading using the more
|
37
|
+
traditional open() method.
|
38
|
+
|
39
|
+
t = nil
|
40
|
+
@foo.open('r'){ |f| t = f.read }
|
41
|
+
t.assert == "THIS IS FOO!\n"
|
42
|
+
|
43
|
+
The #parent method return the Directory object in which the document
|
44
|
+
is contained.
|
45
|
+
|
46
|
+
@foo.parent.assert == Folio.file('fixtures')
|
47
|
+
|
48
|
+
A document can be written to as well using the #write method.
|
49
|
+
|
50
|
+
out = Folio.doc('fixtures/out.txt')
|
51
|
+
out.write('Hello')
|
52
|
+
File.read(out.to_s).assert == 'Hello'
|
53
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
THIS IS FOO!
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello
|
@@ -0,0 +1 @@
|
|
1
|
+
THIS IS FOO!
|
@@ -0,0 +1,44 @@
|
|
1
|
+
= General Usage of Folio Link Object
|
2
|
+
|
3
|
+
Require the Folio library.
|
4
|
+
|
5
|
+
require 'folio'
|
6
|
+
|
7
|
+
Instantiate a soft link.
|
8
|
+
|
9
|
+
@foo = Folio.file('fixtures/foo_softlink.txt')
|
10
|
+
|
11
|
+
It is a link.
|
12
|
+
|
13
|
+
@foo.link?.assert == true
|
14
|
+
|
15
|
+
It is equal to a link defined identically.
|
16
|
+
|
17
|
+
@foo.assert == Folio.file('fixtures/foo_softlink.txt')
|
18
|
+
|
19
|
+
The link is not equal to the target document.
|
20
|
+
|
21
|
+
@foo.assert! == Folio.file('fixtures/foo.txt')
|
22
|
+
|
23
|
+
But it is equal to a same link instantiated from a differnt working directory.
|
24
|
+
|
25
|
+
f = nil
|
26
|
+
Dir.chdir('fixtures') do
|
27
|
+
f = Folio.file('foo_softlink.txt')
|
28
|
+
end
|
29
|
+
@foo.assert == f
|
30
|
+
|
31
|
+
Reads the linked document correctly.
|
32
|
+
|
33
|
+
@foo.read == "THIS IS FOO!"
|
34
|
+
|
35
|
+
Opens the linked document for reading.
|
36
|
+
|
37
|
+
t = nil
|
38
|
+
@foo.open('r'){ |f| t = f.read }
|
39
|
+
t.assert == "THIS IS FOO!\n"
|
40
|
+
|
41
|
+
It provides the parent directory object.
|
42
|
+
|
43
|
+
@foo.parent.assert == Folio.dir('fixtures')
|
44
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
THIS IS FOO!
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello
|
@@ -0,0 +1,30 @@
|
|
1
|
+
= General Usage of the Folio Shell
|
2
|
+
|
3
|
+
Require the Folio library.
|
4
|
+
|
5
|
+
require 'folio'
|
6
|
+
|
7
|
+
Open a new Folio::Shell object.
|
8
|
+
|
9
|
+
@c = Folio.shell('fixtures')
|
10
|
+
|
11
|
+
Method #work returns current working directory.
|
12
|
+
|
13
|
+
@c.work.assert == Folio.dir('fixtures')
|
14
|
+
|
15
|
+
Method #to_s returns current working dirname.
|
16
|
+
|
17
|
+
@c.to_s.assert == File.join(Dir.pwd, 'fixtures')
|
18
|
+
|
19
|
+
Method #entries returns a list of names of the current directory content.
|
20
|
+
|
21
|
+
@c.entries.sort.assert == ['foo.txt', 'foo_softlink.txt', 'out.txt']
|
22
|
+
|
23
|
+
Method #files returns an array of file objects in the current directory.
|
24
|
+
|
25
|
+
f = @c.files.to_a
|
26
|
+
f.size.assert == 3
|
27
|
+
f.assert.include?(Folio.file('fixtures/foo_softlink.txt'))
|
28
|
+
f.assert.include?(Folio.file('fixtures/foo.txt'))
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
= Problem Scenerios
|
2
|
+
|
3
|
+
== Non-existant paths
|
4
|
+
|
5
|
+
If a path does not exist, how do we know if it is intended to
|
6
|
+
be a file, or directory, or what?
|
7
|
+
|
8
|
+
d1 = dir('home/trans')
|
9
|
+
d2 = d1 / 'images'
|
10
|
+
|
11
|
+
Optons for resolution include:
|
12
|
+
|
13
|
+
* Do not support ambiguitous methods.
|
14
|
+
* Raise an error if non-existant.
|
15
|
+
* Default to a directory when ambiguious.
|
16
|
+
* Use a delegator.
|
17
|
+
|
18
|
+
The first solution is the most straightforward. The second is
|
19
|
+
reasonably viable as well, but at least it provides some
|
20
|
+
understanble use for such methods.
|
21
|
+
|
22
|
+
The return value of the third feels to quirky. And the last is a
|
23
|
+
complex solution that effectively only leaves us with some sort
|
24
|
+
of non-disk Pathname object; a solution almost a quirky.
|
25
|
+
|
26
|
+
== Removal of file-io object
|
27
|
+
|
28
|
+
If we delete a file object, then the object looses it's reference.
|
29
|
+
This is especially problematic if we do not allow file objects
|
30
|
+
to have non-existant paths.
|
31
|
+
|
32
|
+
d2 = d1.dir('images')
|
33
|
+
d2.rm_r
|
34
|
+
|
35
|
+
Options for resolution:
|
36
|
+
|
37
|
+
* Do not support removal methods.
|
38
|
+
* Allow non-existant paths.
|
39
|
+
* Use delegator.
|
40
|
+
|
41
|
+
The first solution would mean using a parent directory object to
|
42
|
+
delete anything.
|
43
|
+
|
44
|
+
f1 = file('/home/trans/.bashrc')
|
45
|
+
f1.rm # not allowed
|
46
|
+
f1.parent.rm(f1) # instead
|
47
|
+
|
48
|
+
I do not like this option becuase it means a directory object
|
49
|
+
would behave substantially differnt from other file objects.
|
50
|
+
That might not be so bad is Shell and Directory could be
|
51
|
+
one and the same, but methods like #ctime would still
|
52
|
+
clash.
|
53
|
+
|
54
|
+
The second option is the simplist. The file object simply takes
|
55
|
+
on a "virtual" state. This could lead to errors being thrown,
|
56
|
+
but it is not unacceptable.
|
57
|
+
|
58
|
+
f1 = file('/home/trans/.bashrc')
|
59
|
+
f1.rm
|
60
|
+
f1.ctime # error
|
61
|
+
|
62
|
+
The last solution creates an indirection for all file objects.
|
63
|
+
Removing a file would redelegate to a virtual pathname object.
|
64
|
+
This is a more complicated solution and is really no better
|
65
|
+
than the previous solutution --MethodMissing would be the
|
66
|
+
error. A delegtor solution is a bit more interesting when we
|
67
|
+
consider virtual file objects that can mimic a file system.
|
68
|
+
However that could be a rather misleading redelgation.
|
69
|
+
|
70
|
+
== Looking at the Lager Picture
|
71
|
+
|
72
|
+
Do we really need these objects? Isn't the core idea the Folio
|
73
|
+
Shell? For the first issue, what is wrong with:
|
74
|
+
|
75
|
+
s1 = shell('home/trans')
|
76
|
+
s2 = s1 / 'images'
|
77
|
+
|
78
|
+
Which would clearly raise an error if it were not existant.
|
79
|
+
|
80
|
+
As for the second. While it might not be quite as concise, it fits
|
81
|
+
the shell prompt pattern:
|
82
|
+
|
83
|
+
s1 = shell('/home/trans')
|
84
|
+
s1.rm('.bashrc')
|
85
|
+
|
86
|
+
Yea, ok. However, while we could pass around shell objects as
|
87
|
+
a form of directory object, this would leave us no way to pass
|
88
|
+
file objects.
|
89
|
+
|
90
|
+
== Conclusion
|
91
|
+
|
92
|
+
It is fairly clear that the second solution to the second issue
|
93
|
+
is the clearest choice. And that Directory and Shell should
|
94
|
+
in fact stay separate objects. The "Larger Picture" should be
|
95
|
+
the general pattern for theses cases, however this ought not
|
96
|
+
prevent the use of the file objects as well.
|
97
|
+
|
98
|
+
As for the first issue, the first or second options the better
|
99
|
+
choices. I will probably raise the error.
|
100
|
+
|
metadata
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
tigerops-community@rubyforge.org
|
9
|
-
|
7
|
+
- tigerops-community@rubyforge.org
|
10
8
|
- 7rans <transfire@gmail.com>
|
11
9
|
autorequire:
|
12
10
|
bindir: bin
|
13
11
|
cert_chain: []
|
14
12
|
|
15
|
-
date: 2008-
|
13
|
+
date: 2008-11-21 00:00:00 -05:00
|
16
14
|
default_executable:
|
17
15
|
dependencies: []
|
18
16
|
|
@@ -26,51 +24,84 @@ extra_rdoc_files:
|
|
26
24
|
- README
|
27
25
|
- MANIFEST
|
28
26
|
- CHANGES
|
27
|
+
- RELEASE
|
29
28
|
- TODO
|
30
29
|
- VERSION
|
31
|
-
- NEWS
|
32
30
|
- COPYING
|
33
31
|
files:
|
32
|
+
- demo
|
34
33
|
- doc
|
35
|
-
-
|
36
|
-
-
|
34
|
+
- lib
|
35
|
+
- meta
|
36
|
+
- spec
|
37
37
|
- MANIFEST
|
38
38
|
- CHANGES
|
39
|
+
- RELEASE
|
39
40
|
- TODO
|
40
41
|
- README
|
41
|
-
-
|
42
|
-
-
|
43
|
-
- meta/summary
|
44
|
-
- meta/abstract
|
45
|
-
- meta/releases
|
46
|
-
- meta/authors
|
47
|
-
- meta/contact
|
48
|
-
- demo
|
42
|
+
- VERSION
|
43
|
+
- COPYING
|
49
44
|
- demo/sample1
|
50
45
|
- demo/sample1/bar
|
51
46
|
- demo/sample1/foo
|
52
|
-
- demo/sample1/foo/foo.txt
|
53
47
|
- demo/sample1/tryme.rb
|
54
|
-
-
|
48
|
+
- demo/sample1/foo/foo.txt
|
49
|
+
- doc/spec
|
50
|
+
- doc/book
|
51
|
+
- doc/note
|
52
|
+
- doc/log
|
53
|
+
- doc/spec/index.html
|
54
|
+
- doc/book/basedir-spec-0.6.html
|
55
|
+
- doc/note/release-0.3.0.txt
|
56
|
+
- doc/log/basic_stats
|
57
|
+
- doc/log/changelog.html
|
58
|
+
- doc/log/changelog.xml
|
59
|
+
- doc/log/notes.xml
|
60
|
+
- doc/log/changelog.xsl
|
61
|
+
- doc/log/basic_stats/index.html
|
55
62
|
- lib/folio
|
63
|
+
- lib/folio.rb
|
64
|
+
- lib/folio/filetest.rb
|
65
|
+
- lib/folio/fileutils.rb
|
66
|
+
- lib/folio/path.rb
|
67
|
+
- lib/folio/multiglob.rb
|
56
68
|
- lib/folio/link.rb
|
57
69
|
- lib/folio/pipe.rb
|
58
70
|
- lib/folio/directory.rb
|
59
71
|
- lib/folio/device.rb
|
60
72
|
- lib/folio/errors.rb
|
73
|
+
- lib/folio/uploadutils.rb
|
61
74
|
- lib/folio/shell.rb
|
75
|
+
- lib/folio/ziputils.rb
|
62
76
|
- lib/folio/document.rb
|
63
77
|
- lib/folio/xdg.rb
|
64
78
|
- lib/folio/fileobject.rb
|
65
79
|
- lib/folio/socket.rb
|
66
|
-
- lib/folio.rb
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
80
|
+
- lib/folio/minitar.rb
|
81
|
+
- meta/homepage
|
82
|
+
- meta/summary
|
83
|
+
- meta/abstract
|
84
|
+
- meta/releases
|
85
|
+
- meta/authors
|
86
|
+
- meta/contact
|
87
|
+
- spec/document
|
88
|
+
- spec/link
|
89
|
+
- spec/shell
|
90
|
+
- spec/document/basic.rd
|
91
|
+
- spec/document/fixtures
|
92
|
+
- spec/document/fixtures/foo.txt
|
93
|
+
- spec/document/fixtures/out.txt
|
94
|
+
- spec/link/fixtures
|
95
|
+
- spec/link/general.rd
|
96
|
+
- spec/link/fixtures/foo.txt
|
97
|
+
- spec/shell/fixtures
|
98
|
+
- spec/shell/general.rd
|
99
|
+
- spec/shell/issues.rd
|
100
|
+
- spec/shell/fixtures/foo.txt
|
101
|
+
- spec/shell/fixtures/sub
|
102
|
+
- spec/shell/fixtures/out.txt
|
70
103
|
has_rdoc: true
|
71
|
-
homepage:
|
72
|
-
http://folio.rubyforge.org
|
73
|
-
|
104
|
+
homepage: http://folio.rubyforge.org
|
74
105
|
post_install_message:
|
75
106
|
rdoc_options:
|
76
107
|
- --inline-source
|
@@ -99,5 +130,5 @@ rubygems_version: 1.2.0
|
|
99
130
|
signing_key:
|
100
131
|
specification_version: 2
|
101
132
|
summary: Folio is a better way to access the file system.
|
102
|
-
test_files:
|
103
|
-
|
133
|
+
test_files:
|
134
|
+
- lib/folio/filetest.rb
|