class Anyway::EJSONParser
Attributes
Public Class Methods
Source
# File lib/anyway/ejson_parser.rb, line 12 def initialize(bin_path = "ejson") @bin_path = bin_path end
Public Instance Methods
Source
# File lib/anyway/ejson_parser.rb, line 16 def call(file_path) return unless File.exist?(file_path) raw_content = nil stdout, stderr, status = Open3.capture3("#{bin_path} decrypt #{file_path}") if status.success? raw_content = JSON.parse(stdout.chomp) else Kernel.warn "Failed to decrypt #{file_path}: #{stderr}" end return unless raw_content raw_content.deep_transform_keys do |key| if key[0] == "_" key[1..] else key end end end