effective_developer 0.4.15 → 0.4.16

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
  SHA256:
3
- metadata.gz: 2f7cccd4c476002105c649c582f9fe243d7ec605941756b705c0fba8012cd8db
4
- data.tar.gz: dddc8875b4723c497471b4445e42c6e45de0c59fab4a2493062d608b236fa68d
3
+ metadata.gz: 7d56abcd9d4964e1ef609e137ee2e5cf0af65fef0b94420b75ece42f5dea60a9
4
+ data.tar.gz: 626969c07fd04d4886b2b6044111ec3651c8f682dbb316318106f2528dca7dd1
5
5
  SHA512:
6
- metadata.gz: 8301e15ea438d1e927b601824f96a352ce996d653200e21509bdceb738f2f69bdbb522d7570656e3d6265a6607d0574f312ebb44624ae31f2063aa840f56af11
7
- data.tar.gz: 8f89d98d3413016395f27d4d1576c1c6514a0820734f18f4acde0374d6c66eb954554349ead83aaddbfb26711d8afce83213cf94ebbb58bc109304a7292a8da9
6
+ metadata.gz: 046a257cd7af7e70f2973f3d6082758a66c54982e8ee4b34f32ee91146ef43dd66c4c1b04dc7eb9d2503a5321d83d64f159d715d17f19bcf4b41d64f6427a555
7
+ data.tar.gz: 904fe1dea98e96c21e87c7a74c6c2b7364025edc208719e6d657915566d3de47851892de84811b7e14ab6601edb65dcfecfd543aace4ec6f1bfa3edc5f47c15c
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.15'.freeze
2
+ VERSION = '0.4.16'.freeze
3
3
  end
@@ -9,6 +9,8 @@ namespace :hatchbox do
9
9
  args.with_defaults(remote: ENV['HATCHBOX_IP'])
10
10
 
11
11
  puts "=== Pulling remote '#{args.remote}' database into latest.dump"
12
+
13
+ #scp deploy@159.203.32.114:~/cab/current/latest.dump ./
12
14
  end
13
15
 
14
16
  end
@@ -12,14 +12,13 @@ namespace :heroku do
12
12
 
13
13
  Bundler.with_clean_env do
14
14
  unless system("heroku pg:backups:capture --remote #{args.remote}")
15
- puts("Error capturing heroku backup")
16
- exit
15
+ abort("Error capturing heroku backup")
17
16
  end
18
17
 
19
18
  if system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
20
- puts "Downloading database completed"
19
+ puts("Downloading database completed")
21
20
  else
22
- puts "Error downloading database"
21
+ abort("Error downloading database")
23
22
  end
24
23
  end
25
24
  end
@@ -13,7 +13,7 @@ namespace :pg do
13
13
  else
14
14
  puts "Unable to find pg:pull provider."
15
15
  puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
16
- exit
16
+ abort
17
17
  end
18
18
 
19
19
  Rake::Task['pg:load'].invoke
@@ -43,7 +43,7 @@ namespace :pg do
43
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}")
44
44
  puts "Loading database completed"
45
45
  else
46
- puts "Error loading database"
46
+ abort "Error loading database"
47
47
  end
48
48
  end
49
49
 
@@ -54,14 +54,10 @@ namespace :pg do
54
54
  args.with_defaults(:file_name => 'latest.dump')
55
55
 
56
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)
57
+ uri = URI.parse(ENV['DATABASE_URL']) rescue nil
58
+ abort("Invalid DATABASE_URL") unless uri.present?
59
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] }
60
+ { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
65
61
  else
66
62
  config = ActiveRecord::Base.configurations[Rails.env]
67
63
  { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
@@ -72,7 +68,7 @@ namespace :pg do
72
68
  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}")
73
69
  puts "Saving database completed"
74
70
  else
75
- puts "Error saving database"
71
+ abort "Error saving database"
76
72
  end
77
73
  end
78
74
 
@@ -85,20 +81,17 @@ namespace :pg do
85
81
 
86
82
  Bundler.with_clean_env do
87
83
  unless system("heroku pg:backups:capture --remote #{args.source_remote}")
88
- puts "Error capturing heroku backup"
89
- exit
84
+ abort "Error capturing heroku backup"
90
85
  end
91
86
 
92
87
  url = (`heroku pg:backups:public-url --remote #{args.source_remote}`).chomp
93
88
 
94
89
  unless (url || '').length > 0
95
- puts "Error reading public-url from remote #{args.source_remote}"
96
- exit
90
+ abort "Error reading public-url from remote #{args.source_remote}"
97
91
  end
98
92
 
99
93
  unless system("heroku pg:backups:restore '#{url}' DATABASE_URL --remote #{args.target_remote}")
100
- puts "Error cloning heroku backup"
101
- exit
94
+ abort "Error cloning heroku backup"
102
95
  end
103
96
  end
104
97
 
@@ -110,7 +103,7 @@ namespace :pg do
110
103
  args.with_defaults(:remote => 'heroku')
111
104
 
112
105
  if args.table.blank?
113
- puts "Error, no table name specified. Expected usage: rake pg:push_table[prices]"; exit
106
+ abort "Error, no table name specified. Expected usage: rake pg:push_table[prices]"
114
107
  end
115
108
 
116
109
  # Find and parse my heroku database info
@@ -121,14 +114,14 @@ namespace :pg do
121
114
  if info.blank? || info.length != 6
122
115
  puts "Unable to find heroku DATABASE_URL"
123
116
  puts "Expected \"heroku config --remote #{args.remote} | grep DATABASE_URL\" to be present"
124
- exit
117
+ abort
125
118
  end
126
119
 
127
120
  heroku = { username: info[1], password: info[2], host: info[3], port: info[4], database: info[5] }
128
121
 
129
122
  # Confirm destructive operation
130
123
  puts "WARNING: this task will overwrite the #{args.table} database table on #{args.remote}. Proceed? (y/n)"
131
- (puts 'Aborted' and exit) unless STDIN.gets.chomp.downcase == 'y'
124
+ abort('Aborted') unless STDIN.gets.chomp.downcase == 'y'
132
125
 
133
126
  puts "=== Cloning local table '#{args.table}' to remote #{args.remote} database"
134
127
 
@@ -137,7 +130,7 @@ namespace :pg do
137
130
  tmpfile = "tmp/#{args.table}.sql"
138
131
 
139
132
  unless system("pg_dump --data-only --table=#{args.table} -h localhost -U '#{db['username']}' '#{db['database']}' > #{tmpfile}")
140
- puts "Error dumping local database table"; exit
133
+ abort "Error dumping local database table"
141
134
  end
142
135
 
143
136
  # Now restore it to heroku
@@ -145,11 +138,11 @@ namespace :pg do
145
138
  delete = args.table.split(',').map { |table| "DELETE FROM #{table}" }.join(';')
146
139
 
147
140
  unless system("#{psql} -c \"#{delete}\"")
148
- puts "Error deleting remote table data"; exit
141
+ abort "Error deleting remote table data"
149
142
  end
150
143
 
151
144
  unless system("#{psql} < #{tmpfile}")
152
- puts "Error pushing table to remote database"; exit
145
+ abort "Error pushing table to remote database"
153
146
  end
154
147
 
155
148
  # Delete tmpfile
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.15
4
+ version: 0.4.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect