Sha256: 27334d52d6fa75d7e294104fb886d69dededcb2e65c14b20d87531f204377024
Contents?: true
Size: 1.1 KB
Versions: 13
Compression:
Stored size: 1.1 KB
Contents
require 'rexml/document' class StringsXmlManager def initialize(file_path) @file_path = file_path @xml_content = File.read(@file_path, encoding: 'UTF-8') @doc = REXML::Document.new(@xml_content) end def delete_app_name app_name_element = @doc.elements['resources/string[@name="app_name"]'] app_name_element.remove if app_name_element save_changes Solara.logger.debug("Removed app_name from #{@file_path} to avoid duplication with #{FilePath.artifacts_dir_name}/strings.xml.") end def update_string_value(string_name, new_value) string_element = @doc.elements["resources/string[@name=\"#{string_name}\"]"] if string_element string_element.text = new_value save_changes Solara.logger.debug("Updated string '#{string_name}' to '#{new_value}' in #{@file_path}.") else Solara.logger.warn("String '#{string_name}' not found in #{@file_path}. Update failed.") end end def get_value(string_name) @doc.elements["resources/string[@name=\"#{string_name}\"]"].text end private def save_changes File.write(@file_path, @doc.to_s) end end
Version data entries
13 entries across 13 versions & 1 rubygems