class Vueport::NodeClient

Attributes

content[RW]
path[RW]

Public Class Methods

new(content, path: '/') click to toggle source
# File lib/vueport/node_client.rb, line 7
def initialize(content, path: '/')
  self.content = content
  self.path = path
end

Public Instance Methods

run!() click to toggle source
# File lib/vueport/node_client.rb, line 12
def run!
  render.force_encoding('UTF-8').encode!.html_safe
end

Private Instance Methods

http() click to toggle source
# File lib/vueport/node_client.rb, line 33
def http
  @http ||= Net::HTTP.new Vueport.config[:server_host], Vueport.config[:server_port]
end
render() click to toggle source
# File lib/vueport/node_client.rb, line 18
def render
  case response
  when Net::HTTPSuccess
    response.body
  else
    raise(RenderError.new, response.body)
  end
end
response() click to toggle source
# File lib/vueport/node_client.rb, line 27
def response
  @response ||= http
                .tap { |http| http.read_timeout = timeout }
                .post path, content, 'Content-Type' => 'text/plain'
end
timeout() click to toggle source
# File lib/vueport/node_client.rb, line 37
def timeout
  Vueport.config[:ssr_timeout] || 3
end