Sha256: 64ac3b1af9334d32e69a912588475f169b193daf4366cd405ba4b8be8ea497f2
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
require "erb" require 'ostruct' module InstaSwag class StaticFiles attr_accessor :settings def self.create(settings) instance = new(settings) instance.to_app end def index_path File.expand_path("../../../public/docs/index.html", __FILE__) end def to_app index = eval_and_read(index_path) ->(env) do run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, [index]] } end end def initialize(settings) @settings = settings end def eval_and_read(path) namespace = OpenStruct.new(url: complete_path) template = File.read(index_path) ERB.new(template).result(namespace.instance_eval { binding }) end def complete_path settings.prefix_path + "/documentation" + "/resources" + ".json" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
insta_swag-0.1.1 | lib/insta_swag/static_files.rb |