Sha256: e8f2f495191a27f5d770dc01a1f17faa5e5101b33e62ebd031dc3fb659d4dd73
Contents?: true
Size: 996 Bytes
Versions: 3
Compression:
Stored size: 996 Bytes
Contents
require 'erb' require 'json' require_relative 'helpers' parsed_data = JSON.parse(File.read('./scenario.cache')) Dir.chdir("./scenarios") subdir_list = Dir["*"].reject { |o| not File.directory?(o) } api_key = parsed_data["api_key"] # boiler plate configuration code used in all scenarios boiler_plate = "require 'balanced'\nBalanced.configure('#{api_key}')\n" params_to_hash = @helpers[:params_to_hash] params_to_hash_for_args = @helpers[:params_to_hash_for_args] subdir_list.each do |scenario| begin template = File.read("./#{scenario}/request.rb") # generate new erb template file from each request.rb file erb = ERB.new(template) request = parsed_data[scenario]['request'] payload = request['payload'] # render erb file passing in all local variables executable = erb.result(binding) File.open("./#{scenario}/executable.rb", "w") do |f| f.write(executable) end rescue Exception => e puts "Error rendering #{scenario}'s template" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
balanced-0.7.5 | scenarios/render.rb |
balanced-0.7.4 | scenarios/render.rb |
balanced-0.7.2 | scenarios/render.rb |