Class: WorldDb::LangReader
- Inherits:
-
BaseReader
- Object
- BaseReader
- WorldDb::LangReader
- Defined in:
- lib/worlddb/readers/lang.rb
Instance Attribute Summary
Attributes inherited from BaseReader
Instance Method Summary collapse
Methods inherited from BaseReader
#initialize, #skip_tags?, #strict?
Constructor Details
This class inherits a constructor from WorldDb::BaseReader
Instance Method Details
#read(name) ⇒ Object
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( name ) reader = HashReaderV2.new( name, include_path ) reader.each do |key, value| ### fix: ## move to Lang.read() for (re)use logger.debug "adding lang >>#{key}<< >>#{value}<<..." lang_key = key.strip lang_title = value.strip lang_attribs = {} ## check if it exists 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 # each key,value end |