Class: AdLocalize::Interactors::BaseGenerateFiles
- Inherits:
-
Object
- Object
- AdLocalize::Interactors::BaseGenerateFiles
- Defined in:
- lib/ad_localize/interactors/base_generate_files.rb
Direct Known Subclasses
GenerateInfoPlist, GenerateJSON, GenerateLocalizableStrings, GenerateLocalizableStringsDict, GenerateProperties, GenerateStrings, GenerateYAML
Instance Method Summary collapse
- #call(wording:, export_request:) ⇒ Object
-
#initialize(serializer:) ⇒ BaseGenerateFiles
constructor
A new instance of BaseGenerateFiles.
Constructor Details
#initialize(serializer:) ⇒ BaseGenerateFiles
Returns a new instance of BaseGenerateFiles.
5 6 7 8 9 10 |
# File 'lib/ad_localize/interactors/base_generate_files.rb', line 5 def initialize(serializer:) @serializer = serializer raise MissingArgument.new('Missing Serializer') unless serializer @file_system_repository = Repositories::FileSystemRepository.new end |
Instance Method Details
#call(wording:, export_request:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ad_localize/interactors/base_generate_files.rb', line 12 def call(wording:, export_request:) @serializer.configure(export_request: export_request) if @serializer.respond_to?(:configure) wording.each do |locale, locale_wording| next unless has_wording?(locale_wording: locale_wording) path = output_path(locale_wording: locale_wording, export_request: export_request) filename = path.basename LOGGER.debug("[#{locale}] Generating #{filename}") @file_system_repository.create_directory(path: path.dirname) content = @serializer.render(locale_wording: locale_wording) @file_system_repository.write(content: content, path: path) LOGGER.debug("[#{locale}] #{filename} done !") end end |