fffs 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,13 +66,38 @@ class Directory < Hash
66
66
  self[id.to_s]
67
67
  end
68
68
 
69
- alias __set []=
69
+ def [] (path)
70
+ if path.include?('/')
71
+ result = path.start_with?('/') ? filesystem : self
72
+ last = nil
73
+
74
+ path.split(%r{/+}).each {|piece|
75
+ next if piece.empty? || piece == '.'
76
+
77
+ if !result.is_a?(Directory)
78
+ raise RuntimeError.new "#{last} isn't a directory"
79
+ end
80
+
81
+ if piece == '..'
82
+ result = result.parent
83
+ else
84
+ result = result[piece]
85
+ end
86
+
87
+ last = piece
88
+ }
89
+
90
+ result
91
+ else
92
+ super(path)
93
+ end
94
+ end
70
95
 
71
96
  def []= (name, value)
72
97
  value.parent = self
73
98
  value.filesystem = self.filesystem
74
99
 
75
- __set(name, value)
100
+ super(name, value)
76
101
  end
77
102
 
78
103
  def push (file)
@@ -74,33 +74,19 @@ class FileSystem < Directory
74
74
  content = Base64.decode64(content)
75
75
  end
76
76
 
77
- if path == '.'
78
- parent = self
77
+ into = self
79
78
 
80
- if link
81
- self << Link.new(name, link)
82
- else
83
- self << File.new(name, content)
79
+ path.split('/').each {|dir|
80
+ into = into[dir] || (into << Directory.new(dir))
81
+ }
84
82
 
85
- if mime
86
- self[name].mime = mime
87
- end
88
- end
83
+ if link
84
+ into << Link.new(name, link)
89
85
  else
90
- into = self
91
-
92
- path.split('/').each {|dir|
93
- into = into[dir] || (into << Directory.new(dir))
94
- }
95
-
96
- if link
97
- into << Link.new(name, link)
98
- else
99
- into << File.new(name, content)
86
+ into << File.new(name, content)
100
87
 
101
- if mime
102
- into[name].mime = mime
103
- end
88
+ if mime
89
+ into[name].mime = mime
104
90
  end
105
91
  end
106
92
  }
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
- - 11
9
- version: 0.0.11
4
+ prerelease:
5
+ version: 0.0.12
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-05-10 00:00:00 +02:00
18
- default_executable:
13
+ date: 2011-05-29 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.8.4
65
55
  signing_key:
66
56
  specification_version: 3
67
57
  summary: A virtual filesystem.