fffs 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fffs/file.rb +24 -4
- data/lib/fffs/link.rb +17 -5
- metadata +2 -2
data/lib/fffs/file.rb
CHANGED
@@ -45,10 +45,30 @@ class File
|
|
45
45
|
@parent << self
|
46
46
|
end
|
47
47
|
|
48
|
-
def save (
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def save (file)
|
49
|
+
if file.is_a?(String)
|
50
|
+
::File.open(file, 'wb') {|f|
|
51
|
+
f.write content
|
52
|
+
}
|
53
|
+
else
|
54
|
+
file.write content
|
55
|
+
file.flush
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute (*args)
|
60
|
+
require 'tempfile'
|
61
|
+
|
62
|
+
tmp = Tempfile.new('fffs')
|
63
|
+
tmp.chmod 0700
|
64
|
+
|
65
|
+
save(tmp)
|
66
|
+
|
67
|
+
tmp.close
|
68
|
+
|
69
|
+
Kernel.system(tmp.path, *args)
|
70
|
+
ensure
|
71
|
+
tmp.unlink
|
52
72
|
end
|
53
73
|
|
54
74
|
def to_s
|
data/lib/fffs/link.rb
CHANGED
@@ -29,17 +29,29 @@ class Link
|
|
29
29
|
@to = file
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
handle
|
32
|
+
def handle
|
33
|
+
return @handle if @handle
|
34
|
+
|
35
|
+
@handle = self.filesystem
|
34
36
|
|
35
37
|
@to.split('/').reject {|s| s.empty?}.each {|path|
|
36
|
-
handle = handle[path]
|
38
|
+
@handle = @handle[path]
|
37
39
|
|
38
|
-
break if
|
40
|
+
break if !@handle
|
39
41
|
}
|
40
42
|
|
43
|
+
return @handle
|
44
|
+
end
|
45
|
+
|
46
|
+
def content
|
47
|
+
if handle
|
48
|
+
handle.content
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def execute (*args)
|
41
53
|
if handle
|
42
|
-
handle.
|
54
|
+
handle.execute(*args)
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: fffs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- meh.
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-30 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: A virtual filesystem for embedded data.
|