Class: MobileSecrets::SourceRenderer
- Inherits:
-
Object
- Object
- MobileSecrets::SourceRenderer
- Defined in:
- lib/src/source_renderer.rb
Instance Method Summary collapse
-
#initialize(source_type) ⇒ SourceRenderer
constructor
A new instance of SourceRenderer.
- #render_empty_template(output_file_path) ⇒ Object
- #render_template(secrets_bytes, file_names_bytes, output_file_path, algorithm = "XOR") ⇒ Object
Constructor Details
#initialize(source_type) ⇒ SourceRenderer
Returns a new instance of SourceRenderer.
7 8 9 |
# File 'lib/src/source_renderer.rb', line 7 def initialize source_type @source_type = source_type.downcase end |
Instance Method Details
#render_empty_template(output_file_path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/src/source_renderer.rb', line 25 def render_empty_template output_file_path template = File.read("#{__dir__}/../resources/SecretsSwiftEmpty.erb") case @source_type when "swift" File.open(output_file_path, "w") do |file| file.puts template end end end |
#render_template(secrets_bytes, file_names_bytes, output_file_path, algorithm = "XOR") ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/src/source_renderer.rb', line 11 def render_template secrets_bytes, file_names_bytes, output_file_path, algorithm = "XOR" template = ERB.new(File.read("#{__dir__}/../resources/SecretsSwift.erb")) case @source_type when "swift" File.open(output_file_path, "w") do |file| file.puts template.result_with_hash(secrets_array: secrets_bytes, file_names_array: file_names_bytes, should_decrypt_files: file_names_bytes.length > 0, algorithm: algorithm) end end end |