Class: HerokuWhiz

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

Instance Method Summary collapse

Constructor Details

#initialize(dir: '.', template: 'rack', appname: File.basename(Dir.pwd), verbose: true, debug: false) ⇒ HerokuWhiz

Returns a new instance of HerokuWhiz.



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/heroku_whiz.rb', line 302

def initialize(dir: '.', template: 'rack', appname: File.basename(Dir.pwd),
      verbose: true, debug: false)

  @dir, @template, @appname, @verbose = dir, template, appname, verbose

  @app_path = File.join(@dir, @appname)
  FileUtils.chdir @app_path if File.exists? @app_path

  case @template.to_sym
  when :rack
    @tapp = WhizBase.new @app_path, verbose: verbose, debug: debug
  when :sinatra
    @tapp = SinatraWhiz.new @app_path, verbose: verbose, debug: debug
  end

end

Instance Method Details

#app_openObject



330
331
332
# File 'lib/heroku_whiz.rb', line 330

def app_open()
  `heroku open`
end

#app_urlObject



319
320
321
322
323
324
325
326
327
328
# File 'lib/heroku_whiz.rb', line 319

def app_url()

  s = "https://#{heroku_app()}.herokuapp.com/"

  Clipboard.copy s
  puts 'app URL copied to clipboard.'

  return s

end

#create(add: nil) ⇒ Object



334
335
336
337
338
339
340
341
342
343
344
# File 'lib/heroku_whiz.rb', line 334

def create(add: nil)

  return unless @tapp

  @tapp.create add: add

  # build
  `bundle install`
  sleep 1

end

#deployObject



367
368
369
370
371
372
373
# File 'lib/heroku_whiz.rb', line 367

def deploy()

  return unless @tapp

  @tapp.deploy

end

#goto(target) ⇒ Object



346
347
348
349
350
351
352
353
354
355
# File 'lib/heroku_whiz.rb', line 346

def goto(target)

  case target.to_sym
  when :apps
    Launchy.open("https://dashboard.heroku.com/apps")
  when :docs
    Launchy.open('https://devcenter.heroku.com/articles/rack')
  end

end

#local_runObject



375
376
377
378
379
380
381
# File 'lib/heroku_whiz.rb', line 375

def local_run()

  return unless @tapp

  @tapp.local_run

end

#local_testrunObject



383
384
385
386
387
388
389
# File 'lib/heroku_whiz.rb', line 383

def local_testrun()

  return unless @tapp

  @tapp.local_testrun()

end

#wipe_clean(setup = :local) ⇒ Object

currently only removes a file directory if there are no user created files



359
360
361
362
363
364
365
# File 'lib/heroku_whiz.rb', line 359

def wipe_clean(setup=:local)

  return unless @tapp

  @tapp.wipe_clean setup

end