effective_developer 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c29066e84e43bb85a6bbb3b355537784ca8a8634
4
- data.tar.gz: aa3035ca68b854b7f2b0416ca59b92680a07ae72
3
+ metadata.gz: 26ec6d6142e9588dfc8f9477c26430dbcbec09fc
4
+ data.tar.gz: e00454d2b278034b558ca451d81bad7076c2b0dc
5
5
  SHA512:
6
- metadata.gz: 412c6fe2018b272ef2a3208a25d3a5d9477414f1b02aa15718fcece18e3d82957cc12740078423f672ad4fcd6ed1a9b4eebb3964bbed108fd81e53cebe867746
7
- data.tar.gz: 730983166244c70d25a519f97a69a5717bfbeff1f681d74c0cd824460bf6ecd5a3dfe34a37ba37848083e788ffec4f4a5f6e42644cc2f12d23f36936c5e6a25f
6
+ metadata.gz: 37f824c6c0e3a972be2d59a44ebf22607d375250800f9eb35901b4bcc44be70c176f5d6393afdc517812f90f58ddf988eb38f9fb4e2e047455829f1c216a7eaa
7
+ data.tar.gz: 6b5dab0909f0c2fd2cc5ede9a8e697e714245e515f78ba6873993ffefb7137cc2afc62d89362263d82a08d0ada9fee45c7ed13793ad4391a7cbbe25511575d76
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -11,7 +11,7 @@ namespace :pg do
11
11
 
12
12
  Bundler.with_clean_env do
13
13
  unless system("heroku pg:backups capture --remote #{args.remote}")
14
- puts "Error capturing backup"
14
+ puts "Error capturing heroku backup"
15
15
  exit
16
16
  end
17
17
 
@@ -33,14 +33,14 @@ namespace :pg do
33
33
  desc 'Loads a postgresql .dump file into the development database (latest.dump by default)'
34
34
  task :load, [:file_name] => :environment do |t, args|
35
35
  args.with_defaults(:file_name => 'latest.dump')
36
- db = ActiveRecord::Base.configurations
36
+ db = ActiveRecord::Base.configurations[Rails.env]
37
37
 
38
- puts "=== Loading #{args.file_name} into local '#{db[Rails.env]['database']}' database"
38
+ puts "=== Loading #{args.file_name} into local '#{db['database']}' database"
39
39
 
40
40
  Rake::Task['db:drop'].invoke
41
41
  Rake::Task['db:create'].invoke
42
42
 
43
- if system("pg_restore --no-acl --no-owner -h localhost -U #{db[Rails.env]['username']} -d #{db[Rails.env]['database']} #{args.file_name}")
43
+ if system("pg_restore --no-acl --no-owner -h localhost -U #{db['username']} -d #{db['database']} #{args.file_name}")
44
44
  puts "Loading database completed"
45
45
  else
46
46
  puts "Error loading database"
@@ -52,15 +52,44 @@ namespace :pg do
52
52
  desc 'Saves the development database to a postgresql .dump file (latest.dump by default)'
53
53
  task :save, [:file_name] => :environment do |t, args|
54
54
  args.with_defaults(:file_name => 'latest.dump')
55
- db = ActiveRecord::Base.configurations
55
+ db = ActiveRecord::Base.configurations[Rails.env]
56
56
 
57
- puts "=== Saving local '#{db[Rails.env]['database']}' database to #{args.file_name}"
57
+ puts "=== Saving local '#{db['database']}' database to #{args.file_name}"
58
58
 
59
- if system("pg_dump -Fc --no-acl --no-owner -h localhost -U '#{db[Rails.env]['username']}' '#{db[Rails.env]['database']}' > #{args.file_name}")
59
+ if system("pg_dump -Fc --no-acl --no-owner -h localhost -U '#{db['username']}' '#{db['database']}' > #{args.file_name}")
60
60
  puts "Saving database completed"
61
61
  else
62
- puts "Error saving postgres database"
62
+ puts "Error saving database"
63
63
  end
64
64
  end
65
65
 
66
+ desc 'Clones the production (--remote heroku by default) database to staging (--remote staging by default)'
67
+ task :clone, [:source_remote, :target_remote] => :environment do |t, args|
68
+ args.with_defaults(:source_remote => 'heroku', :target_remote => 'staging')
69
+ db = ActiveRecord::Base.configurations[Rails.env]
70
+
71
+ puts "=== Cloning remote '#{args.source_remote}' to '#{args.target_remote}'"
72
+
73
+ Bundler.with_clean_env do
74
+ unless system("heroku pg:backups capture --remote #{args.source_remote}")
75
+ puts "Error capturing heroku backup"
76
+ exit
77
+ end
78
+
79
+ url = (`heroku pg:backups public-url --remote #{args.source_remote}`).chomp
80
+
81
+ unless (url || '').length > 0
82
+ puts "Error reading public-url from remote #{args.source_remote}"
83
+ exit
84
+ end
85
+
86
+ unless system("heroku pg:backups restore '#{url}' DATABASE_URL --remote #{args.target_remote}")
87
+ puts "Error cloning heroku backup"
88
+ exit
89
+ end
90
+ end
91
+
92
+ puts 'Cloning database complete'
93
+ end
94
+
66
95
  end
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.0.2
4
+ version: 0.0.3
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: 2016-04-26 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails