fffs 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fffs/directory.rb +4 -12
- data/lib/fffs/file.rb +6 -10
- data/lib/fffs/filesystem.rb +0 -1
- data/lib/fffs/node.rb +36 -0
- metadata +3 -2
data/lib/fffs/directory.rb
CHANGED
@@ -17,9 +17,13 @@
|
|
17
17
|
# along with fffs. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
19
|
|
20
|
+
require 'fffs/node'
|
21
|
+
|
20
22
|
module FFFS
|
21
23
|
|
22
24
|
class Directory < Hash
|
25
|
+
include Node
|
26
|
+
|
23
27
|
attr_accessor :filesystem, :parent
|
24
28
|
|
25
29
|
attr_reader :name
|
@@ -78,18 +82,6 @@ class Directory < Hash
|
|
78
82
|
}
|
79
83
|
end
|
80
84
|
|
81
|
-
def path
|
82
|
-
path = []
|
83
|
-
current = self
|
84
|
-
|
85
|
-
begin
|
86
|
-
path << current.name
|
87
|
-
current = current.parent
|
88
|
-
end while current != current.parent
|
89
|
-
|
90
|
-
"/#{path.reverse.join('/')}/".sub(%r{/*/}, '/')
|
91
|
-
end
|
92
|
-
|
93
85
|
def inspect
|
94
86
|
output = "#{self.path}\n"
|
95
87
|
|
data/lib/fffs/file.rb
CHANGED
@@ -17,9 +17,13 @@
|
|
17
17
|
# along with fffs. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
19
|
|
20
|
+
require 'fffs/node'
|
21
|
+
|
20
22
|
module FFFS
|
21
23
|
|
22
24
|
class File
|
25
|
+
include Node
|
26
|
+
|
23
27
|
attr_accessor :filesystem, :parent
|
24
28
|
|
25
29
|
attr_accessor :content
|
@@ -41,16 +45,8 @@ class File
|
|
41
45
|
@parent << self
|
42
46
|
end
|
43
47
|
|
44
|
-
def
|
45
|
-
|
46
|
-
current = self
|
47
|
-
|
48
|
-
begin
|
49
|
-
path << current.name
|
50
|
-
current = current.parent
|
51
|
-
end while current != current.parent
|
52
|
-
|
53
|
-
"/#{path.reverse.join('/')}"
|
48
|
+
def to_s
|
49
|
+
@content
|
54
50
|
end
|
55
51
|
|
56
52
|
def inspect
|
data/lib/fffs/filesystem.rb
CHANGED
data/lib/fffs/node.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#--
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
3
|
+
#
|
4
|
+
# This file is part of fffs.
|
5
|
+
#
|
6
|
+
# fffs is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# fffs is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
17
|
+
# along with fffs. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
module FFFS
|
21
|
+
|
22
|
+
module Node
|
23
|
+
def path
|
24
|
+
path = []
|
25
|
+
current = self
|
26
|
+
|
27
|
+
begin
|
28
|
+
path << current.name
|
29
|
+
current = current.parent
|
30
|
+
end while current != current.parent
|
31
|
+
|
32
|
+
"/#{path.reverse.join('/')}/".sub(%r{/*/}, '/')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- meh.
|
@@ -29,6 +29,7 @@ extra_rdoc_files: []
|
|
29
29
|
files:
|
30
30
|
- lib/fffs.rb
|
31
31
|
- lib/fffs/file.rb
|
32
|
+
- lib/fffs/node.rb
|
32
33
|
- lib/fffs/link.rb
|
33
34
|
- lib/fffs/directory.rb
|
34
35
|
- lib/fffs/filesystem.rb
|