Class: Falcon::Deploy

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(appname, force = false) ⇒ Deploy

Returns a new instance of Deploy.



9
10
11
12
# File 'lib/falcon.rb', line 9

def initialize(appname, force=false)
  @appname = appname
  @force = force
end

Instance Attribute Details

#appnameObject (readonly)

Returns the value of attribute appname.



8
9
10
# File 'lib/falcon.rb', line 8

def appname
  @appname
end

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/falcon.rb', line 8

def env
  @env
end

#forceObject (readonly)

Returns the value of attribute force.



8
9
10
# File 'lib/falcon.rb', line 8

def force
  @force
end

Class Method Details

.helpObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/falcon.rb', line 14

def self.help
  %Q{
    USAGE: `falcon [appname] [command] [flags]`
    APPNAME: Your Heroku app name
    COMMANDS: 
    - `deploy` - deploy the code
    - `migrations` - deploy and run migrations
    - `rollback` - reverse the latest code deploy (does NOT reverse migrations)
    FLAGS
    - `-f`, `--force` - force rollback etc
  }
end

Instance Method Details

#deployObject



36
37
38
# File 'lib/falcon.rb', line 36

def deploy
  deployer.deploy
end

#deployerObject



56
57
58
# File 'lib/falcon.rb', line 56

def deployer
  @deployer ||= HerokuDeployer.new( appname )
end

#migrationsObject



40
41
42
# File 'lib/falcon.rb', line 40

def migrations
  deployer.migrations
end

#rollbackObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/falcon.rb', line 44

def rollback
  unless force
    puts rollback_warning
    
    answer = STDIN.gets.strip

    return (puts "Rollback cancelled.") unless %w( y yes ).include?( answer.downcase )
  end

  deployer.rollback
end

#rollback_warningObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/falcon.rb', line 60

def rollback_warning
  %Q{
    This command does NOT reverse migrations. 
    If you want to reverse a migration, please do so manually:
      `heroku run rake db:rollback`
    Then run this command again.

    Continue (without DB rollback)? Y/N
  }
end

#run(command) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/falcon.rb', line 27

def run(command)
  if respond_to? command
    send command
  else
    puts "The command '#{command}' is not valid.\n"
    puts self.class.help
  end
end