Class: Homesteading::Routes

Inherits:
Command
  • Object
show all
Defined in:
lib/homesteading/commands/routes.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
# File 'lib/homesteading/commands/routes.rb', line 7

def default
  puts

  routes      = get_routes
  longest_app = routes.map{ |app, host| app }.sort_by { |a| a.length }.last.length

  routes.sort.each do |app, remote_host|
    app = "/" if app.empty?
    puts "* #{app.ljust(longest_app)}  :  #{remote_host}"
  end

  puts
end

#pushObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/homesteading/commands/routes.rb', line 21

def push
  puts

  env_var = get_routes.map do |app, remote_host|
    [app.empty? ? "feed" : app, remote_host].join("@@@")
  end.join(",")

  env_var = get_routes.map{ |app, host| [app.empty? ? "feed" : app, host].join("@@@") }.join(",")

  app_dir = "#{Dir.pwd}/homesteading-router-rack/"
  git_url = Git.open(app_dir).remote("heroku").url

  if git_url.nil?
    puts "* No known router app deployed to Heroku"
    exit 1
  else
    heroku_app = git_url.split(":").last.split(".").first

    puts "* Setting remote routes env variable..."
    puts
    system "heroku config:set HOMESTEADING_ROUTES=#{env_var} --app #{heroku_app}"
    puts
    puts "* ...done"
  end

  puts
end