Class: Locomotive::Mounter::Writer::FileSystem::TranslationsWriter

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/mounter/writer/file_system/translations_writer.rb

Instance Attribute Summary

Attributes inherited from Base

#mounting_point, #runner

Instance Method Summary collapse

Methods inherited from Base

#create_folder, #initialize, #open_file, #target_path

Constructor Details

This class inherits a constructor from Locomotive::Mounter::Writer::FileSystem::Base

Instance Method Details

#prepareObject



8
9
10
11
# File 'lib/locomotive/mounter/writer/file_system/translations_writer.rb', line 8

def prepare
  super
  self.create_folder 'config'
end

#writeObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/locomotive/mounter/writer/file_system/translations_writer.rb', line 13

def write
  content = self.mounting_point.translations.each_with_object({}) do |(key,translation), hash|
    hash[key] = translation.values
  end

  content = content.empty? ? '' : content.to_yaml

  self.open_file('config/translations.yml') do |file|
    file.write content
  end
end