Class: HunkReviewChanges::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/hunk_review_changes/server.rb

Overview

Boots the review UI for a bundle: configures the app, picks a free localhost port, opens the browser, arms the watchdog, and runs Puma. Blocks until the user clicks Done (which writes export.md and exits) or the watchdog fires.

Instance Method Summary collapse

Constructor Details

#initialize(bundle, port: nil, open: true) ⇒ Server

Returns a new instance of Server.



15
16
17
18
19
20
# File 'lib/hunk_review_changes/server.rb', line 15

def initialize(bundle, port: nil, open: true)
  @bundle = bundle
  @port = port || free_port
  @open = open
  @lifecycle = Lifecycle.new
end

Instance Method Details

#export_pathObject



23
# File 'lib/hunk_review_changes/server.rb', line 23

def export_path = File.join(@bundle.dir, "export.md")

#runObject



25
26
27
28
29
30
31
# File 'lib/hunk_review_changes/server.rb', line 25

def run
  configure_app
  open_browser
  arm_watchdog
  announce
  App.run!(port: @port, server: "puma")
end

#urlObject



22
# File 'lib/hunk_review_changes/server.rb', line 22

def url = "http://127.0.0.1:#{@port}/"