Sha256: ff9566b4faaa1927059cdf6163175c6343be815eb3987880641a36b0d41fef11
Contents?: true
Size: 998 Bytes
Versions: 5
Compression:
Stored size: 998 Bytes
Contents
require "erb" require "raml" require "rambo/raml_models" require "rambo/rspec/examples" module Rambo module RSpec class HelperFile attr_reader :options def initialize(template_path:, file_path:, raml: nil, options: nil) @template_path = template_path @file_path = file_path @options = options || { rails: true } @raml = raml ? Rambo::RamlModels::Api.new(raml) : nil end def generate write_to_file(render) unless file_already_exists? end def render b = binding ERB.new(template, 0, "-", "@result").result(raml.instance_eval { b }) @result end private attr_reader :template_path, :file_path, :raml def file_already_exists? File.exist?(file_path) end def write_to_file(template) File.write(file_path, template) end def template @template ||= File.read(template_path) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems