output_resource

in asf-site-src/ruby27_fix_uri.rb [77:103]


  def output_resource(resource) 
    ::Middleman::Util.instrument 'builder.output.resource', path: File.basename(resource.destination_path) do 
      output_file = @build_dir + resource.destination_path.gsub('%20', ' ')

      begin
        if resource.binary?
          export_file!(output_file, resource.file_descriptor[:full_path])
        else
          response = @rack.get(::URI.encode_www_form_component(resource.request_path))

          
          if response.status == 200
            export_file!(output_file, binary_encode(response.body))
          else
            trigger(:error, output_file, response.body)
            return false
          end
        end
      rescue StandardError => e
        trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
        return false
      end

      output_file
    end
  end