Class: Devcenter::Previewer::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/devcenter/previewer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug, md_path, host, port) ⇒ Runner

Returns a new instance of Runner.



16
17
18
19
20
21
22
23
24
# File 'lib/devcenter/previewer.rb', line 16

def initialize(slug, md_path, host, port)
  @slug = slug
  @md_path = md_path
  @host = host
  @port = port
  @url = "http://#{@host}:#{@port}/#{@slug}"
  @listener = init_listener
  @server = init_server
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



14
15
16
# File 'lib/devcenter/previewer.rb', line 14

def host
  @host
end

#md_pathObject (readonly)

Returns the value of attribute md_path.



14
15
16
# File 'lib/devcenter/previewer.rb', line 14

def md_path
  @md_path
end

#portObject (readonly)

Returns the value of attribute port.



14
15
16
# File 'lib/devcenter/previewer.rb', line 14

def port
  @port
end

#slugObject (readonly)

Returns the value of attribute slug.



14
15
16
# File 'lib/devcenter/previewer.rb', line 14

def slug
  @slug
end

#urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/devcenter/previewer.rb', line 14

def url
  @url
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/devcenter/previewer.rb', line 26

def run
  start
  @running = true
  [:INT, :TERM].each do |signal|
    trap(signal) do
      stop
      exit
    end
  end
  sleep 1 while running?
end