class DeployNanny::Base
Attributes
deploy_instructions[R]
environments[R]
github_account[R]
nannyrc[R]
options[R]
Public Class Methods
new(github_account:, nannyrc:, environments:, deploy_instructions:, options: {})
click to toggle source
# File lib/deploy_nanny/base.rb, line 6 def initialize(github_account:, nannyrc:, environments:, deploy_instructions:, options: {}) @github_account = github_account @nannyrc = nannyrc @environments = environments @deploy_instructions = deploy_instructions @options = options @rows = [] @updates = {} end
Public Instance Methods
babysit()
click to toggle source
# File lib/deploy_nanny/base.rb, line 21 def babysit display_github_shas! display_deployed_shas! deploy_to_outdated_envs! unless options.no_deploy clear_memoized_values! end
Private Instance Methods
application_branches()
click to toggle source
# File lib/deploy_nanny/base.rb, line 84 def application_branches deploy_instructions.fetch("apps") end
apps()
click to toggle source
# File lib/deploy_nanny/base.rb, line 80 def apps @apps ||= deploy_instructions.fetch("apps").keys end
clear_memoized_values!()
click to toggle source
# File lib/deploy_nanny/base.rb, line 36 def clear_memoized_values! @updates = {} @rows = [] @github_table = nil end
deploy_to_outdated_envs!()
click to toggle source
# File lib/deploy_nanny/base.rb, line 100 def deploy_to_outdated_envs! @updates.each do |env, apps| apps.each do |app| puts "Deploying #{app}: #{env}\n".yellow deployer = Deployer.new( env: env, app: app, nannyrc: nannyrc, environments: environments, deploy_instructions: deploy_instructions ) puts deployer.command deployer.deploy end end end
display_deployed_shas!()
click to toggle source
# File lib/deploy_nanny/base.rb, line 42 def display_deployed_shas! puts "\n" SpinningCursor.run do banner "Pulling SHA's from servers".yellow type :spinner action { fetch_and_display_shas! } message "\n" end end
display_github_shas!()
click to toggle source
# File lib/deploy_nanny/base.rb, line 95 def display_github_shas! github_table.fetch_all github_table.render end
envs()
click to toggle source
# File lib/deploy_nanny/base.rb, line 76 def envs @envs ||= deploy_instructions.fetch("envs") end
fetch_and_display_shas!()
click to toggle source
# File lib/deploy_nanny/base.rb, line 52 def fetch_and_display_shas! apps.each do |app| envs.each do |env| host = environments.fetch(env).fetch("host") ssh_host = "#{app}@#{host}" remote_sha = `ssh #{ssh_host} cat app/REVISION`.strip if github_table.match(app, remote_sha) @rows << [env, app.yellow, remote_sha.green] else @rows << [env, app.yellow, remote_sha.red] str = @updates[env].to_a @updates[env] = str << app end end end puts Terminal::Table.new( :title => "Deployments", :headings => ['server', 'app', 'deployed'], :rows => @rows ) end
github_table()
click to toggle source
# File lib/deploy_nanny/base.rb, line 88 def github_table @github_table ||= GithubTable.new( github_account: github_account, application_branches: application_branches ) end