Class: Tane::Commands::Open

Inherits:
Base
  • Object
show all
Defined in:
lib/tane/commands/open.rb

Class Method Summary collapse

Methods inherited from Base

fire

Methods included from Helpers

included

Class Method Details

.help_textObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tane/commands/open.rb', line 20

def help_text
  <<-EOL
Usage:

tane open

Waits until there's a webserver running at port 3000 and then opens the browser to it.

tane open
EOL
end

.process(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tane/commands/open.rb', line 5

def process(args)
  timeout = opts.timeout || 120

  started = try_for(:seconds => timeout) do
    begin
      RestClient.get("http://localhost:3000/")
      true
    rescue => e
      false
    end
  end

  Launchy.open("http://localhost:3000/") if started
end