effective_developer 0.4.16 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d56abcd9d4964e1ef609e137ee2e5cf0af65fef0b94420b75ece42f5dea60a9
4
- data.tar.gz: 626969c07fd04d4886b2b6044111ec3651c8f682dbb316318106f2528dca7dd1
3
+ metadata.gz: 69c2ad2ced44b14156608bb55919de80279aa387486fb46dc9dc6b231c6b6944
4
+ data.tar.gz: 4cb2421a2691a9a1678e01a85f89619ad9084ec9db2c78b4937b64dea5d9140d
5
5
  SHA512:
6
- metadata.gz: 046a257cd7af7e70f2973f3d6082758a66c54982e8ee4b34f32ee91146ef43dd66c4c1b04dc7eb9d2503a5321d83d64f159d715d17f19bcf4b41d64f6427a555
7
- data.tar.gz: 904fe1dea98e96c21e87c7a74c6c2b7364025edc208719e6d657915566d3de47851892de84811b7e14ab6601edb65dcfecfd543aace4ec6f1bfa3edc5f47c15c
6
+ metadata.gz: '089b86610b269844cfcf035de7ee7b30b44feda053d083caa27c1a7856e77d2e554fb457663dc481fd53b1bc0d2d6cc6eb91c562333bc1386b11a44786691e37'
7
+ data.tar.gz: 6abc2003eee8e83cf9980d99ddcef466fde60286504f54cf1d09121bbbf8a8e3c8c7a9ca47ee84c7e26a86802a89f5b18d2f12298be00f7a14b4634c63e60274
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.16'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -6,17 +6,60 @@ namespace :pg do
6
6
  # bundle exec rake pg:pull[158.204.33.124]
7
7
  desc 'Creates a new backup on remote server and downloads it to latest.dump'
8
8
  task :pull, [:remote] => :environment do |t, args|
9
+
10
+ # Heroku mode
9
11
  if `git remote -v | grep heroku`.length > 0
10
- Rake::Task['heroku:pg:pull'].invoke(args[:remote])
11
- elsif (args[:remote] || ENV['HATCHBOX_IP']).to_s.count('.') == 3
12
- Rake::Task['hatchbox:pg:pull'].invoke(args[:remote])
13
- else
14
- puts "Unable to find pg:pull provider."
15
- puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
16
- abort
12
+ args.with_defaults(remote: 'heroku')
13
+
14
+ puts "=== Pulling remote '#{args.remote}' database into latest.dump"
15
+
16
+ # Create a backup on heroku
17
+ unless system("heroku pg:backups:capture --remote #{args.remote}")
18
+ abort("Error capturing heroku backup")
19
+ end
20
+
21
+ # Download it to local
22
+ unless system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
23
+ abort("Error downloading database")
24
+ end
25
+
26
+ # Load it
27
+ Rake::Task['pg:load'].invoke
28
+ exit
29
+ end
30
+
31
+ # Hatchbox mode
32
+ if (ENV['HATCHBOX_IP'] || args[:remote]).count('.') == 3
33
+ args.with_defaults(
34
+ remote: ENV.fetch('HATCHBOX_IP'),
35
+ app: ENV['HATCHBOX_APP'] || `pwd`.split('/').last.chomp,
36
+ user: ENV['HATCHBOX_USER'] || 'deploy'
37
+ )
38
+
39
+ puts "=== Pulling hatchbox '#{args.remote}' #{args.app} database into latest.dump"
40
+
41
+ # SSH into hatchbox and call rake pg:save there to create latest.dump
42
+ unless(result = `ssh #{args.user}@#{args.remote} << EOF
43
+ cd ~/#{args.app}/current/
44
+ bundle exec rake pg:save[latest.dump]
45
+ `).include?('Saving database completed') # The output of pg:save down below
46
+ puts("Error calling ssh #{args.user}@#{args.remote} and running rake pg:save on hatchbox from ~/#{args.app}/current/")
47
+ abort(result)
48
+ end
49
+
50
+ # SCP to copy the hatchkbox latest.dump to local
51
+ unless system("scp deploy@159.203.32.114:~/cab/current/latest.dump ./")
52
+ abort("Error downloading database")
53
+ end
54
+
55
+ # Load it
56
+ Rake::Task['pg:load'].invoke
57
+ exit
17
58
  end
18
59
 
19
- Rake::Task['pg:load'].invoke
60
+ puts "Unable to find pg:pull provider."
61
+ puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
62
+ abort
20
63
  end
21
64
 
22
65
  # Drops and re-creates the local database then initializes database with latest.dump
@@ -60,7 +103,7 @@ namespace :pg do
60
103
  { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
61
104
  else
62
105
  config = ActiveRecord::Base.configurations[Rails.env]
63
- { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
106
+ { username: (config['username'] || `whoami`.chomp), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
64
107
  end
65
108
 
66
109
  puts "=== Saving local '#{db[:database]}' database to #{args.file_name}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_developer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -95,8 +95,6 @@ files:
95
95
  - lib/scaffolds/models/model.rb
96
96
  - lib/scaffolds/views/_resource.html.haml
97
97
  - lib/tasks/effective_csv_importer.rake
98
- - lib/tasks/hatchbox.rake
99
- - lib/tasks/heroku.rake
100
98
  - lib/tasks/pg_pull.rake
101
99
  - lib/tasks/rename_class.rake
102
100
  - lib/tasks/reset_pk_sequence.rake
@@ -1,17 +0,0 @@
1
- namespace :hatchbox do
2
- namespace :pg do
3
- # Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
4
- #
5
- # bundle exec rake heroku:pull
6
- # bundle exec rake heroku:pull[staging]
7
- desc 'Pulls a newly captured backup from heroku (--remote heroku by default) and calls pg:load'
8
- task :pull, [:remote] => :environment do |t, args|
9
- args.with_defaults(remote: ENV['HATCHBOX_IP'])
10
-
11
- puts "=== Pulling remote '#{args.remote}' database into latest.dump"
12
-
13
- #scp deploy@159.203.32.114:~/cab/current/latest.dump ./
14
- end
15
-
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- namespace :heroku do
2
- namespace :pg do
3
- # Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
4
- #
5
- # bundle exec rake heroku:pg:pull
6
- # bundle exec rake heroku:pg:pull[staging]
7
- desc 'Pulls a newly captured backup from heroku (--remote heroku by default)'
8
- task :pull, [:remote] => :environment do |t, args|
9
- args.with_defaults(remote: 'heroku')
10
-
11
- puts "=== Pulling remote '#{args.remote}' database into latest.dump"
12
-
13
- Bundler.with_clean_env do
14
- unless system("heroku pg:backups:capture --remote #{args.remote}")
15
- abort("Error capturing heroku backup")
16
- end
17
-
18
- if system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
19
- puts("Downloading database completed")
20
- else
21
- abort("Error downloading database")
22
- end
23
- end
24
- end
25
-
26
- end
27
- end