hr_deploy 0.0.2 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class DisablePingerTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Disabling New Relic availability pinger...'
9
+
10
+ execute_system_command("curl #{target.new_relic_disable_pinger_url}")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('New Relic availability pinger disabled?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = 'Could not disable New Relic availability pinger'
22
+ end
23
+ end
24
+
25
+ def reversal_instruction
26
+ "Availability pinging is disabled\nTo enable: curl #{target.new_relic_enable_pinger_url}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class EnableMaintenanceTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Enabling maintenance mode...'
9
+
10
+ execute_system_command("heroku maintenance:on --remote #{target.name}")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('Maintenance mode enabled?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = 'Could not enable maintenance mode'
22
+ end
23
+ end
24
+
25
+ def reversal_instruction
26
+ "Maintenance mode is enabled\nTo disable: heroku maintenance:off --remote #{target.name}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class EnablePingerTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Enabling New Relic availability pinger...'
9
+
10
+ execute_system_command("curl #{target.new_relic_enable_pinger_url}")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('New Relic availability pinger enabled?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = 'Could not enable New Relic availability pinger'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class MigrateDBTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Migrating database...'
9
+
10
+ execute_system_command("heroku run rake db:migrate --remote #{target.name}")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('Database migrated?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+
22
+ error = 'Could not migrate database'
23
+ if target.backup_db?
24
+ error += "\nTo list database backups: heroku pgbackups --remote #{target.name}\n" +
25
+ 'To restore from backup if needed: ' +
26
+ "heroku pgbackups:restore [database name] [version] --remote #{target.name}"
27
+ end
28
+
29
+ self.error = error
30
+ end
31
+ end
32
+
33
+ def reversal_instruction
34
+ if target.backup_db?
35
+ "Database was migrated\n" +
36
+ 'To list database backups: ' +
37
+ "heroku pgbackups --remote #{target.name}\n" +
38
+ 'To restore from backup if needed: ' +
39
+ "heroku pgbackups:restore [database name] [version] --remote #{target.name}"
40
+ else
41
+ nil
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class PrecompileAssetsTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Precompiling and syncing new assets...'
9
+
10
+ execute_system_command('rake assets:precompile')
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('New assets precompiled and synced?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = 'Could not precompile and sync new assets'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class PushCodeTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Pushing new code...'
9
+
10
+ execute_system_command("git push #{target.name} master")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('New code pushed?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = 'Could not push new code'
22
+ end
23
+
24
+ def reversal_instruction
25
+ "Code was pushed\n" +
26
+ 'To list app releases: ' +
27
+ "heroku releases --remote #{target.name}\n" +
28
+ 'To rollback if needed: ' +
29
+ "heroku rollback [version] --remote #{target.name}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ require 'hr_deploy/tasks/task'
2
+
3
+ module HR_Deploy
4
+
5
+ class RestartTask < HR_Deploy::Task
6
+
7
+ def run
8
+ print_stage 'Restarting instance...'
9
+
10
+ execute_system_command("heroku restart --remote #{target.name}")
11
+
12
+ if dry_run? || !confirm?
13
+ self.success = true
14
+ return
15
+ end
16
+
17
+ if confirm_successful?('Instance restarted?')
18
+ self.success = true
19
+ else
20
+ self.success = false
21
+ self.error = "Could not restart instance\n" +
22
+ "To restart manually: heroku restart --remote #{target.name}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,81 @@
1
+ require 'hr_deploy/deployer'
2
+ require 'hr_deploy/color.rb'
3
+
4
+ module HR_Deploy
5
+
6
+ class Task
7
+
8
+ attr_reader :error
9
+
10
+ def initialize(args = {})
11
+ @target = args.fetch(:target, nil)
12
+ @confirm = args.fetch(:confirm, false)
13
+ @dry_run = args.fetch(:dry_run, false)
14
+ @success = nil
15
+ @error = nil
16
+ end
17
+
18
+ def successful?
19
+ raise "Task #{self.class} did not set a proper success status" if success.nil?
20
+ success
21
+ end
22
+
23
+ def reversal_instruction
24
+ nil
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :target
30
+ attr_writer :error
31
+ attr_accessor :success
32
+
33
+ def confirm?
34
+ !!@confirm
35
+ end
36
+
37
+ def dry_run?
38
+ !!@dry_run
39
+ end
40
+
41
+ # Subclasses are required to implement the 'run' method
42
+ def run
43
+ raise "Don't know how to execute task for class: #{self.class}"
44
+ end
45
+
46
+ def confirm_successful?(message)
47
+ loop do
48
+ puts
49
+
50
+ print "#{message} [Yes / No] > "
51
+ answer = $stdin.gets.chomp.downcase
52
+
53
+ if answer == 'yes'
54
+ return true
55
+
56
+ elsif answer == 'no'
57
+ return false
58
+
59
+ else
60
+ puts 'Unknown answer'
61
+ end
62
+ end
63
+ end
64
+
65
+ def execute_system_command(cmd)
66
+ if dry_run?
67
+ puts "Executing command: #{cmd}"
68
+ else
69
+ system(cmd)
70
+ end
71
+ end
72
+
73
+ def print_stage(msg)
74
+ puts msg.blue
75
+ end
76
+
77
+ def print_success(msg)
78
+ puts msg.green
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,3 @@
1
1
  module HR_Deploy
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hr_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Gubitskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-06-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easily deploy your Rails apps to Heroku with one command, automatically
14
14
  taking care of things such as checking current Heroku status, enabling maintenance
@@ -19,9 +19,27 @@ executables:
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - lib/hr_deploy/application.rb
23
+ - lib/hr_deploy/parser.rb
22
24
  - lib/hr_deploy/deployer.rb
23
25
  - lib/hr_deploy/config_handler.rb
24
26
  - lib/hr_deploy/target.rb
27
+ - lib/hr_deploy/helper.rb
28
+ - lib/hr_deploy/color.rb
29
+ - lib/hr_deploy/tasks/task.rb
30
+ - lib/hr_deploy/tasks/check_network_task.rb
31
+ - lib/hr_deploy/tasks/check_heroku_task.rb
32
+ - lib/hr_deploy/tasks/enable_pinger_task.rb
33
+ - lib/hr_deploy/tasks/disable_pinger_task.rb
34
+ - lib/hr_deploy/tasks/enable_maintenance_task.rb
35
+ - lib/hr_deploy/tasks/disable_maintenance_task.rb
36
+ - lib/hr_deploy/tasks/backup_db_task.rb
37
+ - lib/hr_deploy/tasks/clean_old_assets_task.rb
38
+ - lib/hr_deploy/tasks/clean_new_assets_task.rb
39
+ - lib/hr_deploy/tasks/precompile_assets_task.rb
40
+ - lib/hr_deploy/tasks/push_code_task.rb
41
+ - lib/hr_deploy/tasks/migrate_db_task.rb
42
+ - lib/hr_deploy/tasks/restart_task.rb
25
43
  - lib/hr_deploy/version.rb
26
44
  - bin/hr_deploy
27
45
  homepage: https://github.com/enthrops/hr_deploy