Class: Homesteading::Open

Inherits:
Command
  • Object
show all
Defined in:
lib/homesteading/commands/open.rb

Constant Summary

Constants inherited from Command

Command::COMMANDS

Instance Method Summary collapse

Methods inherited from Command

create, register

Instance Method Details

#defaultObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/homesteading/commands/open.rb', line 7

def default
  puts
  puts "* Opening deployed site in browser..."

  app_dir = Dir[Dir.pwd + "/homesteading-router*"].first

  if File.exist?(app_dir + "/.git")
    git_url = Git.open(app_dir).remote("heroku").url
    unless git_url.nil?
      heroku_app = git_url.split(":").last.split(".").first
      url        = "http://#{heroku_app}.herokuapp.com"
    end

    system "open #{url}"
  end

  puts
end