7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/worlddb/readers/lang.rb', line 7
def read
reader = HashReader.from_string( @text )
reader.each do |key, value|
logger.debug "adding lang >>#{key}<< >>#{value}<<..."
lang_key = key.strip
lang_title = value.strip
lang_attribs = {}
lang = Lang.find_by_key( lang_key )
if lang.present?
logger.debug "update lang #{lang.id}-#{lang.key}:"
else
logger.debug "create lang:"
lang = Lang.new
lang_attribs[ :key ] = lang_key
end
lang_attribs[ :title ] = lang_title
logger.debug lang_attribs.to_json
lang.update_attributes!( lang_attribs )
end
end
|