fffs 0.0.5 → 0.0.6

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.
@@ -102,6 +102,27 @@ class Directory < Hash
102
102
  }
103
103
  end
104
104
 
105
+ def load (path)
106
+ require 'find'
107
+
108
+ Find.find(path) {|f|
109
+ next unless ::File.file?(f) || ::File.symlink?(f)
110
+
111
+ tmp = ::File.dirname(f[path.length + 1, f.length]) rescue next
112
+ into = self
113
+
114
+ tmp.split('/').each {|dir|
115
+ into = into[dir] || (into << Directory.new(dir))
116
+ }
117
+
118
+ if ::File.file?(f)
119
+ into << File.new(::File.basename(f), ::File.read(f))
120
+ elsif ::File.symlink?(f)
121
+ into << Link.new(::File.basename(f), ::File.readlink(f))
122
+ end
123
+ }
124
+ end
125
+
105
126
  def inspect
106
127
  output = "#{self.path}\n"
107
128
 
@@ -25,7 +25,19 @@ module FFFS
25
25
 
26
26
  class FileSystem < Directory
27
27
  def self.parse (text)
28
- self.new.parse(text)
28
+ fs = self.new
29
+
30
+ fs.parse(text)
31
+
32
+ return fs
33
+ end
34
+
35
+ def self.load (path)
36
+ fs = self.new
37
+
38
+ fs.load(path)
39
+
40
+ return fs
29
41
  end
30
42
 
31
43
  def initialize
@@ -35,6 +47,10 @@ class FileSystem < Directory
35
47
  self.filesystem = self
36
48
  end
37
49
 
50
+ def path (path=nil)
51
+ '/'
52
+ end
53
+
38
54
  def parse (text)
39
55
  separator = Regexp.escape(text.match(/^(.+)$/)[1])
40
56
  text = text.sub(/^.*$/, '').gsub(/\r/, '')
@@ -72,12 +88,6 @@ class FileSystem < Directory
72
88
  end
73
89
  end
74
90
  }
75
-
76
- self
77
- end
78
-
79
- def path (path=nil)
80
- '/'
81
91
  end
82
92
  end
83
93
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fffs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 5
9
- version: 0.0.5
4
+ prerelease:
5
+ version: 0.0.6
10
6
  platform: ruby
11
7
  authors:
12
8
  - meh.
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-04-15 00:00:00 +02:00
18
- default_executable:
13
+ date: 2011-04-24 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: A virtual filesystem for embedded data.
@@ -33,7 +28,6 @@ files:
33
28
  - lib/fffs/link.rb
34
29
  - lib/fffs/directory.rb
35
30
  - lib/fffs/filesystem.rb
36
- has_rdoc: true
37
31
  homepage: http://github.com/meh/fffs
38
32
  licenses: []
39
33
 
@@ -47,21 +41,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
41
  requirements:
48
42
  - - ">="
49
43
  - !ruby/object:Gem::Version
50
- segments:
51
- - 0
52
44
  version: "0"
53
45
  required_rubygems_version: !ruby/object:Gem::Requirement
54
46
  none: false
55
47
  requirements:
56
48
  - - ">="
57
49
  - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
50
  version: "0"
61
51
  requirements: []
62
52
 
63
53
  rubyforge_project:
64
- rubygems_version: 1.3.7
54
+ rubygems_version: 1.7.2
65
55
  signing_key:
66
56
  specification_version: 3
67
57
  summary: A virtual filesystem.