fffs 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ class File
26
26
 
27
27
  attr_accessor :filesystem, :parent
28
28
 
29
- attr_accessor :content
29
+ attr_accessor :content, :mime
30
30
  attr_reader :name, :mode
31
31
 
32
32
  def initialize (name, content='', parent=nil, filesystem=nil)
@@ -35,6 +35,7 @@ class File
35
35
 
36
36
  @name = name
37
37
  @mode = 0644
38
+ @mime = 'text/plain'
38
39
 
39
40
  @content = content.clone
40
41
  @content.force_encoding 'ASCII-8BIT'
@@ -59,13 +59,21 @@ class FileSystem < Directory
59
59
  data.shift
60
60
 
61
61
  data.each_slice(2) {|(name, content)|
62
- if name.include?(' -> ')
63
- t, name, link = name.match(/^(.*?) -> (.*?)$/)
62
+ if matches = name.match(/^(.+?) -> (.+?)$/)
63
+ whole, name, link = matches.to_a
64
+ elsif matches = name.match(/(.+?)\s+\((.*?)\)$/)
65
+ whole, name, mime = matches.to_a
64
66
  end
65
67
 
66
68
  path = ::File.dirname(name)
67
69
  name = ::File.basename(name)
68
70
 
71
+ if mime
72
+ require 'base64'
73
+
74
+ content = Base64.decode64(content)
75
+ end
76
+
69
77
  if path == '.'
70
78
  parent = self
71
79
 
@@ -73,6 +81,10 @@ class FileSystem < Directory
73
81
  self << Link.new(name, link)
74
82
  else
75
83
  self << File.new(name, content)
84
+
85
+ if mime
86
+ self[name].mime = mime
87
+ end
76
88
  end
77
89
  else
78
90
  into = self
@@ -85,6 +97,10 @@ class FileSystem < Directory
85
97
  into << Link.new(name, link)
86
98
  else
87
99
  into << File.new(name, content)
100
+
101
+ if mime
102
+ into[name].mime = mime
103
+ end
88
104
  end
89
105
  end
90
106
  }
@@ -49,7 +49,7 @@ class Link
49
49
  return handle
50
50
  end
51
51
 
52
- [:content, :chmod, :execute, :mode].each {|meth|
52
+ [:content, :chmod, :execute, :mode, :mime].each {|meth|
53
53
  define_method meth do |*args|
54
54
  if tmp = handle
55
55
  tmp.send meth, *args
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - meh.
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-08 00:00:00 +02:00
17
+ date: 2011-05-10 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20