lib/chamber/file.rb in chamber-2.2.1 vs lib/chamber/file.rb in chamber-2.3.0

- old
+ new

@@ -69,12 +69,23 @@ decryption_key: decryption_key, encryption_key: encryption_key) end def secure - secure_settings = to_settings.secure + insecure_settings = to_settings.insecure.to_flattened_name_hash + secure_settings = to_settings.insecure.secure.to_flattened_name_hash + file_contents = self.read - ::File.open(self, 'w') { |file| file.write YAML.dump(secure_settings.to_hash) } + insecure_settings.each_pair do |name_pieces, value| + secure_value = secure_settings[name_pieces] + + file_contents. + sub!( + /^(\s*)_secure_#{name_pieces.last}(\s*):(\s*)['"]?#{value}['"]?$/, + "\\1_secure_#{name_pieces.last}\\2:\\3#{secure_value}") + end + + self.write(file_contents) end protected attr_accessor :namespaces,