effective_developer 0.4.14 → 0.4.15

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: 33e92fc9bd9a51a447bd0128b11463ac1e06c854389e1e996872c5f012b02e47
4
- data.tar.gz: 87049e6643aaa2235639729e97d93d48f642827a53a9cefe8aab34b1d206ea1e
3
+ metadata.gz: 2f7cccd4c476002105c649c582f9fe243d7ec605941756b705c0fba8012cd8db
4
+ data.tar.gz: dddc8875b4723c497471b4445e42c6e45de0c59fab4a2493062d608b236fa68d
5
5
  SHA512:
6
- metadata.gz: 67119ab7a04b64551565dacc737a8bf95eb06793c0bab5fbd6bf26b3e8f2afc7a62e4c2e686b4b48f55db477f86e70147a1ab3d30f9c7b13b21b36a403a60bf8
7
- data.tar.gz: 6908000780ca6d53f58dd21ca7a6cf15f757113db5e27e8b2aaa6ef4ae09c15efb60a5965b50c03801c28e4fb9751074dea193c1445d6880df2499820304bcb4
6
+ metadata.gz: 8301e15ea438d1e927b601824f96a352ce996d653200e21509bdceb738f2f69bdbb522d7570656e3d6265a6607d0574f312ebb44624ae31f2063aa840f56af11
7
+ data.tar.gz: 8f89d98d3413016395f27d4d1576c1c6514a0820734f18f4acde0374d6c66eb954554349ead83aaddbfb26711d8afce83213cf94ebbb58bc109304a7292a8da9
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.14'.freeze
2
+ VERSION = '0.4.15'.freeze
3
3
  end
@@ -0,0 +1,15 @@
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
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,28 @@
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
+ puts("Error capturing heroku backup")
16
+ exit
17
+ end
18
+
19
+ if system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
20
+ puts "Downloading database completed"
21
+ else
22
+ puts "Error downloading database"
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -1,26 +1,19 @@
1
1
  namespace :pg do
2
- # Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
2
+ # Creates a new backup on remote server, downloads that backup to latest.dump, and then calls pg:load
3
3
  #
4
4
  # bundle exec rake pg:pull
5
5
  # bundle exec rake pg:pull[staging]
6
- desc 'Pulls a newly captured backup from heroku (--remote heroku by default) and calls pg:load'
6
+ # bundle exec rake pg:pull[158.204.33.124]
7
+ desc 'Creates a new backup on remote server and downloads it to latest.dump'
7
8
  task :pull, [:remote] => :environment do |t, args|
8
- args.with_defaults(:remote => 'heroku')
9
-
10
- puts "=== Pulling remote '#{args.remote}' database into latest.dump"
11
-
12
- Bundler.with_clean_env do
13
- unless system("heroku pg:backups:capture --remote #{args.remote}")
14
- puts "Error capturing heroku backup"
15
- exit
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
- puts "Error downloading database"
22
- exit
23
- end
9
+ 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
+ exit
24
17
  end
25
18
 
26
19
  Rake::Task['pg:load'].invoke
@@ -33,9 +26,11 @@ namespace :pg do
33
26
  desc 'Loads a postgresql .dump file into the development database (latest.dump by default)'
34
27
  task :load, [:file_name] => :environment do |t, args|
35
28
  args.with_defaults(:file_name => 'latest.dump')
36
- db = ActiveRecord::Base.configurations[Rails.env]
37
29
 
38
- puts "=== Loading #{args.file_name} into local '#{db['database']}' database"
30
+ config = ActiveRecord::Base.configurations[Rails.env]
31
+ db = { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
32
+
33
+ puts "=== Loading #{args.file_name} into local '#{db[:database]}' database"
39
34
 
40
35
  # bin/rails db:environment:set RAILS_ENV=development
41
36
  if Rails.env != 'production'
@@ -45,7 +40,7 @@ namespace :pg do
45
40
  Rake::Task['db:drop'].invoke
46
41
  Rake::Task['db:create'].invoke
47
42
 
48
- if system("pg_restore --no-acl --no-owner --clean --if-exists -h localhost -U #{db['username']} -d #{db['database']} #{args.file_name}")
43
+ if system("export PGPASSWORD=#{db[:password]}; pg_restore --no-acl --no-owner --clean --if-exists -h #{db[:host]} -U #{db[:username]} -d #{db[:database]} #{args.file_name}")
49
44
  puts "Loading database completed"
50
45
  else
51
46
  puts "Error loading database"
@@ -57,11 +52,24 @@ namespace :pg do
57
52
  desc 'Saves the development database to a postgresql .dump file (latest.dump by default)'
58
53
  task :save, [:file_name] => :environment do |t, args|
59
54
  args.with_defaults(:file_name => 'latest.dump')
60
- db = ActiveRecord::Base.configurations[Rails.env]
61
55
 
62
- puts "=== Saving local '#{db['database']}' database to #{args.file_name}"
56
+ db = if ENV['DATABASE_URL'].to_s.length > 0
57
+ regex = Regexp.new(/postgres:\/\/(\w+):(\w+)@(.+):(\d+)\/(\w+)/)
58
+ info = ENV['DATABASE_URL'].match(regex)
59
+
60
+ if info.blank? || info.length != 6
61
+ puts("Invalid DATABASE_URL") and exit
62
+ end
63
+
64
+ { username: info[1], password: info[2], host: info[3], port: info[4], database: info[5] }
65
+ else
66
+ config = ActiveRecord::Base.configurations[Rails.env]
67
+ { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
68
+ end
69
+
70
+ puts "=== Saving local '#{db[:database]}' database to #{args.file_name}"
63
71
 
64
- if system("pg_dump -Fc --no-acl --no-owner -h localhost -U '#{db['username']}' '#{db['database']}' > #{args.file_name}")
72
+ if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.file_name}")
65
73
  puts "Saving database completed"
66
74
  else
67
75
  puts "Error saving database"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_developer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-05 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,6 +95,8 @@ 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
98
100
  - lib/tasks/pg_pull.rake
99
101
  - lib/tasks/rename_class.rake
100
102
  - lib/tasks/reset_pk_sequence.rake