Class: Kybus::CLI::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/kybus/cli/bot/deployer.rb

Constant Summary collapse

DEFAULT_CONFIGS =
{
  'repo_path' => '.',
  'output_path' => './.kybusbotcode.zip'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Deployer

Returns a new instance of Deployer.



27
28
29
30
31
32
# File 'lib/kybus/cli/bot/deployer.rb', line 27

def initialize(options)
  @params = options
  load_kybusdeploy_file!
  @telegram = ::Kybus::CLI::BotDeployerTelegramConfigurator.new(@url, config_with_options)
  @lambda = ::Kybus::CLI::AWSBotDeployer.new(config_with_options)
end

Instance Method Details

#compress_repo!Object



48
49
50
51
# File 'lib/kybus/cli/bot/deployer.rb', line 48

def compress_repo!
  code = ::Kybus::AWS::CodePackager.new(config_with_options)
  code.create_or_update!
end

#config_with_optionsObject



44
45
46
# File 'lib/kybus/cli/bot/deployer.rb', line 44

def config_with_options
  @config_with_options ||= DEFAULT_CONFIGS.merge(@config.merge(@params))
end

#deploy_lambda!Object



53
54
55
56
# File 'lib/kybus/cli/bot/deployer.rb', line 53

def deploy_lambda!
  @lambda.create_or_update!
  @telegram.url = @lambda.url
end

#destroyObject



64
65
66
67
# File 'lib/kybus/cli/bot/deployer.rb', line 64

def destroy
  @lambda.destroy!
  @telegram.destroy!
end

#load_kybusdeploy_file!Object



40
41
42
# File 'lib/kybus/cli/bot/deployer.rb', line 40

def load_kybusdeploy_file!
  @config = YAML.load_file('./kybusbot.yaml')
end

#runObject



58
59
60
61
62
# File 'lib/kybus/cli/bot/deployer.rb', line 58

def run
  compress_repo!
  deploy_lambda!
  @telegram.create_or_update!
end

#run_migrations!Object



34
35
36
37
38
# File 'lib/kybus/cli/bot/deployer.rb', line 34

def run_migrations!
  Rake::Task.clear
  load 'Rakefile'
  Rake::Task['db:migrate'].invoke
end