Class: Bookbinder::Deploy::Pusher

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/deploy/pusher.rb

Instance Method Summary collapse

Constructor Details

#initialize(cf_cli, app_fetcher) ⇒ Pusher

Returns a new instance of Pusher.



4
5
6
7
# File 'lib/bookbinder/deploy/pusher.rb', line 4

def initialize(cf_cli, app_fetcher)
  @cf_cli = cf_cli
  @app_fetcher = app_fetcher
end

Instance Method Details

#push(app_dir) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bookbinder/deploy/pusher.rb', line 9

def push(app_dir)
  Dir.chdir(app_dir) do
    cf_cli.

    old_app = app_fetcher.fetch_current_app

    if old_app
      new_app = old_app.with_flipped_name
      cf_cli.start(new_app)
      cf_cli.push(new_app)
      cf_cli.map_routes(new_app)
      cf_cli.takedown_old_target_app(old_app)
    else
      new_app = cf_cli.new_app
      cf_cli.push(new_app)
      cf_cli.map_routes(new_app)
    end
  end
end