31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/deplate/nukumi2.rb', line 31
def self.parse(io)
entry = Nukumi2::Entry.new
metadata = []
while line = io.gets
break if line.chomp.empty?
metadata << line
end
meta = DeplateString.new(metadata.join)
meta.to_html
date = meta.deplate_converter.get_clip('date')
entry.time = Time.parse(date.elt) if date
subject = meta.deplate_converter.get_clip('title')
entry.title = subject.elt if subject
meta.deplate_variables.each do |field, value|
if value
case field
when 'keywords'
entry.categories.concat Deplate::Core.split_list(value, ';', ',')
when 'encoding'
else
if entry.respond_to? field + "="
entry.send field + "=", value
else
entry.fields[field] = value
end
end
end
end
entry.content = io.read
entry
end
|